示例#1
0
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import check_apps_dir
     opts = {'verbose':global_options.verbose, 'template':options.template,
         'exact':options.exact}
     if options.project:
         check_apps_dir(global_options.apps_dir)
         app = self.get_application(global_options)
         
         _process(global_options.apps_dir, options.locale, opts, output_dir=global_options.project)
     elif options.apps or args:
         check_apps_dir(global_options.apps_dir)
         
         app = self.get_application(global_options)
         if options.apps:
             _apps = SimpleFrame.get_apps(global_options.apps_dir)
         else:
             _apps = args
         apps_dir = os.path.normpath(os.path.abspath(global_options.apps_dir))
         for appname in _apps:
             path = SimpleFrame.get_app_dir(appname)
             if global_options.verbose:
                 print('Processing... app=>[%s] path=>[%s]' % (appname, path))
             _process(path, options.locale, opts)
     elif options.uliweb:
         path = pkg.resource_filename('uliweb', '')
         _process(path, options.locale, opts)
     elif options.directory:
         _process(options.directory, options.locale, opts)
示例#2
0
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import check_apps_dir
     opts = {'verbose':global_options.verbose, 'template':options.template,
         'exact':options.exact}
     if options.project:
         check_apps_dir(global_options.apps_dir)
         app = self.get_application(global_options)
         
         _process(global_options.apps_dir, options.locale, opts, output_dir=global_options.project)
     elif options.apps or args:
         check_apps_dir(global_options.apps_dir)
         
         app = self.get_application(global_options)
         if options.apps:
             _apps = SimpleFrame.get_apps(global_options.apps_dir)
         else:
             _apps = args
         apps_dir = os.path.normpath(os.path.abspath(global_options.apps_dir))
         for appname in _apps:
             path = SimpleFrame.get_app_dir(appname)
             if global_options.verbose:
                 print 'Processing... app=>[%s] path=>[%s]' % (appname, path)
             _process(path, options.locale, opts)
     elif options.uliweb:
         path = pkg.resource_filename('uliweb', '')
         _process(path, options.locale, opts)
     elif options.directory:
         _process(options.directory, options.locale, opts)
示例#3
0
 def handle(self, options, global_options, *args):
     opts = {
         'verbose': global_options.verbose,
         'template': options.template,
         'exact': options.exact
     }
     if options.project:
         _process(global_options.project, options.locale, opts)
     elif options.apps or args:
         if options.apps:
             _apps = SimpleFrame.get_apps(global_options.apps_dir)
         else:
             _apps = args
         apps_dir = os.path.normpath(
             os.path.abspath(global_options.apps_dir))
         for appname in _apps:
             path = SimpleFrame.get_app_dir(appname)
             if not path.startswith(apps_dir):
                 continue
             _process(SimpleFrame.get_app_dir(appname), options.locale,
                      opts)
     elif options.uliweb:
         path = pkg.resource_filename('uliweb', '')
         _process(path, options.locale, opts)
     elif options.directory:
         _process(options.directory, options.locale, opts)
示例#4
0
 def make_shell_env(self, global_options):
     application = SimpleFrame.Dispatcher(project_dir=global_options.project, 
         settings_file=global_options.settings, 
         local_settings_file=global_options.local_settings, 
         start=False)
     env = {'application':application, 'settings':application.settings}
     return env
示例#5
0
文件: manage.py 项目: 08haozi/uliweb
    def handle(self, options, global_options, *args):
        from uliweb.utils.common import copy_dir
        from uliweb.utils.common import pkg

        _types = []
        support_dirs = {}
        app_dirs = [
            os.path.join(SimpleFrame.get_app_dir(appname), "template_files/support")
            for appname in self.get_apps(global_options)
        ]
        for path in [pkg.resource_filename("uliweb", "template_files/support/")] + app_dirs:
            if os.path.exists(path):
                for f in os.listdir(path):
                    _path = os.path.join(path, f)
                    if os.path.isdir(_path) and not f.startswith("."):
                        _name = f
                        _types.append(_name)
                        support_dirs[_name] = _path

        support_type = args[0] if args else ""
        while not support_type in _types and support_type != "quit":
            print "Supported types:\n"
            print "    " + "\n    ".join(sorted(_types))
            print
            support_type = raw_input("Please enter support type[quit to exit]:")

        if support_type != "quit":
            src_dir = support_dirs[support_type]
            copy_dir(src_dir, ".", verbose=global_options.verbose)
