Django

Code

Changeset 6089

Show
Ignore:
Timestamp:
09/10/07 22:46:35 (1 year ago)
Author:
adrian
Message:

Changed core.management print_help() methods to accept a prog_name argument instead of an argv list, in an attempt to figure out why auto reloading stopped working

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/management/base.py

    r6088 r6089  
    5050                            option_list=self.option_list) 
    5151 
    52     def print_help(self, argv): 
    53         parser = self.create_parser(argv[0]
     52    def print_help(self, prog_name): 
     53        parser = self.create_parser(prog_name
    5454        parser.print_help() 
    5555 
    56     def run(self, argv): 
     56    def run_from_argv(self, argv): 
    5757        parser = self.create_parser(argv[0]) 
    5858        options, args = parser.parse_args(argv[1:]) 
  • django/trunk/django/core/management/__init__.py

    r6088 r6089  
    5252        return dict([(name, load_command_class(name)) for name in names]) 
    5353 
    54     def print_help(self, argv): 
     54    def print_help(self, prog_name): 
    5555        """ 
    5656        Returns the help message, as a string. 
    5757        """ 
    58         prog_name = os.path.basename(argv[0]
     58        prog_name = os.path.basename(prog_name
    5959        usage = ['%s <subcommand> [options] [args]' % prog_name] 
    6060        usage.append('Django command line tool, version %s' % django.get_version()) 
     
    6767        print '\n'.join(usage) 
    6868 
    69     def fetch_command(self, subcommand, command_name): 
     69    def fetch_command(self, subcommand, prog_name): 
    7070        """ 
    7171        Tries to fetch the given subcommand, printing a message with the 
     
    7676            return self.commands[subcommand] 
    7777        except KeyError: 
    78             sys.stderr.write("Unknown command: %r\nType '%s help' for usage.\n" % (subcommand, command_name)) 
     78            sys.stderr.write("Unknown command: %r\nType '%s help' for usage.\n" % (subcommand, prog_name)) 
    7979            sys.exit(1) 
    8080 
    8181    def execute(self, argv=None): 
    8282        """ 
    83         Figures out which command is being run (the first arg), creates a parser 
    84         appropriate to that command, and runs it. 
     83        Given the command-line arguments, this figures out which subcommand is 
     84        being run, creates a parser appropriate to that command, and runs it. 
    8585        """ 
    8686        if argv is None: 
     
    9494        if subcommand == 'help': 
    9595            if len(argv) > 2: 
    96                 self.fetch_command(argv[2], argv[0]).print_help(argv[2:]) 
     96                self.fetch_command(argv[2], argv[0]).print_help(argv[0]) 
    9797            else: 
    98                 self.print_help(argv
     98                self.print_help(argv[0]
    9999        # Special-cases: We want 'django-admin.py --version' and 
    100100        # 'django-admin.py --help' to work, for backwards compatibility. 
     
    102102            print django.get_version() 
    103103        elif argv[1:] == ['--help']: 
    104             self.print_help(argv
     104            self.print_help(argv[0]
    105105        else: 
    106             self.fetch_command(subcommand, argv[0]).run(argv[1:]) 
     106            self.fetch_command(subcommand, argv[0]).run_from_argv(argv[1:]) 
    107107 
    108108class ProjectManagementUtility(ManagementUtility):