def collect_files(apps_dir, apps): files = [os.path.join(apps_dir, "settings.ini"), os.path.join(apps_dir, "local_settings.ini")] def f(path): if not os.path.exists(path): log.error("Path %s is not existed!" % path) return for r in os.listdir(path): if r in [".svn", "_svn", ".git"] or r.startswith("."): continue fpath = os.path.join(path, r) if os.path.isdir(fpath): f(fpath) else: ext = os.path.splitext(fpath)[1] if ext in [".py", ".ini"]: files.append(fpath) from uliweb import get_app_dir for p in apps: path = get_app_dir(p) files.append(os.path.join(path, "config.ini")) files.append(os.path.join(path, "settings.ini")) f(path) return files
def collect_files(apps_dir, apps): files = [os.path.join(apps_dir, 'settings.ini'), os.path.join(apps_dir, 'local_settings.ini')] def f(path): if not os.path.exists(path): log.error("Path %s is not existed!" % path) return for r in os.listdir(path): if r in ['.svn', '_svn', '.git'] or r.startswith('.'): continue fpath = os.path.join(path, r) if os.path.isdir(fpath): f(fpath) else: ext = os.path.splitext(fpath)[1] if ext in ['.py', '.ini']: files.append(fpath) from uliweb import get_app_dir for p in apps: path = get_app_dir(p) files.append(os.path.join(path, 'config.ini')) files.append(os.path.join(path, 'settings.ini')) f(path) return files
def get_requirements(): for app in apps: path = get_app_dir(app) r_file = os.path.join(path, 'requirements.txt') if os.path.exists(r_file): yield r_file r_file = os.path.join(global_options.project, 'requirements.txt') if os.path.exists(r_file): yield r_file
def handle(self, options, global_options, *args): from uliweb.utils.common import is_pyfile_exist from uliweb.core.SimpleFrame import get_app_dir if not args: print "Error: There is no command module name behind call command." return else: command = args[0] if options.gevent: from gevent import monkey monkey.patch_all() if options.application: self.get_application(global_options) if not options.appname: apps = self.get_apps(global_options) else: apps = [options.appname] exe_flag = False def get_module(command, apps): if '.' in command: yield 'mod', '', command else: for f in apps: yield 'app', f, command for _type, app, m in get_module(command, apps): mod = None if _type == 'mod': mod_name = m if global_options.verbose: print "Importing... %s" % mod_name mod = __import__(m, fromlist=['*']) else: path = get_app_dir(app) if is_pyfile_exist(path, m): mod_name = app + '.' + m if global_options.verbose: print "Importing... %s" % mod_name mod = __import__('%s.%s' % (app, m), fromlist=['*']) if mod: if hasattr(mod, 'call'): getattr(mod, 'call')(args, options, global_options) elif hasattr(mod, 'main'): getattr(mod, 'main')(args, options, global_options) else: print "Can't find call() or main() function in module %s" % mod_name exe_flag = True if not exe_flag: print "Error: Can't import the [%s], please check the file and try again." % command
def handle(self, options, global_options, *args): from uliweb.utils.common import extract_dirs from uliweb import get_app_dir if not args: extract_dirs('uliweb', 'template_files/command', '.', verbose=global_options.verbose) else: for f in args: p = get_app_dir(f) extract_dirs('uliweb', 'template_files/command', p, verbose=global_options.verbose)
def _find_static(self, global_options, static): from uliweb import get_app_dir apps = self.get_apps(global_options) for appname in reversed(apps): path = os.path.join(get_app_dir(appname), 'static', static) if os.path.exists(path): print '%s' % path return print 'Not Found'
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)