def main(opts, args): if len(args) == 0: sys.exit( "Need to specify a relative path to the script you want to run.") script_path = args[0] if not script_path.endswith('.py'): sys.exit( "You can only reference python scripts that end with a .py extension." ) mltshpoptions.parse_dictionary(getattr(settings, opts.settings)) # if a server argument was specified and doesn't match with the # server_id configured for settings, then exit silently # without running if opts.server_id and opts.server_id != options.server_id: exit(0) lib.flyingcow.register_connection(host=options.database_host, name=options.database_name, user=options.database_user, password=options.database_password) if options.stripe_secret_key: stripe.api_key = options.stripe_secret_key run(script_path)
def run(self, hostname=None, pool_cls=None, app=None, uid=None, gid=None, loglevel=None, logfile=None, pidfile=None, statedb=None, settings=None, **kwargs): # Set up the settings first. try: settings_data = getattr(app_settings, settings) except AttributeError: sys.stderr.write("\nCouldn't find set of settings %r in 'settings'?\n" % settings) sys.exit(1) mltshpoptions.parse_dictionary(settings_data) return super(TornadoWorkerCommand, self).run(hostname, pool_cls, app, uid, gid, loglevel, logfile, pidfile, statedb, **kwargs)
def main(opts, args): if len(args) == 0: sys.exit( "Need to specify a relative path to the script you want to run.") script_path = args[0] if not script_path.endswith('.py'): sys.exit( "You can only reference python scripts that end with a .py extension." ) mltshpoptions.parse_dictionary(getattr(settings, opts.settings)) lib.flyingcow.register_connection(host=options.database_host, name=options.database_name, user=options.database_user, password=options.database_password) if options.stripe_secret_key: stripe.api_key = options.stripe_secret_key run(script_path)
from tornado.options import define, options import mltshpoptions from settings import settings mltshpoptions.parse_dictionary(settings) from yoyo import read_migrations, get_backend import logging logging.basicConfig(level=logging.INFO) backend = get_backend( "mysql+mysqldb://%s:%s@%s/%s" % (options.database_user, options.database_password, options.database_host, options.database_name)) migrations = read_migrations("migrations") print "Applying migrations..." backend.apply_migrations(backend.to_apply(migrations)) print "...complete!"