Example #1
0
def main():
    usage = "%prog {-c | -u} connString='required' mysql_engine='optional'"
    desc = ' '.join(__doc__.split())
    parser = OptionParser(usage=usage, description=desc)
    parser.add_option('-c',
                      '--check',
                      dest='schema_check',
                      action='store_true',
                      default=False,
                      help="Perform a schema check")
    parser.add_option('-u',
                      '--upgrade',
                      dest='upgrade',
                      action='store_true',
                      default=False,
                      help="Upgrade database to current version.")
    options, args = parser.parse_args(sys.argv[1:])
    log = get_logger(__file__)

    if len(args) == 0:
        parser.print_help()
        parser.error("Option flag and connection string required.")

    if log.getEffectiveLevel() >= logging.DEBUG:
        get_root_logger().setLevel(logging.INFO)

    num_modes = (0, 1)[bool(options.schema_check)] + (0, 1)[bool(
        options.upgrade)]
    if num_modes > 1:
        parser.error('Choose only one option flag')

    init = {}
    for a in args:
        k, v = a.split('=')
        if k in ['connString', 'mysql_engine']:
            init[k] = v

    conn = ConnHandle(**init)
    s_check = SchemaCheck(conn.get_session())

    if options.schema_check:
        log.info('Executing schema check')
        s_check.check_schema()
    elif options.upgrade:
        log.info('Performing upgrade')
        s_check.upgrade()
    pass
Example #2
0
def main():
    usage = "%prog {-c | -u} connString='required' mysql_engine='optional'"
    desc = ' '.join(__doc__.split())
    parser = OptionParser(usage=usage, description=desc)
    parser.add_option('-c', '--check', dest='schema_check', action='store_true',
                        default=False, help="Perform a schema check")
    parser.add_option('-u', '--upgrade', dest='upgrade', action='store_true',
                        default=False, help="Upgrade database to current version.")
    options, args = parser.parse_args(sys.argv[1:])
    log = get_logger(__file__)
    
    if len(args) == 0:
        parser.print_help()
        parser.error("Option flag and connection string required.")

    if log.getEffectiveLevel() >= logging.DEBUG:
        get_root_logger().setLevel(logging.INFO)

    num_modes = (0,1)[bool(options.schema_check)] + (0,1)[bool(options.upgrade)]
    if num_modes > 1:
        parser.error('Choose only one option flag')
        
    init = {}
    for a in args:
        k,v = a.split('=')
        if k in ['connString', 'mysql_engine']:
            init[k] = v
    
    conn = ConnHandle(**init)
    s_check = SchemaCheck(conn.get_session())
    
    if options.schema_check:
        log.info('Executing schema check')
        s_check.check_schema()
    elif options.upgrade:
        log.info('Performing upgrade')
        s_check.upgrade()
    pass
Example #3
0
"""

__rcsid__ = "$Id: _base.py 26972 2011-01-11 16:19:33Z mgoode $"
__author__ = "Monte Goode [email protected]"

import logging
from Pegasus.netlogger.nllog import DoesLogging, get_root_logger


class NullHandler(logging.Handler):
    def emit(self, record):
        pass


# silence the logger since lib may be used by non-netloger apps.
get_root_logger().addHandler(NullHandler())


class WorkflowBase(DoesLogging):
    # indent level for pretty printing = override in subclasses
    # if you want different indent levels for your various
    # objects.
    _indent = 1

    def __init__(self):
        DoesLogging.__init__(self)
        pass

    def __repr__(self):
        spacer = '  '
        retval = '%s:' % self.__class__
Example #4
0
"""

__rcsid__ = "$Id: _base.py 26972 2011-01-11 16:19:33Z mgoode $"
__author__ = "Monte Goode [email protected]"

import logging
from Pegasus.netlogger.nllog import DoesLogging, get_root_logger


class NullHandler(logging.Handler):
    def emit(self, record):
        pass


# silence the logger since lib may be used by non-netloger apps.
get_root_logger().addHandler(NullHandler())


class WorkflowBase(DoesLogging):
    # indent level for pretty printing = override in subclasses
    # if you want different indent levels for your various
    # objects.
    _indent = 1

    def __init__(self):
        DoesLogging.__init__(self)
        pass

    def __repr__(self):
        spacer = "  "
        retval = "%s:" % self.__class__