Ejemplo n.º 1
0
    def handle(self, options, global_options, *args):
        from uliweb.utils.common import extract_dirs
        from uliweb.core.template import template_file

        if not args:
            project_name = ""
            while not project_name:
                project_name = raw_input("Please enter project name:")
        else:
            project_name = args[0]

        ans = "-1"
        if os.path.exists(project_name):
            if options.force:
                ans = "y"
            while ans not in ("y", "n"):
                ans = raw_input("The project directory has been existed, do you want to overwrite it?(y/n)[n]")
                if not ans:
                    ans = "n"
        else:
            ans = "y"
        if ans == "y":
            extract_dirs("uliweb", "template_files/project", project_name, verbose=global_options.verbose)
            # template setup.py
            setup_file = os.path.join(project_name, "setup.py")
            text = template_file(setup_file, {"project_name": project_name})
            with open(setup_file, "w") as f:
                f.write(text)
            # rename .gitignore.template to .gitignore
            os.rename(os.path.join(project_name, ".gitignore.template"), os.path.join(project_name, ".gitignore"))
Ejemplo n.º 2
0
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import extract_dirs
     
     if not options.outputdir:
         print >>sys.stderr, "Error: please give the output directory with '-d outputdir' argument"
         sys.exit(0)
     else:
         outputdir = options.outputdir
 
     if not args:
         apps = self.get_apps(global_options)
     else:
         apps = args
     if not os.path.exists(outputdir):
         os.makedirs(outputdir)
     for app in apps:
         dirs = app.split('.')
         mod = []
         dest = outputdir
         for m in dirs:
             mod.append(m)
             dest = os.path.join(dest, m)
             module = '.'.join(mod)
             if global_options.verbose:
                 print 'Export %s to %s ...' % (module, dest)
             if module == app:
                 recursion = True
             else:
                 recursion = False
             extract_dirs(module, '', dest, verbose=global_options.verbose, recursion=recursion)
Ejemplo n.º 3
0
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import extract_dirs
     from uliweb.core.template import template_file
     
     if not args:
         project_name = ''
         while not project_name:
             project_name = raw_input('Please enter project name:')
     else:
         project_name = args[0]
     
     ans = '-1'
     if os.path.exists(project_name):
         if options.force:
             ans = 'y'
         while ans not in ('y', 'n'):
             ans = raw_input('The project directory has been existed, do you want to overwrite it?(y/n)[n]')
             if not ans:
                 ans = 'n'
     else:
         ans = 'y'
     if ans == 'y':
         extract_dirs('uliweb', 'template_files/project', project_name, verbose=global_options.verbose)
         #template setup.py
         setup_file = os.path.join(project_name, 'setup.py')
         text = template_file(setup_file, {'project_name':project_name})
         with open(setup_file, 'w') as f:
             f.write(text)
         #rename .gitignore.template to .gitignore
         os.rename(os.path.join(project_name, '.gitignore.template'), os.path.join(project_name, '.gitignore'))
Ejemplo n.º 4
0
 def handle(self, options, global_options, *args):
     if not args:
         appname = ''
         while not appname:
             appname = raw_input('Please enter app name:')
     else:
         appname = args[0]
     
     ans = '-1'
     app_path = appname.replace('.', '//')
     if os.path.exists('apps'):
         path = os.path.join('apps', app_path)
     else:
         path = app_path
     
     if os.path.exists(path):
         if options.force:
             ans = 'y'
         while ans not in ('y', 'n'):
             ans = raw_input('The app directory has been existed, do you want to overwrite it?(y/n)[n]')
             if not ans:
                 ans = 'n'
     else:
         ans = 'y'
     if ans == 'y':
         from uliweb.utils.common import extract_dirs
         extract_dirs('uliweb', 'template_files/app', path, verbose=global_options.verbose)
Ejemplo n.º 5
0
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import extract_dirs
     from uliweb.core.template import template_file
     from uliweb.manage import make_simple_application
     from uliweb import settings
     from sqlalchemy import create_engine, MetaData, Table
     from shutil import rmtree
     from uliweb.orm import get_connection, engine_manager
     
     alembic_path = os.path.join(global_options.project, 'alembic', options.engine).replace('\\', '/')
     #delete alembic path
     if os.path.exists(alembic_path):
         rmtree(alembic_path, True)
     extract_dirs('uliweb.contrib.orm', 'templates/alembic', alembic_path, 
         verbose=global_options.verbose, replace=True)
     make_simple_application(project_dir=global_options.project,
         settings_file=global_options.settings,
         local_settings_file=global_options.local_settings)
     ini_file = os.path.join(alembic_path, 'alembic.ini')
     text = template_file(ini_file, 
         {'connection':engine_manager[options.engine].options.connection_string, 
         'engine_name':options.engine,
         'script_location':alembic_path})
     
     with open(ini_file, 'w') as f:
         f.write(text)
         
     #drop old alembic_version table
     db = get_connection(engine_name=options.engine)
     metadata = MetaData(db)
     if db.dialect.has_table(db.connect(), 'alembic_version'):
         version = Table('alembic_version', metadata, autoload=True) 
         version.drop()
