Mercurial > p > roundup > code
changeset 296:e155eca83f40
Beginnings of an interactive mode for roundup-admin
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 17 Oct 2001 06:04:00 +0000 |
| parents | 0eb026a5257d |
| children | 1bbc16563d89 |
| files | roundup-admin setup.py |
| diffstat | 2 files changed, 91 insertions(+), 62 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup-admin Wed Oct 17 00:18:41 2001 +0000 +++ b/roundup-admin Wed Oct 17 06:04:00 2001 +0000 @@ -16,7 +16,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundup-admin,v 1.29 2001-10-16 03:48:01 richard Exp $ +# $Id: roundup-admin,v 1.30 2001-10-17 06:04:00 richard Exp $ import sys if int(sys.version[0]) < 2: @@ -125,6 +125,8 @@ help = figureCommands().get(args[0], None) if help: print help.__doc__ + else: + print 'Sorry, no help for "%s"'%args[0] def help_initopts(): import roundup.templates @@ -525,82 +527,106 @@ d[k[5:]] = v return d -def main(): - opts, args = getopt.getopt(sys.argv[1:], 'i:u:hc') +class AdminTool: + + def run_command(self, args): + command = args[0] - # handle command-line args - instance_home = os.environ.get('ROUNDUP_INSTANCE', '') - name = password = '' - if os.environ.has_key('ROUNDUP_LOGIN'): - l = os.environ['ROUNDUP_LOGIN'].split(':') - name = l[0] - if len(l) > 1: - password = l[1] - comma_sep = 0 - for opt, arg in opts: - if opt == '-h': - args = ['help'] - break - if opt == '-i': - instance_home = arg - if opt == '-c': - comma_sep = 1 + # handle help now + if command == 'help': + if len(args)>1: + do_help(args[1:]) + return 0 + do_help(['help']) + return 0 + if command == 'morehelp': + do_help(['help']) + help_commands() + help_all() + return 0 + + # make sure we have an instance_home + while not self.instance_home: + self.instance_home = raw_input('Enter instance home: ').strip() - # figure the command - if not args: - usage('No command specified') - return 1 - command = args[0] + # before we open the db, we may be doing an init + if command == 'init': + return do_init(self.instance_home, args) + + function = figureCommands().get(command, None) + + # not a valid command + if function is None: + usage('Unknown command "%s"'%command) + return 1 - # handle help now - if command == 'help': - if len(args)>1: - do_help(args[1:]) - return 0 - usage() - return 0 - if command == 'morehelp': - usage() - help_all() - return 0 + # get the instance + instance = roundup.instance.open(self.instance_home) + db = instance.open('admin') - # make sure we have an instance_home - while not instance_home: - instance_home = raw_input('Enter instance home: ').strip() + if len(args) < 2: + print function.__doc__ + return 1 - # before we open the db, we may be doing an init - if command == 'init': - return do_init(instance_home, args) + # do the command + try: + return function(db, args[1:], comma_sep=self.comma_sep) + finally: + db.close() - function = figureCommands().get(command, None) - - # not a valid command - if function is None: - usage('Unknown command "%s"'%command) return 1 - # get the instance - instance = roundup.instance.open(instance_home) - db = instance.open('admin') + def interactive(self, ws_re=re.compile(r'\s+')): + '''Run in an interactive mode + ''' + while 1: + try: + command = raw_input('roundup> ') + except EOFError: + print '.. exit' + return 0 + args = ws_re.split(command) + if not args: continue + if args[0] in ('quit', 'exit'): return 0 + self.run_command(args) - if len(args) < 2: - print function.__doc__ - return 1 + def main(self): + opts, args = getopt.getopt(sys.argv[1:], 'i:u:hc') - # do the command - try: - return function(db, args[1:], comma_sep=comma_sep) - finally: - db.close() + # handle command-line args + self.instance_home = os.environ.get('ROUNDUP_INSTANCE', '') + name = password = '' + if os.environ.has_key('ROUNDUP_LOGIN'): + l = os.environ['ROUNDUP_LOGIN'].split(':') + name = l[0] + if len(l) > 1: + password = l[1] + self.comma_sep = 0 + for opt, arg in opts: + if opt == '-h': + usage() + return 0 + if opt == '-i': + self.instance_home = arg + if opt == '-c': + self.comma_sep = 1 - return 1 + # if no command - go interactive + if not args: + return self.interactive() + + self.run_command(args) if __name__ == '__main__': - sys.exit(main()) + tool = AdminTool() + sys.exit(tool.main()) # # $Log: not supported by cvs2svn $ +# Revision 1.29 2001/10/16 03:48:01 richard +# admin tool now complains if a "find" is attempted with a non-link property. +# # Revision 1.28 2001/10/13 00:07:39 richard # More help in admin tool. #
--- a/setup.py Wed Oct 17 00:18:41 2001 +0000 +++ b/setup.py Wed Oct 17 06:04:00 2001 +0000 @@ -16,7 +16,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: setup.py,v 1.22 2001-10-11 05:01:28 richard Exp $ +# $Id: setup.py,v 1.23 2001-10-17 06:04:00 richard Exp $ from distutils.core import setup, Extension from distutils.util import get_platform @@ -42,7 +42,7 @@ setup ( name = "roundup", - version = "0.3.0pre2", + version = "0.3.0pre3", description = "Roundup issue tracking system.", author = "Richard Jones", author_email = "richard@users.sourceforge.net", @@ -53,6 +53,9 @@ # # $Log: not supported by cvs2svn $ +# Revision 1.22 2001/10/11 05:01:28 richard +# Prep for pre-release #2 +# # Revision 1.21 2001/10/10 04:18:38 richard # Getting ready for a preview release for 0.3.0. #