示例#6
0
    def handle(self, options, global_options, *args):
        from uliweb.utils.common import copy_dir
        from uliweb.utils.common import pkg
        
        _types = []
        support_dirs = {}
        app_dirs = [os.path.join(SimpleFrame.get_app_dir(appname), 'template_files/support') for appname in self.get_apps(global_options)]
        for path in [pkg.resource_filename('uliweb', 'template_files/support/')] + app_dirs:
            if os.path.exists(path):
                for f in os.listdir(path):
                    _path = os.path.join(path, f)
                    if os.path.isdir(_path) and not f.startswith('.'):
                        _name = f
                        _types.append(_name)
                        support_dirs[_name] = _path

        support_type = args[0] if args else ''
        while not support_type in _types and support_type != 'quit':
            print 'Supported types:\n'
            print '    ' + '\n    '.join(sorted(_types))
            print
            support_type = raw_input('Please enter support type[quit to exit]:')
        
        if support_type != 'quit':
            src_dir = support_dirs[support_type]
            copy_dir(src_dir, '.', verbose=global_options.verbose)
示例#7
0
文件: manage.py 项目: dtld/uliweb
    def handle(self, options, global_options, *args):
        from uliweb.utils.common import copy_dir
        from uliweb.utils.common import pkg
        
        _types = []
        support_dirs = {}
        app_dirs = [os.path.join(SimpleFrame.get_app_dir(appname), 'template_files/support') for appname in self.get_apps(global_options)]
        for path in [pkg.resource_filename('uliweb', 'template_files/support/')] + app_dirs:
            if os.path.exists(path):
                for f in os.listdir(path):
                    _path = os.path.join(path, f)
                    if os.path.isdir(_path) and not f.startswith('.'):
                        _name = f
                        _types.append(_name)
                        support_dirs[_name] = _path

        support_type = args[0] if args else ''
        while not support_type in _types and support_type != 'quit':
            print 'Supported types:\n'
            print '    ' + '\n    '.join(sorted(_types))
            print
            support_type = raw_input('Please enter support type[quit to exit]:')
        
        if support_type != 'quit':
            src_dir = support_dirs[support_type]
            copy_dir(src_dir, '.', verbose=global_options.verbose)
示例#8
0
    def handle(self, options, global_options, *args):
        from uliweb.utils.common import copy_dir_with_check

        self.get_application(global_options)

        if not args:
            print >> sys.stderr, "Error: outputdir should be a directory and existed"
            sys.exit(0)
        else:
            outputdir = os.path.abspath(args[0])
            if global_options.verbose:
                print "Export direcotry is %s ..." % outputdir

        if not args[1:]:
            apps = self.get_apps(global_options)
        else:
            apps = args[1:]
        dirs = [
            os.path.join(SimpleFrame.get_app_dir(appname), 'static')
            for appname in apps
        ]
        self.options = options
        self.global_options = global_options
        copy_dir_with_check(dirs,
                            outputdir,
                            False,
                            options.check,
                            processor=self.process_file)

        self.process_combine(outputdir, global_options.verbose)
示例#9
0
文件: manage.py 项目: dtld/uliweb
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import pkg
     from uliweb.utils.pyini import Ini
     from uliweb.core.commands import get_input
     from uliweb.core.template import template_file
     import glob
     
     _types = []
     config_files = {}
     app_dirs = [os.path.join(SimpleFrame.get_app_dir(appname), 'template_files/config') for appname in self.get_apps(global_options)]
     for path in [pkg.resource_filename('uliweb', 'template_files/config/')] + app_dirs:
         if os.path.exists(path):
             files = glob.glob(os.path.join(path, '*.conf'))
             if files:
                 for f in files:
                     _name = os.path.splitext(os.path.basename(f))[0]
                     _types.append(_name)
                     config_files[_name] = f
     
     support_type = args[0] if args else ''
     while not support_type in _types and support_type != 'quit':
         print 'Supported types:\n'
         print '    ' + '\n    '.join(sorted(_types))
         print
         support_type = raw_input('Please enter support type[quit to exit]:')
     
     if support_type != 'quit':
         conf_file = config_files[support_type]
         conf_ini = conf_file[:-5] + '.ini'
         
         if not os.path.exists(conf_file):
             log.error("%s config can't be found" % support_type)
             sys.exit(1)
             
         data = {}
         data['project_dir'] = os.path.abspath(os.getcwd())
         data['project'] = os.path.basename(data['project_dir'])
         if os.path.exists(conf_ini):
             x = Ini(conf_ini)
             for k, v in x.INPUT.items():
                 if isinstance(v, (tuple, list)):
                     if len(v) == 2:
                         prompt, default = v
                     else:
                         prompt = v[0]
                         default = ''
                 else:
                     prompt, default = v or '', ''
                 if not prompt.strip():
                     prompt = 'Please input %s[%s]:' % (k, default)
                 r = get_input(prompt, default=default)
                 data[k] = r
             data.update(x.get('DEFAULT', {}))
             
         print
         print template_file(conf_file, data)