Ejemplo n.º 6
0
 def handle(self, options, global_options, *args):
     if not args:
         appname = ''
         while not appname:
             appname = raw_input('Please enter app name:')
     else:
         appname = args[0]
     
     ans = '-1'
     app_path = appname.replace('.', '//')
     if os.path.exists('apps'):
         path = os.path.join('apps', app_path)
     else:
         path = app_path
     
     if os.path.exists(path):
         if options.force:
             ans = 'y'
         while ans not in ('y', 'n'):
             ans = raw_input('The app directory has been existed, do you want to overwrite it?(y/n)[n]')
             if not ans:
                 ans = 'n'
     else:
         ans = 'y'
     if ans == 'y':
         from uliweb.utils.common import extract_dirs
         extract_dirs('uliweb', 'template_files/app', path, verbose=global_options.verbose)
Ejemplo n.º 7
0
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import extract_dirs
     
     if not options.outputdir:
         print >>sys.stderr, "Error: please give the output directory with '-d outputdir' argument"
         sys.exit(0)
     else:
         outputdir = options.outputdir
 
     if not args:
         apps = self.get_apps(global_options)
     else:
         apps = args
     if not os.path.exists(outputdir):
         os.makedirs(outputdir)
     for app in apps:
         dirs = app.split('.')
         mod = []
         dest = outputdir
         for m in dirs:
             mod.append(m)
             dest = os.path.join(dest, m)
             module = '.'.join(mod)
             if global_options.verbose:
                 print 'Export %s to %s ...' % (module, dest)
             if module == app:
                 recursion = True
             else:
                 recursion = False
             extract_dirs(module, '', dest, verbose=global_options.verbose, recursion=recursion)
Ejemplo n.º 8
0
    def handle(self, options, global_options, *args):
        if not args:
            appname = ""
            while not appname:
                appname = raw_input("Please enter app name:")
        else:
            appname = args[0]

        ans = "-1"
        app_path = appname.replace(".", "//")
        if os.path.exists("apps"):
            path = os.path.join("apps", app_path)
        else:
            path = app_path

        if os.path.exists(path):
            while ans not in ("y", "n"):
                ans = raw_input("The app directory has been existed, do you want to overwrite it?(y/n)[n]")
                if not ans:
                    ans = "n"
        else:
            ans = "y"
        if ans == "y":
            from uliweb.utils.common import extract_dirs

            extract_dirs("uliweb", "template_files/app", path, verbose=global_options.verbose)
Ejemplo n.º 9
0
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import extract_dirs
     from uliweb.core.template import template_file
     from uliweb.manage import make_simple_application
     from uliweb import settings
     from sqlalchemy import create_engine, MetaData, Table
     from shutil import rmtree
     from uliweb.orm import get_connection, engine_manager
     
     alembic_path = os.path.join(global_options.project, 'alembic', options.engine).replace('\\', '/')
     #delete alembic path
     if os.path.exists(alembic_path):
         rmtree(alembic_path, True)
     extract_dirs('uliweb.contrib.orm', 'templates/alembic', alembic_path, 
         verbose=global_options.verbose, replace=True)
     make_simple_application(project_dir=global_options.project,
         settings_file=global_options.settings,
         local_settings_file=global_options.local_settings)
     ini_file = os.path.join(alembic_path, 'alembic.ini')
     text = template_file(ini_file, 
         {'connection':engine_manager[options.engine].options.connection_string, 
         'engine_name':options.engine,
         'script_location':alembic_path})
     
     with open(ini_file, 'w') as f:
         f.write(text)
         
     #drop old alembic_version table
     db = get_connection(options.engine)
     metadata = MetaData(db)
     if db.dialect.has_table(db.connect(), 'alembic_version'):
         version = Table('alembic_version', metadata, autoload=True) 
         version.drop()
