コード例 #1
0
ファイル: setup.py プロジェクト: adibossiseu/goliat
    def check_evoque_qpy():
        try:
            import evoque
        except ImportError:
            prompt='Goliat uses evoque as template engine.\n\n'+\
            'Would you like to install evoque now?'
            if userquery(prompt)=="Yes":

                currdir=os.getcwd()
                os.chdir('evoque-0.4')
                from subprocess import Popen, PIPE
                p=Popen('python2.6 setup.py {0}'.format(args[0]).split(' '), stdout=PIPE, stderr=PIPE)
                print '\n{0}ing Goliat Evoque\n'.format(args[0].capitalize())
                ret=p.communicate()
                if len(ret[1]):
                    print ret[1]
                    print '\nQuitting.'
                    sys.exit(1)
                print ret[0]
                print '\nContinue.\n'
                os.chdir(currdir)
                #from setuptools.command.easy_install import main
                #main(['evoque'])
                #print '\nContinue.\n'
        try:
            import qpy
        except ImportError:
            prompt='Goliat uses qpy with evoque.\n\n'+\
            'Would you like to install qpy now?'
            if userquery(prompt)=="Yes":
                from setuptools.command.easy_install import main
                main(['qpy'])
                print '\nContinue.\n'
コード例 #2
0
    def perform(self, args):
        (app_name, opts) = self.parse_args(args)

        if app_name != '':
            if app_name == 'project':
                print self.long_help()
                sys.exit(1)
            else:
                opts['app_name'] = app_name
                opts['app_file'] = app_name.lower().replace(' ', '_') + '.tac'
            print bold('\nYou are going to create a new Goliat Project on {0}'\
                ' with this options:\n'.format(os.path.abspath(os.getcwd())))
            for k, v in opts.iteritems():
                if k != 'verbose':
                    print brown(k.ljust(12))+' :'+green('( ')+\
                    v.decode('utf8')+green(' )')
            if 'verbose' in opts:
                print brown('vebosity'.ljust(12))+' :'+green('( ')+\
                'yes'+green(' )')
            else:
                print brown('vebosity'.ljust(12))+' :'+green('( ')+\
                'no'+green(' )')
            if userquery("Would you like to create this project?") == "No":
                print '\nQuitting.'
                sys.exit(0)
            else:
                return self._create_project(opts)
        else:
            print self.long_help()
            sys.exit(-1)
コード例 #3
0
ファイル: project.py プロジェクト: DamnWidget/goliat
    def perform(self, args):
        (app_name, opts)=self.parse_args(args)

        if app_name!='':
            if app_name=='project':
                print self.long_help()
                sys.exit(1)
            else:
                opts['app_name']=app_name
                opts['app_file']=app_name.lower().replace(' ', '_')+'.tac'
            print bold('\nYou are going to create a new Goliat Project on {0}'\
                ' with this options:\n'.format(os.path.abspath(os.getcwd())))
            for k, v in opts.iteritems():
                if k!='verbose':
                    print brown(k.ljust(12))+' :'+green('( ')+\
                    v.decode('utf8')+green(' )')
            if 'verbose' in opts:
                print brown('vebosity'.ljust(12))+' :'+green('( ')+\
                'yes'+green(' )')
            else:
                print brown('vebosity'.ljust(12))+' :'+green('( ')+\
                'no'+green(' )')
            if userquery("Would you like to create this project?")=="No":
                print '\nQuitting.'
                sys.exit(0)
            else:
                return self._create_project(opts)
        else:
            print self.long_help()
            sys.exit(-1)
