def handle(self, options, global_options, *args): from werkzeug.serving import run_simple from uliweb import get_apps if self.develop: include_apps = ['uliweb.contrib.develop'] app = make_application(options.debug, project_dir=global_options.project, include_apps=include_apps) else: app = make_application(options.debug, project_dir=global_options.project) include_apps = [] extra_files = collect_files(global_options.apps_dir, get_apps(global_options.apps_dir, settings_file=global_options.settings, local_settings_file=global_options.local_settings)+include_apps) if options.ssl: from OpenSSL import SSL ctx = SSL.Context(SSL.SSLv23_METHOD) if not os.path.exists(options.ssl_key): log.error("Can't find ssl key file [%s], please check it first." % options.ssl_key) sys.exit(1) if not os.path.exists(options.ssl_cert): log.error("Can't find ssl certificate file [%s], please check it first." % options.ssl_key) sys.exit(1) ctx.use_privatekey_file(options.ssl_key) ctx.use_certificate_file(options.ssl_cert) else: ctx = None run_simple(options.hostname, options.port, app, options.reload, False, True, extra_files, 1, options.thread, options.processes, ssl_context=ctx)
def handle(self, options, global_options, *args): if not args: print "Error: There is no command module name behind call command." return else: command = args[0] if not options.appname: from uliweb import get_apps apps = get_apps(global_options.apps_dir, settings_file=global_options.settings, local_settings_file=global_options.local_settings) else: apps = [options.appname] exe_flag = False for f in apps: m = '%s.%s' % (f, command) try: mod = __import__(m, {}, {}, ['']) if global_options.verbose: print "Importing... %s.%s" % (f, command) if hasattr(mod, 'call'): getattr(mod, 'call')(args, options, global_options) exe_flag = True except ImportError: continue if not exe_flag: print "Error: Can't import the [%s], please check the file and try again." % command
def collect_commands(): from uliweb import get_apps for f in get_apps(apps_dir): m = '%s.commands' % f try: mod = __import__(m, {}, {}, ['']) except ImportError: continue find_mod_commands(mod)
def collect_commands(): from uliweb import get_apps, get_app_dir from uliweb.utils.common import is_pyfile_exist apps = get_apps(global_options.apps_dir, settings_file=global_options.settings, local_settings_file=global_options.local_settings) for f in apps: path = get_app_dir(f) if is_pyfile_exist(path, 'commands'): m = '%s.commands' % f mod = __import__(m, fromlist=['*']) find_mod_commands(mod)
def collect_commands(): from uliweb import get_apps for f in get_apps(global_options.apps_dir, settings_file=global_options.settings, local_settings_file=global_options.local_settings): m = '%s.commands' % f try: mod = __import__(m, fromlist=['*']) except ImportError as e: if not str(e).startswith('No module named'): import traceback traceback.print_exc() continue find_mod_commands(mod)
def handle(self, options, global_options, *args): from uliweb.utils.common import copy_dir_with_check from uliweb import get_apps if not args: print >>sys.stderr, "Error: outputdir should be a directory and existed" sys.exit(0) else: outputdir = args[0] apps = get_apps(global_options.apps_dir, settings_file=global_options.settings, local_settings_file=global_options.local_settings) dirs = [os.path.join(SimpleFrame.get_app_dir(appname), 'static') for appname in reversed(apps)] self.options = options self.global_options = global_options copy_dir_with_check(dirs, outputdir, False, options.check, processor=self.process_file)