Ejemplo n.º 10
0
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import extract_dirs
     from uliweb.core.template import template_file
     
     if not args:
         project_name = ''
         while not project_name:
             project_name = raw_input('Please enter project name:')
     else:
         project_name = args[0]
     
     ans = '-1'
     if os.path.exists(project_name):
         if options.force:
             ans = 'y'
         while ans not in ('y', 'n'):
             ans = raw_input('The project directory has been existed, do you want to overwrite it?(y/n)[n]')
             if not ans:
                 ans = 'n'
     else:
         ans = 'y'
     if ans == 'y':
         extract_dirs('uliweb', 'template_files/project', project_name, verbose=global_options.verbose)
         #template setup.py
         setup_file = os.path.join(project_name, 'setup.py')
         text = template_file(setup_file, {'project_name':project_name})
         with open(setup_file, 'w') as f:
             f.write(text)
         #rename .gitignore.template to .gitignore
         os.rename(os.path.join(project_name, '.gitignore.template'), os.path.join(project_name, '.gitignore'))
Ejemplo n.º 11
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)
Ejemplo n.º 12
0
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import extract_dirs, pkg
     from uliweb.core.template import template_file
     
     extract_dirs('uliweb.contrib.orm', 'templates/alembic', '.', verbose=global_options.verbose, replace=False)
     engine_string = get_engine(options, global_options)
     ini_file = os.path.join(pkg.resource_filename('uliweb.contrib.orm', 'templates/alembic/alembic.ini'))
     text = template_file(ini_file, {'CONNECTION':engine_string})
     with open(os.path.join(global_options.project, 'alembic.ini'), 'w') as f:
         f.write(text)
Ejemplo n.º 13
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)
Ejemplo n.º 14
0
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import extract_dirs
     
     _types = ['gae', 'dotcloud', 'sae', 'bae', 'heroku']
     if not args:
         support_type = ''
         while not support_type in _types:
             support_type = raw_input('Please enter support type[%s]:' % '/'.join(_types))
     else:
         support_type = args[0]
     
     extract_dirs('uliweb', 'template_files/support/%s' % support_type, '.', verbose=global_options.verbose)
Ejemplo n.º 15
0
    def handle(self, options, global_options, *args):
        from uliweb.utils.common import extract_dirs

        _types = ["gae", "dotcloud"]
        if not args:
            support_type = ""
            while not support_type in _types:
                support_type = raw_input("Please enter support type[gae/dotcloud]:")
        else:
            support_type = args[0]

        extract_dirs("uliweb", "template_files/support/%s" % support_type, ".", verbose=global_options.verbose)
Ejemplo n.º 16
0
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import extract_dirs
     
     _types = ['gae', 'dotcloud', 'sae', 'bae', 'heroku']
     if not args:
         support_type = ''
         while not support_type in _types:
             support_type = raw_input('Please enter support type[%s]:' % '/'.join(_types))
     else:
         support_type = args[0]
     
     extract_dirs('uliweb', 'template_files/support/%s' % support_type, '.', verbose=global_options.verbose)
Ejemplo n.º 17
0
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import extract_dirs
     
     _types = ['gae', 'dotcloud', 'sae', 'bae', 'fcgi', 'heroku', 'tornado', 'gevent', 'gevent-socketio']
     support_type = args[0] if args else ''
     while not support_type in _types and support_type != 'quit':
         print 'Supported types:\n'
         print '    ' + '\n    '.join(_types)
         print
         support_type = raw_input('Please enter support type[quit to exit]:')
     
     if support_type != 'quit':
         extract_dirs('uliweb', 'template_files/support/%s' % support_type, '.', verbose=global_options.verbose)
Ejemplo n.º 18
0
    def handle(self, options, global_options, *args):
        from uliweb.utils.common import extract_dirs

        if not args:
            project_name = ""
            while not project_name:
                project_name = raw_input("Please enter project name:")
        else:
            project_name = args[0]

        ans = "-1"
        if os.path.exists(project_name):
            while ans not in ("y", "n"):
                ans = raw_input("The project directory has been existed, do you want to overwrite it?(y/n)[n]")
                if not ans:
                    ans = "n"
        else:
            ans = "y"
        if ans == "y":
            extract_dirs("uliweb", "template_files/project", project_name, verbose=global_options.verbose)
Ejemplo n.º 19
0
 def handle(self, options, global_options, *args):
     from uliweb.utils.common import extract_dirs
     
     if not args:
         project_name = ''
         while not project_name:
             project_name = raw_input('Please enter project name:')
     else:
         project_name = args[0]
     
     ans = '-1'
     if os.path.exists(project_name):
         while ans not in ('y', 'n'):
             ans = raw_input('The project directory has been existed, do you want to overwrite it?(y/n)[n]')
             if not ans:
                 ans = 'n'
     else:
         ans = 'y'
     if ans == 'y':
         extract_dirs('uliweb', 'template_files/project', project_name, verbose=global_options.verbose)