コード例 #4
0
ファイル: setup.py プロジェクト: adibossiseu/goliat
 def check_storm_twisted():
     try:
         import storm.twisted
     except ImportError:
         prompt='Storm Twisted branch is required to use the deferred stores from Storm ORM\n'+\
         'Goliat can work with the regular Storm libraries but using the Twisted branch (at this\n'+\
         'moment waiting for merge to the official branch) should offer a high performance.\n'+\
         'NOTE: You need the Bazaar bzrlibs installed in your system to get the branch.\n\n'+\
         'Would you like to install the twisted branch from storm bazaar repository? (recommended)'
         if userquery(prompt)=="Yes":
             try:
                 from bzrlib import bzrdir, errors
                 accelerator_tree, source=bzrdir.BzrDir.open_tree_or_branch('http://bazaar.launchpad.net/~therve/storm/twisted-integration')
                 try:
                     print 'The installation script is donwloading the Bazaar repository...'
                     source.create_checkout('./twisted-storm', None, True, accelerator_tree)
                 except errors.FileExists:
                     pass
                 currdir=os.getcwd()
                 os.chdir('twisted-storm')
                 from subprocess import Popen, PIPE
                 p=Popen('python2.6 setup.py {0}'.format(args[0]).split(' '), stdout=PIPE, stderr=PIPE)
                 print '\n{0}ing Storm with twisted-integration\n'.format(args[0].capitalize())
                 ret=p.communicate()
                 if len(ret[1]):
                     print ret[1]
                     print '\nQuitting.'
                     sys.exit(1)
                 print ret[0]
                 print '\nContinue.\n'
                 os.chdir(currdir)
             except ImportError:
                 prompt='You answered \'Yes\' previosly but the bzrlib is not present in your system.\n'+\
                 'This script needs Bazaar Bzrlib to get the twisted-storm branch from the launchpad brazaar'+\
                 'repository.\n\n'+\
                 'Would you like return to the system and install he Brzlibs with your package manager?'
                 if userquery(prompt)=="Yes":
                     sys.exit(1)
                 print 'The twisted support will not be available in your Goliat Resource objects...\n\n'
コード例 #5
0
ファイル: database.py プロジェクト: adibossiseu/goliat
    def perform(self, args):
        opts = self.parse_args(args)
        if userquery('ATENTION: This command will delete any project tables at'\
                   ' database server.\nWould you like yo continue?')=='no':
            print '\nQuitting.'
            sys.exit(1)
        print '\n' + bold('Creating tables...')
        gen = Generator(opts['verbose'])
        gen.generate_database()
        tables = gen.get_database()
        db = Database()
        db.connect()

        for table in tables:
            if opts['verbose']:
                print bold('Creating table {0}...'.format(table['name']))
            db.create(table['script'])

        print bold('Database created successfully.')
コード例 #6
0
ファイル: database.py プロジェクト: DamnWidget/goliat
    def perform(self, args):
        opts=self.parse_args(args)
        if userquery('ATENTION: This command will delete any project tables at'\
                   ' database server.\nWould you like yo continue?')=='no':
            print '\nQuitting.'
            sys.exit(1)
        print '\n'+bold('Creating tables...')
        gen=Generator(opts['verbose'])
        gen.generate_database()
        tables=gen.get_database()
        db=Database()
        db.connect()

        for table in tables:
            if opts['verbose']:
                print bold('Creating table {0}...'.format(table['name']))
            db.create(table['script'])

        print bold('Database created successfully.')
