comparison roundup-admin @ 386:59ed29a879f6

Fixed option & associated error handling
author Jürgen Hermann <jhermann@users.sourceforge.net>
date Mon, 12 Nov 2001 22:51:59 +0000
parents a1331423eb93
children d47818b09265
comparison
equal deleted inserted replaced
385:66e18fd9f5a2 386:59ed29a879f6
14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
18 # 18 #
19 # $Id: roundup-admin,v 1.44 2001-11-12 22:01:06 richard Exp $ 19 # $Id: roundup-admin,v 1.45 2001-11-12 22:51:59 jhermann Exp $
20 20
21 import sys 21 import sys
22 if int(sys.version[0]) < 2: 22 if int(sys.version[0]) < 2:
23 print 'Roundup requires python 2.0 or later.' 23 print 'Roundup requires python 2.0 or later.'
24 sys.exit(1) 24 sys.exit(1)
64 for k in AdminTool.__dict__.keys(): 64 for k in AdminTool.__dict__.keys():
65 if k[:5] == 'help_': 65 if k[:5] == 'help_':
66 self.help[k[5:]] = getattr(self, k) 66 self.help[k[5:]] = getattr(self, k)
67 self.db = None 67 self.db = None
68 68
69 def usage(message=''): 69 def usage(self, message=''):
70 if message: message = 'Problem: '+message+'\n' 70 if message: message = 'Problem: '+message+'\n\n'
71 print '''%sUsage: roundup-admin [-i instance home] [-u login] [-c] <command> <arguments> 71 print '''%sUsage: roundup-admin [-i instance home] [-u login] [-c] <command> <arguments>
72 72
73 Help: 73 Help:
74 roundup-admin -h 74 roundup-admin -h
75 roundup-admin help -- this help 75 roundup-admin help -- this help
90 commands.sort() 90 commands.sort()
91 commands.append( 91 commands.append(
92 'Commands may be abbreviated as long as the abbreviation matches only one') 92 'Commands may be abbreviated as long as the abbreviation matches only one')
93 commands.append('command, e.g. l == li == lis == list.') 93 commands.append('command, e.g. l == li == lis == list.')
94 print '\n'.join(commands) 94 print '\n'.join(commands)
95 print 95 print
96 96
97 def help_all(self): 97 def help_all(self):
98 print ''' 98 print '''
99 All commands (except help) require an instance specifier. This is just the path 99 All commands (except help) require an instance specifier. This is just the path
100 to the roundup instance you're working with. A roundup instance is where 100 to the roundup instance you're working with. A roundup instance is where
849 if not args: continue 849 if not args: continue
850 if args[0] in ('quit', 'exit'): return 0 850 if args[0] in ('quit', 'exit'): return 0
851 self.run_command(args) 851 self.run_command(args)
852 852
853 def main(self): 853 def main(self):
854 opts, args = getopt.getopt(sys.argv[1:], 'i:u:hc') 854 try:
855 opts, args = getopt.getopt(sys.argv[1:], 'i:u:hc')
856 except getopt.GetoptError, e:
857 self.usage(str(e))
858 return 1
855 859
856 # handle command-line args 860 # handle command-line args
857 self.instance_home = os.environ.get('ROUNDUP_INSTANCE', '') 861 self.instance_home = os.environ.get('ROUNDUP_INSTANCE', '')
858 name = password = '' 862 name = password = ''
859 if os.environ.has_key('ROUNDUP_LOGIN'): 863 if os.environ.has_key('ROUNDUP_LOGIN'):
862 if len(l) > 1: 866 if len(l) > 1:
863 password = l[1] 867 password = l[1]
864 self.comma_sep = 0 868 self.comma_sep = 0
865 for opt, arg in opts: 869 for opt, arg in opts:
866 if opt == '-h': 870 if opt == '-h':
867 usage() 871 self.usage()
868 return 0 872 return 0
869 if opt == '-i': 873 if opt == '-i':
870 self.instance_home = arg 874 self.instance_home = arg
871 if opt == '-c': 875 if opt == '-c':
872 self.comma_sep = 1 876 self.comma_sep = 1
886 tool = AdminTool() 890 tool = AdminTool()
887 sys.exit(tool.main()) 891 sys.exit(tool.main())
888 892
889 # 893 #
890 # $Log: not supported by cvs2svn $ 894 # $Log: not supported by cvs2svn $
895 # Revision 1.44 2001/11/12 22:01:06 richard
896 # Fixed issues with nosy reaction and author copies.
897 #
891 # Revision 1.43 2001/11/09 22:33:28 richard 898 # Revision 1.43 2001/11/09 22:33:28 richard
892 # More error handling fixes. 899 # More error handling fixes.
893 # 900 #
894 # Revision 1.42 2001/11/09 10:11:08 richard 901 # Revision 1.42 2001/11/09 10:11:08 richard
895 # . roundup-admin now handles all hyperdb exceptions 902 # . roundup-admin now handles all hyperdb exceptions

Roundup Issue Tracker: http://roundup-tracker.org/