Skip to content

Commit b5c552f

Browse files
author
Jürgen Hermann
committed
Fixed option & associated error handling
1 parent 11d793d commit b5c552f

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

roundup-admin

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1717
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1818
#
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 $
2020

2121
import sys
2222
if int(sys.version[0]) < 2:
@@ -66,8 +66,8 @@ class AdminTool:
6666
self.help[k[5:]] = getattr(self, k)
6767
self.db = None
6868

69-
def usage(message=''):
70-
if message: message = 'Problem: '+message+'\n'
69+
def usage(self, message=''):
70+
if message: message = 'Problem: '+message+'\n\n'
7171
print '''%sUsage: roundup-admin [-i instance home] [-u login] [-c] <command> <arguments>
7272
7373
Help:
@@ -92,7 +92,7 @@ Options:
9292
'Commands may be abbreviated as long as the abbreviation matches only one')
9393
commands.append('command, e.g. l == li == lis == list.')
9494
print '\n'.join(commands)
95-
print
95+
print
9696

9797
def help_all(self):
9898
print '''
@@ -851,7 +851,11 @@ Command help:
851851
self.run_command(args)
852852

853853
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
855859

856860
# handle command-line args
857861
self.instance_home = os.environ.get('ROUNDUP_INSTANCE', '')
@@ -864,7 +868,7 @@ Command help:
864868
self.comma_sep = 0
865869
for opt, arg in opts:
866870
if opt == '-h':
867-
usage()
871+
self.usage()
868872
return 0
869873
if opt == '-i':
870874
self.instance_home = arg
@@ -888,6 +892,9 @@ if __name__ == '__main__':
888892

889893
#
890894
# $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+
#
891898
# Revision 1.43 2001/11/09 22:33:28 richard
892899
# More error handling fixes.
893900
#

roundup-server

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
Based on CGIHTTPServer in the Python library.
2222
23-
$Id: roundup-server,v 1.18 2001-11-01 22:04:37 richard Exp $
23+
$Id: roundup-server,v 1.19 2001-11-12 22:51:04 jhermann Exp $
2424
2525
"""
2626
import sys
@@ -181,7 +181,7 @@ class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
181181
client.main()
182182

183183
def usage(message=''):
184-
if message: message = 'Error: %s\n'%message
184+
if message: message = 'Error: %s\n\n'%message
185185
print '''%sUsage:
186186
roundup-server [-n hostname] [-p port] [name=instance home]*
187187
@@ -203,7 +203,11 @@ def main():
203203
port = 8080
204204
try:
205205
# handle the command-line args
206-
optlist, args = getopt.getopt(sys.argv[1:], 'n:p:u:')
206+
try:
207+
optlist, args = getopt.getopt(sys.argv[1:], 'n:p:u:')
208+
except getopt.GetoptError, e:
209+
usage(str(e))
210+
207211
user = ROUNDUP_USER
208212
for (opt, arg) in optlist:
209213
if opt == '-n': hostname = arg
@@ -240,6 +244,8 @@ def main():
240244
raise ValueError, "Instances must be name=home"
241245
d[name] = home
242246
RoundupRequestHandler.ROUNDUP_INSTANCE_HOMES = d
247+
except SystemExit:
248+
raise
243249
except:
244250
type, value = sys.exc_info()[:2]
245251
usage('%s: %s'%(type, value))
@@ -256,6 +262,12 @@ if __name__ == '__main__':
256262

257263
#
258264
# $Log: not supported by cvs2svn $
265+
# Revision 1.18 2001/11/01 22:04:37 richard
266+
# Started work on supporting a pop3-fetching server
267+
# Fixed bugs:
268+
# . bug #477104 ] HTML tag error in roundup-server
269+
# . bug #477107 ] HTTP header problem
270+
#
259271
# Revision 1.17 2001/10/29 23:55:44 richard
260272
# Fix to CGI top-level index (thanks Juergen Hermann)
261273
#

0 commit comments

Comments
 (0)