コード例 #7
0
    def _config_project(self, project, cfg, opts):
        project_file = cfg.get_config(project)['file']
        try:
            current = cfg.get_config(project)['Project']
            self._default_opts = Apply(self._default_opts, current)
        except KeyError:
            print red('{0} seems to ve an invalid Goliat Project file, ' \
                'missing \'Project\' section on file.'.format(project_file))
            sys.exit(0)

        # Application Connection Port
        label='Would you like to change the application port? (Current: {0})' \
            .format(self._default_opts['app_port'])
        input_label = 'Input the application port. (> 1024)'
        if userquery(label) == "Yes":
            current['app_port'] = userinput(input_label)
        else:
            current['app_port'] = self._default_opts['app_port']
        # Application Layout
        label='Would you like to change your application layout? ' \
            '(Current: {0})'.format(_layouts[current['app_layout']])
        if userquery(label) == "Yes":
            current['app_layout']=\
            userchoice('Available Layouts', _layouts.keys(), _layouts.values())
        # Orbited
        label="Would you like to use Orbited COMET services on your project?" \
        " (Current: {0})".format(
            'Yes' if self._default_opts['orbited'] else 'No')
        current['orbited'] = True if userquery(label) == "Yes" else False
        # Twisted on Storm
        label="Would you like to use Twisted on Storm ORM? (Current: {0})" \
            .format('Yes' if self._default_opts['tos'] else 'No')
        current['tos'] = True if userquery(label) == "Yes" else False
        # JavaScript Debug or Minified files
        label="Would you like to use ExtJS and GoliatJS Debug files? " \
        "(Current: {0})".format('Yes' if self._default_opts['debug'] else 'No')
        current['debug'] = True if userquery(label) == "Yes" else False
        # DocType
        label='Would you like to change your application DOCTYPE? ' \
        '(Current: {0})'.format(self._default_opts['doctype'])
        if userquery(label) == "Yes":
            current['doctype'] = userchoice('Available DocTypes',
                                            _docTypes.keys(),
                                            _docTypes.values())
        else:
            current['doctype'] = self._default_opts['doctype']
        # Meta Keys
        current['meta_keys']=\
        userinput('Input a list of keywords separated by comma.') \
        if userquery('Would you like to change your application Meta Keywords?'\
            ' (Current: {0})'.format(
                    self._default_opts['meta_keys']))=="Yes" \
        else self._default_opts['meta_keys']
        # Meta Description
        current['meta_description']=\
        userinput('Write the meta description.') \
        if userquery('Would you like to change your application Meta ' \
            'Description? (Current: {0})'.format(
                    self._default_opts['meta_description']))=="Yes" \
        else ''
        # Language
        if userquery('Would you like to change your application language? ' \
            '(Current: {0}'.format(
                _languages[self._default_opts['language']] \
            if self._default_opts['language'] \
            else _languages[os.environ['LANG'].split('_')[0]]))=="Yes":
            current['language']=\
            userchoice(
                'Available Languages', _languages.keys(), _languages.values())
        else:
            current['language']=\
            self._default_opts['language'] \
            if self._default_opts['language'] \
            else os.environ['LANG'].split('_')[0]
        # ExtJS Theme
        current['ext_theme']=\
        userinput('Input the ExtJS theme name.') \
        if userquery('Would you like to change the ExtJS theme? (Current: {0})'
            .format(self._default_opts['ext_theme']))=="Yes" \
        else self._default_opts['ext_theme']
        # GoliatJS Theme
        current['goliat_theme']=\
        userinput('Input the Goliat theme name.') \
        if userquery('Would you like to change the Goliat theme? (Current: {0})'
            .format(self._default_opts['goliat_theme']))=="Yes" \
        else self._default_opts['goliat_theme']

        # Summary
        print bold('\nThose are your options:')
        for k, v in current.iteritems():
            print brown(k.ljust(20)) + ': ' + green('( ') + str(v).decode(
                'utf8') + green(' )')

        if userquery('Would you like to write the Project File and perform ' \
            'the needed changes to the application templates?')=="Yes":
            self._write_config(project)
        else:
            print '\nQuitting.'
            sys.exit(0)