示例#10
0
文件: manage.py 项目: hankji/uliweb
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import pkg
     from uliweb.utils.pyini import Ini
     from uliweb.core.commands import get_input
     from uliweb.core.template import template_file
     import glob
     
     _types = []
     config_files = {}
     app_dirs = [os.path.join(SimpleFrame.get_app_dir(appname), 'template_files/config') for appname in self.get_apps(global_options)]
     for path in [pkg.resource_filename('uliweb', 'template_files/config/')] + app_dirs:
         if os.path.exists(path):
             files = glob.glob(os.path.join(path, '*.conf'))
             if files:
                 for f in files:
                     _name = os.path.splitext(os.path.basename(f))[0]
                     _types.append(_name)
                     config_files[_name] = f
     
     support_type = args[0] if args else ''
     while not support_type in _types and support_type != 'quit':
         print 'Supported types:\n'
         print '    ' + '\n    '.join(sorted(_types))
         print
         support_type = raw_input('Please enter support type[quit to exit]:')
     
     if support_type != 'quit':
         conf_file = config_files[support_type]
         conf_ini = conf_file[:-5] + '.ini'
         
         if not os.path.exists(conf_file):
             log.error("%s config can't be found" % support_type)
             sys.exit(1)
             
         data = {}
         data['project_dir'] = os.path.abspath(os.getcwd())
         data['project'] = os.path.basename(data['project_dir'])
         if os.path.exists(conf_ini):
             x = Ini(conf_ini)
             for k, v in x.INPUT.items():
                 if isinstance(v, (tuple, list)):
                     if len(v) == 2:
                         prompt, default = v
                     else:
                         prompt = v[0]
                         default = ''
                 else:
                     prompt, default = v or '', ''
                 if not prompt.strip():
                     prompt = 'Please input %s[%s]:' % (k, default)
                 r = get_input(prompt, default=default)
                 data[k] = r
             data.update(x.get('DEFAULT', {}))
             
         print
         print template_file(conf_file, data)
示例#11
0
文件: manage.py 项目: 08haozi/uliweb
    def handle(self, options, global_options, *args):
        from uliweb.utils.common import pkg
        from uliweb.utils.pyini import Ini
        from uliweb.core.commands import get_input
        from uliweb.core.template import template_file
        import glob

        _types = []
        config_files = {}
        app_dirs = [
            os.path.join(SimpleFrame.get_app_dir(appname), "template_files/config")
            for appname in self.get_apps(global_options)
        ]
        for path in [pkg.resource_filename("uliweb", "template_files/config/")] + app_dirs:
            if os.path.exists(path):
                files = glob.glob(os.path.join(path, "*.conf"))
                if files:
                    for f in files:
                        _name = os.path.splitext(os.path.basename(f))[0]
                        _types.append(_name)
                        config_files[_name] = f

        support_type = args[0] if args else ""
        while not support_type in _types and support_type != "quit":
            print "Supported types:\n"
            print "    " + "\n    ".join(sorted(_types))
            print
            support_type = raw_input("Please enter support type[quit to exit]:")

        if support_type != "quit":
            conf_file = config_files[support_type]
            conf_ini = conf_file[:-5] + ".ini"

            if not os.path.exists(conf_file):
                log.error("%s config can't be found" % support_type)
                sys.exit(1)

            data = {}
            data["project_dir"] = os.path.abspath(os.getcwd())
            data["project"] = os.path.basename(data["project_dir"])
            if os.path.exists(conf_ini):
                x = Ini(conf_ini)
                for k, v in x.INPUT.items():
                    if isinstance(v, (tuple, list)):
                        prompt, default = v
                    else:
                        prompt, default = v or "", ""
                    if not prompt.strip():
                        prompt = "Please input %s[%s]:" % (k, default)
                    r = get_input(prompt, default=default)
                    data[k] = r
                data.update(x.get("DEFAULT", {}))

            print
            print template_file(conf_file, data)
