From d9a7a9f4f8e4cb40cbdcb8d04d37bbc4979d958d Mon Sep 17 00:00:00 2001 From: jhermann Date: Mon, 12 Nov 2001 22:51:59 +0000 Subject: [PATCH] Fixed option & associated error handling git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@397 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup-admin | 19 +++++++++++++------ roundup-server | 18 +++++++++++++++--- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/roundup-admin b/roundup-admin index 4065e33..e165aa1 100755 --- a/roundup-admin +++ b/roundup-admin @@ -16,7 +16,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundup-admin,v 1.44 2001-11-12 22:01:06 richard Exp $ +# $Id: roundup-admin,v 1.45 2001-11-12 22:51:59 jhermann Exp $ import sys if int(sys.version[0]) < 2: @@ -66,8 +66,8 @@ class AdminTool: self.help[k[5:]] = getattr(self, k) self.db = None - def usage(message=''): - if message: message = 'Problem: '+message+'\n' + def usage(self, message=''): + if message: message = 'Problem: '+message+'\n\n' print '''%sUsage: roundup-admin [-i instance home] [-u login] [-c] Help: @@ -92,7 +92,7 @@ Options: 'Commands may be abbreviated as long as the abbreviation matches only one') commands.append('command, e.g. l == li == lis == list.') print '\n'.join(commands) - print + print def help_all(self): print ''' @@ -851,7 +851,11 @@ Command help: self.run_command(args) def main(self): - opts, args = getopt.getopt(sys.argv[1:], 'i:u:hc') + try: + opts, args = getopt.getopt(sys.argv[1:], 'i:u:hc') + except getopt.GetoptError, e: + self.usage(str(e)) + return 1 # handle command-line args self.instance_home = os.environ.get('ROUNDUP_INSTANCE', '') @@ -864,7 +868,7 @@ Command help: self.comma_sep = 0 for opt, arg in opts: if opt == '-h': - usage() + self.usage() return 0 if opt == '-i': self.instance_home = arg @@ -888,6 +892,9 @@ if __name__ == '__main__': # # $Log: not supported by cvs2svn $ +# Revision 1.44 2001/11/12 22:01:06 richard +# Fixed issues with nosy reaction and author copies. +# # Revision 1.43 2001/11/09 22:33:28 richard # More error handling fixes. # diff --git a/roundup-server b/roundup-server index de71d67..a71ce47 100755 --- a/roundup-server +++ b/roundup-server @@ -20,7 +20,7 @@ Based on CGIHTTPServer in the Python library. -$Id: roundup-server,v 1.18 2001-11-01 22:04:37 richard Exp $ +$Id: roundup-server,v 1.19 2001-11-12 22:51:04 jhermann Exp $ """ import sys @@ -181,7 +181,7 @@ class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): client.main() def usage(message=''): - if message: message = 'Error: %s\n'%message + if message: message = 'Error: %s\n\n'%message print '''%sUsage: roundup-server [-n hostname] [-p port] [name=instance home]* @@ -203,7 +203,11 @@ def main(): port = 8080 try: # handle the command-line args - optlist, args = getopt.getopt(sys.argv[1:], 'n:p:u:') + try: + optlist, args = getopt.getopt(sys.argv[1:], 'n:p:u:') + except getopt.GetoptError, e: + usage(str(e)) + user = ROUNDUP_USER for (opt, arg) in optlist: if opt == '-n': hostname = arg @@ -240,6 +244,8 @@ def main(): raise ValueError, "Instances must be name=home" d[name] = home RoundupRequestHandler.ROUNDUP_INSTANCE_HOMES = d + except SystemExit: + raise except: type, value = sys.exc_info()[:2] usage('%s: %s'%(type, value)) @@ -256,6 +262,12 @@ if __name__ == '__main__': # # $Log: not supported by cvs2svn $ +# Revision 1.18 2001/11/01 22:04:37 richard +# Started work on supporting a pop3-fetching server +# Fixed bugs: +# . bug #477104 ] HTML tag error in roundup-server +# . bug #477107 ] HTTP header problem +# # Revision 1.17 2001/10/29 23:55:44 richard # Fix to CGI top-level index (thanks Juergen Hermann) # -- 2.30.2