コード例 #8
0
    def _write_project_files(self, pr):
        project_dir = pr.get_name().lower().replace(' ', '_')
        try:
            # Create project directory
            if pr._verbose:
                print bold(
                    'Creating {0} project dir.'.format(os.getcwd() + '/' +
                                                       project_dir))
            if os.path.exists(os.getcwd() + '/' + project_dir):
                from shutil import rmtree
                print red('\nSeems like already exists a project named {0} '\
                    'on your current path.'.format(os.getcwd()+'/'+project_dir))
                if userquery("Would you like to rename it? "\
                             "(Ctrl+c to abort)")=="Yes":
                    from random import randrange
                    rnd = str(randrange(1, 10000))
                    os.rename(os.getcwd()+'/'+project_dir, os.getcwd()+'/'+\
                        project_dir+rnd)
                    print turquoise('The old directory was saved as '\
                        '{0}.'.format(os.getcwd()+'/'+project_dir+rnd))
                else:
                    rmtree(os.getcwd() + '/' + project_dir)

            os.mkdir(os.getcwd() + '/' + project_dir)
            # Cd to the new created directory
            if pr._verbose:
                print bold('Entering {0} dir.'.format(os.getcwd()+\
                '/'+project_dir))
            os.chdir(project_dir)

            # Write tac_file template
            if pr._verbose:
                print bold('Writing {0} Twisted tac file.'.format(
                    pr.get_name()))
            self._create_tac_file(pr)
            if pr.verbose:
                print bold('Creating config directory.\nWriting schema file.')
            self._create_config_directory(pr)

            # Create application needed directories
            if pr._verbose:
                print bold('Creating application directory.\n' \
                    'Creating model directory.\nCreating controller ' \
                    'directory.\nCreating view directory.')
            self._create_application_directory()
            self._create_model_directories()
            self._create_controller_directory()
            self._create_view_directory()
            if pr._verbose:
                print bold('Creating web directory.\n' \
                    'Creating web/js directory.\n' \
                    'Creating web/media directory\n.' \
                    'Creating web/css directory.\n' \
                    'Creating services directory.' \
                    'Writing web/js/main.js UI file.'
                )
            self._create_web_directories(pr)
            self._create_services_directory()

            # Write the project config file
            if pr._verbose:
                print bold('Writing {0} project file.'.format(
                    pr.get_name().lower().replace(' ', '_') + '.cfg'))
            self._create_config_file(pr)

            print bold('Project Generated!')
            self._configure(pr)
        except OSError, e:
            print red(str(e))
            sys.exit(-1)
コード例 #9
0
ファイル: project.py プロジェクト: DamnWidget/goliat
    def _config_project(self, project, cfg, opts):
        project_file=cfg.get_config(project)['file']
        try:
            current=cfg.get_config(project)['Project']
            self._default_opts=Apply(self._default_opts, current)
        except KeyError:
            print red('{0} seems to ve an invalid Goliat Project file, ' \
                'missing \'Project\' section on file.'.format(project_file))
            sys.exit(0)

        # Application Connection Port        
        label='Would you like to change the application port? (Current: {0})' \
            .format(self._default_opts['app_port'])
        input_label='Input the application port. (> 1024)'
        if userquery(label)=="Yes":
            current['app_port']=userinput(input_label)
        else:
            current['app_port']=self._default_opts['app_port']
        # Application Layout
        label='Would you like to change your application layout? ' \
            '(Current: {0})'.format(_layouts[current['app_layout']])
        if userquery(label)=="Yes":
            current['app_layout']=\
            userchoice('Available Layouts', _layouts.keys(), _layouts.values())
        # Orbited
        label="Would you like to use Orbited COMET services on your project?" \
        " (Current: {0})".format(
            'Yes' if self._default_opts['orbited'] else 'No')
        current['orbited']=True if userquery(label)=="Yes" else False
        # Twisted on Storm
        label="Would you like to use Twisted on Storm ORM? (Current: {0})" \
            .format('Yes' if self._default_opts['tos'] else 'No')
        current['tos']=True if userquery(label)=="Yes" else False
        # JavaScript Debug or Minified files
        label="Would you like to use ExtJS and GoliatJS Debug files? " \
        "(Current: {0})".format('Yes' if self._default_opts['debug'] else 'No')
        current['debug']=True if userquery(label)=="Yes" else False
        # DocType
        label='Would you like to change your application DOCTYPE? ' \
        '(Current: {0})'.format(self._default_opts['doctype'])
        if userquery(label)=="Yes":
            current['doctype']=userchoice(
                'Available DocTypes', _docTypes.keys(), _docTypes.values())
        else:
            current['doctype']=self._default_opts['doctype']
        # Meta Keys
        current['meta_keys']=\
        userinput('Input a list of keywords separated by comma.') \
        if userquery('Would you like to change your application Meta Keywords?'\
            ' (Current: {0})'.format(
                    self._default_opts['meta_keys']))=="Yes" \
        else self._default_opts['meta_keys']
        # Meta Description
        current['meta_description']=\
        userinput('Write the meta description.') \
        if userquery('Would you like to change your application Meta ' \
            'Description? (Current: {0})'.format(
                    self._default_opts['meta_description']))=="Yes" \
        else ''
        # Language
        if userquery('Would you like to change your application language? ' \
            '(Current: {0}'.format(
                _languages[self._default_opts['language']] \
            if self._default_opts['language'] \
            else _languages[os.environ['LANG'].split('_')[0]]))=="Yes":
            current['language']=\
            userchoice(
                'Available Languages', _languages.keys(), _languages.values())
        else:
            current['language']=\
            self._default_opts['language'] \
            if self._default_opts['language'] \
            else os.environ['LANG'].split('_')[0]
        # ExtJS Theme
        current['ext_theme']=\
        userinput('Input the ExtJS theme name.') \
        if userquery('Would you like to change the ExtJS theme? (Current: {0})'
            .format(self._default_opts['ext_theme']))=="Yes" \
        else self._default_opts['ext_theme']
        # GoliatJS Theme
        current['goliat_theme']=\
        userinput('Input the Goliat theme name.') \
        if userquery('Would you like to change the Goliat theme? (Current: {0})'
            .format(self._default_opts['goliat_theme']))=="Yes" \
        else self._default_opts['goliat_theme']

        # Summary
        print bold('\nThose are your options:')
        for k, v in current.iteritems():
            print brown(k.ljust(20))+': '+green('( ')+str(v).decode('utf8')+green(' )')

        if userquery('Would you like to write the Project File and perform ' \
            'the needed changes to the application templates?')=="Yes":
            self._write_config(project)
        else:
            print '\nQuitting.'
            sys.exit(0)