示例#12
0
 def handle(self, options, global_options, *args):
     opts = {'verbose':global_options.verbose}
     if options.project:
         _process(global_options.project, options.locale, opts)
     elif options.apps or args:
         if options.apps:
             _apps = SimpleFrame.get_apps(global_options.apps_dir)
         else:
             _apps = args
         apps_dir = os.path.normpath(os.path.abspath(global_options.apps_dir))
         for appname in _apps:
             path = SimpleFrame.get_app_dir(appname)
             if not path.startswith(apps_dir):
                 continue
             _process(SimpleFrame.get_app_dir(appname), options.locale, opts)
     elif options.uliweb:
         path = pkg.resource_filename('uliweb', '')
         _process(path, options.locale, opts)
     elif options.directory:
         _process(options.directory, options.locale, opts)
示例#13
0
 def handle(self, options, global_options, *args):
     opts = {'verbose':global_options.verbose, 'template':options.template,
         'exact':options.exact}
     if options.project:
         _process(global_options.project, options.locale, opts)
     elif options.apps or args:
         if options.apps:
             _apps = SimpleFrame.get_apps(global_options.apps_dir)
         else:
             _apps = args
         apps_dir = os.path.normpath(os.path.abspath(global_options.apps_dir))
         for appname in _apps:
             path = SimpleFrame.get_app_dir(appname)
             if global_options.verbose:
                 print 'Processing... app=>[%s] path=>[%s]' % (appname, path)
             _process(path, options.locale, opts)
     elif options.uliweb:
         path = pkg.resource_filename('uliweb', '')
         _process(path, options.locale, opts)
     elif options.directory:
         _process(options.directory, options.locale, opts)
示例#14
0
 def make_shell_env(self, global_options):
     from uliweb import functions
     
     application = SimpleFrame.Dispatcher(project_dir=global_options.project, 
         settings_file=global_options.settings, 
         local_settings_file=global_options.local_settings, 
         start=False)
     
     if global_options.project not in sys.path:
         sys.path.insert(0, global_options.project)
     
     env = {'application':application, 'settings':application.settings, 'functions':functions}
     return env
示例#15
0
    def handle(self, options, global_options, *args):
        from uliweb.utils.common import copy_dir_with_check

        if not args:
            print >>sys.stderr, "Error: outputdir should be a directory and existed"
            sys.exit(0)
        else:
            outputdir = args[0]

        application = SimpleFrame.Dispatcher(project_dir=global_options.project, start=False)
        apps = application.apps
        dirs = [os.path.join(SimpleFrame.get_app_dir(appname), 'static') for appname in apps]
        self.options = options
        self.global_options = global_options
        copy_dir_with_check(dirs, outputdir, global_options.verbose, options.check, processor=self.process_file)
示例#16
0
文件: manage.py 项目: bobgao/uliweb
    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)
示例#17
0
    def handle(self, options, global_options, *args):
        from uliweb.utils.common import copy_dir_with_check

        if not args:
            print >> sys.stderr, "Error: outputdir should be a directory and existed"
            sys.exit(0)
        else:
            outputdir = args[0]

        if not args[1:]:
            apps = self.get_apps(global_options)
        else:
            apps = args[1:]
        dirs = [os.path.join(SimpleFrame.get_app_dir(appname), "static") for appname in apps]
        self.options = options
        self.global_options = global_options
        copy_dir_with_check(dirs, outputdir, False, options.check, processor=self.process_file)
示例#18
0
def develop_build():
    from uliweb.utils.common import pkg

    import uliweb.core.SimpleFrame as sf
    app_apps = sf.get_apps(application.apps_dir)

    contrib_path = pkg.resource_filename('uliweb.contrib', '')
    apps_dirs = [(application.apps_dir, ''), (contrib_path, 'uliweb.contrib')]

    #using entry point to find installed apps
    try:
        from pkg_resources import iter_entry_points
    except:
        iter_entry_points = None
    if iter_entry_points:
        #process apps group
        for p in iter_entry_points('uliweb_apps'):
            apps_dirs.append((os.path.join(p.dist.location,
                                           p.module_name), p.module_name))

    catalogs, apps = get_apps(application, apps_dirs, app_apps)

    if iter_entry_points:
        #proces single app
        for p in iter_entry_points('uliweb_app'):
            _get_app(os.path.join(p.dist.location, p.module_name),
                     p.module_name, apps, catalogs, app_apps)

    from forms import GenericForm

    f = GenericForm(method="post")

    if request.method == 'GET':
        #        ini = Ini(os.path.join(application.apps_dir, 'settings.ini'))
        ini_to_form(f, application.settings)

    else:
        r = f.validate(request.params)
        if r:
            ini = Ini(os.path.join(application.apps_dir, 'settings.ini'))
            flag = form_to_ini(f, ini, application.settings)
            if flag:
                ini.save()

    return {'catalogs': catalogs, 'generic_form': f}
