Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
 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
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
 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
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 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)
Exemplo n.º 10
0
 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'
Exemplo n.º 11
0
 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'
Exemplo n.º 12
0
 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)
Exemplo n.º 13
0
 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)