コード例 #10
0
ファイル: project.py プロジェクト: DamnWidget/goliat
    def _write_project_files(self, pr):
        project_dir=pr.get_name().lower().replace(' ', '_')
        try:
            # Create project directory
            if pr._verbose: print bold('Creating {0} project dir.'.format(
                os.getcwd()+'/'+project_dir))
            if os.path.exists(os.getcwd()+'/'+project_dir):
                from shutil import rmtree
                print red('\nSeems like already exists a project named {0} '\
                    'on your current path.'.format(os.getcwd()+'/'+project_dir))
                if userquery("Would you like to rename it? "\
                             "(Ctrl+c to abort)")=="Yes":
                    from random import randrange
                    rnd=str(randrange(1, 10000))
                    os.rename(os.getcwd()+'/'+project_dir, os.getcwd()+'/'+\
                        project_dir+rnd)
                    print turquoise('The old directory was saved as '\
                        '{0}.'.format(os.getcwd()+'/'+project_dir+rnd))
                else:
                    rmtree(os.getcwd()+'/'+project_dir)

            os.mkdir(os.getcwd()+'/'+project_dir)
            # Cd to the new created directory
            if pr._verbose:
                print bold('Entering {0} dir.'.format(os.getcwd()+\
                '/'+project_dir))
            os.chdir(project_dir)

            # Write tac_file template
            if pr._verbose:
                print bold('Writing {0} Twisted tac file.'.format(
                    pr.get_name()))
            self._create_tac_file(pr)
            if pr.verbose:
                print bold('Creating config directory.\nWriting schema file.')
            self._create_config_directory(pr)

            # Create application needed directories
            if pr._verbose:
                print bold('Creating application directory.\n' \
                    'Creating model directory.\nCreating controller ' \
                    'directory.\nCreating view directory.')
            self._create_application_directory()
            self._create_model_directories()
            self._create_controller_directory()
            self._create_view_directory()
            if pr._verbose:
                print bold('Creating web directory.\n' \
                    'Creating web/js directory.\n' \
                    'Creating web/media directory\n.' \
                    'Creating web/css directory.\n' \
                    'Creating services directory.' \
                    'Writing web/js/main.js UI file.'
                )
            self._create_web_directories(pr)
            self._create_services_directory()

            # Write the project config file
            if pr._verbose: print bold('Writing {0} project file.'.format(
                    pr.get_name().lower().replace(' ', '_')+'.cfg'))
            self._create_config_file(pr)

            print bold('Project Generated!')
            self._configure(pr)
        except OSError, e:
            print red(str(e))
            sys.exit(-1)