示例#19
0
def develop_build():
    from uliweb.utils.common import pkg
    
    import uliweb.core.SimpleFrame as sf
    app_apps = sf.get_apps(application.apps_dir)
    
    contrib_path = pkg.resource_filename('uliweb.contrib', '')
    apps_dirs = [(application.apps_dir, ''), (contrib_path, 'uliweb.contrib')]
    
    #using entry point to find installed apps
    try:
        from pkg_resources import iter_entry_points
    except:
        iter_entry_points = None
    if iter_entry_points:
        #process apps group
        for p in iter_entry_points('uliweb_apps'):
            apps_dirs.append((os.path.join(p.dist.location, p.module_name), p.module_name))
            
    catalogs, apps = get_apps(application, apps_dirs, app_apps)
    
    if iter_entry_points:
        #proces single app
        for p in iter_entry_points('uliweb_app'):
            _get_app(os.path.join(p.dist.location, p.module_name), p.module_name, apps, catalogs, app_apps)
    
    from forms import GenericForm
    
    f = GenericForm(method="post")
    
    if request.method == 'GET':
#        ini = Ini(os.path.join(application.apps_dir, 'settings.ini'))
        ini_to_form(f, application.settings)
        
    else:
        r = f.validate(request.params)
        if r:
            ini = Ini(os.path.join(application.apps_dir, 'settings.ini'))
            flag = form_to_ini(f, ini, application.settings)
            if flag:
                ini.save()
        
    return {'catalogs':catalogs, 'generic_form':f}
示例#20
0
文件: manage.py 项目: chifeng/uliweb
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import copy_dir_with_check
     
     self.get_application(global_options)
     
     if not args:
         print >>sys.stderr, "Error: outputdir should be a directory and existed"
         sys.exit(0)
     else:
         outputdir = os.path.abspath(args[0])
         if global_options.verbose:
             print "Export direcotry is %s ..." % outputdir
             
     if not args[1:]:
         apps = self.get_apps(global_options)
     else:
         apps = args[1:]
     dirs = [os.path.join(SimpleFrame.get_app_dir(appname), 'static') for appname in apps]
     self.options = options
     self.global_options = global_options
     copy_dir_with_check(dirs, outputdir, False, options.check, processor=self.process_file)
     
     self.process_combine(outputdir, global_options.verbose)
示例#21
0
def develop_edit_app():
    ini = Ini(os.path.join(application.apps_dir, 'settings.ini'))
    flag = False
    module = str(request.GET['module'])
    
    import uliweb.core.SimpleFrame as sf
    app_apps = sf.get_apps(application.apps_dir)
    
    if request.GET['action'] == 'add':
        if not ini.GLOBAL.get('INSTALLED_APPS'):
            ini.GLOBAL.INSTALLED_APPS = app_apps
        if module not in ini.GLOBAL.INSTALLED_APPS:
            ini.GLOBAL.INSTALLED_APPS.append(module)
            flag = True
    else:
        if not ini.GLOBAL.get('INSTALLED_APPS'):
            ini.GLOBAL.INSTALLED_APPS = app_apps
        if module in ini.GLOBAL.INSTALLED_APPS:
            ini.GLOBAL.INSTALLED_APPS.remove(module)
            flag = True
    
    if flag:
        ini.save()
    return 'ok'
示例#22
0
def develop_edit_app():
    ini = Ini(os.path.join(application.apps_dir, 'settings.ini'))
    flag = False
    module = str(request.GET['module'])

    import uliweb.core.SimpleFrame as sf
    app_apps = sf.get_apps(application.apps_dir)

    if request.GET['action'] == 'add':
        if not ini.GLOBAL.get('INSTALLED_APPS'):
            ini.GLOBAL.INSTALLED_APPS = app_apps
        if module not in ini.GLOBAL.INSTALLED_APPS:
            ini.GLOBAL.INSTALLED_APPS.append(module)
            flag = True
    else:
        if not ini.GLOBAL.get('INSTALLED_APPS'):
            ini.GLOBAL.INSTALLED_APPS = app_apps
        if module in ini.GLOBAL.INSTALLED_APPS:
            ini.GLOBAL.INSTALLED_APPS.remove(module)
            flag = True

    if flag:
        ini.save()
    return 'ok'