def execute(self, callback=None):
        """
        Given the command-line arguments, this figures out which subcommand is
        being run, creates a parser appropriate to that command, and runs it.
        """
        # Preprocess options to extract --settings and --pythonpath.
        # These options could affect the commands that are available, so they
        # must be processed early.
        self.parser = parser = NewOptionParser(prog=self.prog_name,
                             usage=self.usage_info,
#                             version=self.get_version(),
                             formatter = NewFormatter(),
                             add_help_option = False,
                             option_list=self.option_list)
        
        if not self.global_options:
            global_options, args = parser.parse_args(self.argv)
            global_options.apps_dir = os.path.normpath(os.path.join(global_options.project, 'apps'))
            handle_default_options(global_options)
            args = args[1:]
        else:
            global_options = self.global_options
            args = self.argv

        if global_options.envs:
            for x in global_options.envs:
                if '=' in x:
                    k, v = x.split('=')
                    os.environ[k.strip()] = v.strip()
                else:
                    print ('Error: environment variable definition (%s) format is not right, '
                           'shoule be -Ek=v or -Ek="a b"' % x)

        global_options.settings = global_options.settings or os.environ.get('SETTINGS', 'settings.ini')
        global_options.local_settings = global_options.local_settings or os.environ.get('LOCAL_SETTINGS', 'local_settings.ini')
        
        if callback:
            callback(global_options)
            
        if len(args) == 0:
            if global_options.version:
                print self.get_version()
                sys.exit(0)
            else:
                self.print_help(global_options)
                sys.ext(1)

        self.do_command(args, global_options)
def execute ( self , callback = None ) : self . parser = parser = NewOptionParser ( prog = self . prog_name , usage = self . usage_info , formatter = NewFormatter ( ) , add_help_option = False , option_list = self . option_list ) if not self . global_options : global_options , args = parser . parse_args ( self . argv ) global_options . apps_dir = os . path . normpath ( os . path . join ( global_options . project , 'apps' ) ) handle_default_options ( global_options ) args = args [ 1 : ] else : global_options = self . global_options args = self . argv if global_options . envs : for x in global_options . envs : if '=' in x : k , v = x . split ( '=' ) os . environ [ k . strip ( ) ] = v . strip ( ) else : print ( 'Error: environment variable definition (%s) format is not right, ' 'shoule be -Ek=v or -Ek="a b"' % x ) global_options . settings = global_options . settings or os . environ . get ( 'SETTINGS' , 'settings.ini' ) global_options . local_settings = global_options . local_settings or os . environ . get ( 'LOCAL_SETTINGS' , 'local_settings.ini' ) if callback : callback ( global_options ) if len ( args ) == 0 : if global_options . version : print self . get_version ( ) sys . exit ( 0 ) else : self . print_help ( global_options ) sys . ext ( 1 ) self . do_command ( args , global_options )
Given the command-line arguments, this figures out which subcommand is
        being run, creates a parser appropriate to that command, and runs it.