Skip to content

Instantly share code, notes, and snippets.

View abg's full-sized avatar

Andrew Garner abg

  • VMware
  • San Antonio
View GitHub Profile
@abg
abg / gist:972666
Created May 14, 2011 21:38
holland divide-by-zero error
class CheckForSpaceHook(BackupHook):
"""Check for available space before starting a backup"""
job_info = None
def execute(self, job, event):
"""Estimate the available space from the plugin and abort if
there does not appear to be enought to successfully complete this
backup based on the estimate.
:raises: BackupError if estimated_space > available_space
@abg
abg / gist:972845
Created May 15, 2011 02:37
holland-sqlite.patch
--- a/plugins/holland.backup.sqlite/holland/backup/sqlite.py
+++ b/plugins/holland.backup.sqlite/holland/backup/sqlite.py
@@ -11,13 +11,13 @@ LOG = logging.getLogger(__name__)
CONFIGSPEC="""
[sqlite]
databases = force_list(default=list())
-binary = string(default=/usr/bin/sqlite3)
+binary = string(default="/usr/bin/sqlite3")
[compression]
@abg
abg / gist:973800
Created May 16, 2011 02:11
holland-sqlite error
======================================================================
ERROR: tests.test_sqlite.test_sqlite_info
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/nose/case.py", line 186, in runTest
self.test(*self.arg)
File "/home/abg/projects/holland/plugins/holland.backup.sqlite/tests/test_sqlite.py", line 213, in test_sqlite_info
plugin.pre()
File "/home/abg/projects/holland/plugins/holland.backup.sqlite/holland/backup/sqlite.py", line 43, in pre
self.config['sqlite']['binary']
@abg
abg / gist:973807
Created May 16, 2011 02:17
holland test_runner.py patch
--- a/test_runner.py
+++ b/test_runner.py
@@ -112,12 +112,13 @@ class TestRunner(object):
os.chdir(path)
if self.report:
args = [
- self.nosetests,
+ 'python',
+ 'setup.py',
+ 'nosetests',
" vimrc file for following the coding standards specified in PEP 7 & 8.
"
" To use this file, source it in your own personal .vimrc file (``source
" <filename>``) or, if you don't have a .vimrc file, you can just symlink to it
" (``ln -s <this file> ~/.vimrc``). All options are protected by autocmds
" (read below for an explanation of the command) so blind sourcing of this file
" is safe and will not affect your settings for non-Python or non-C files.
"
"
" All setting are protected by 'au' ('autocmd') statements. Only files ending
#!/usr/bin/python
"""
python-bottle based MySQL replication monitor.
Configuration can be specified via [server.*] and [bottle] directivesin /etc/rack_replmon/monitor.conf. The monitor will parse any entry thatbegins with ^server as directives for a server to scan
Valid [server.*] directives:
host, port, user, passwd
Valid [bottle] directives:
host, port
@abg
abg / decode_datetime.py
Created December 2, 2013 19:34
Decode raw MySQL 5.6 datetime data
import ctypes
import datetime
c_uint64 = ctypes.c_uint64
class MySQLDT(ctypes.BigEndianStructure):
_fields_ = [
("sign", c_uint64, 1),
("yearmonth", c_uint64, 17),
("day", c_uint64, 5),
@abg
abg / decode_decimal.py
Created December 2, 2013 19:40
Decode MySQL newdecimal datatype - intended for decoding the defaults buffer in a .frm file.
import operator
import struct
def unpack_integer(data, size, endian='<'):
"""Unpack a MySQL packed integer format
Standard MySQL integers are packed in little endian format,
but various integers are packed in big endian format - e.g.
timestamps and decimal parts.
@abg
abg / filename_to_tablename.py
Last active December 30, 2015 02:39
Decode MySQL filenames to unicode
import binascii
import collections
import re
import struct
CodeRange = collections.namedtuple('CodeRange', 'start end')
class EncodingRule(object):
def __init__(self, coderange, pattern, name, initial_code):
self.coderange = coderange
@abg
abg / cli.py
Last active August 29, 2015 13:56
simple command line helper - inspired by baker.py
"""
cli
~~~
Simple CLI API
@cli.command
def mycommand(required_arg, option='default', *varargs):
...
sys.exit(cli.run())