mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 18:21:39 +01:00
bitkeeper revision 1.1108.1.10 (40ffca0cD1Dy4C5W0JRW9WjeIXOWPA)
Catch getopt errors.
This commit is contained in:
1 parent
1cf700faee
commit
20cd16c058
1 file changed
+6
-3
@@ -1,7 +1,7 @@
|
||||
# Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
|
||||
"""Object-oriented command-line option support.
|
||||
"""
|
||||
from getopt import getopt
|
||||
from getopt import getopt, GetoptError
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
@@ -273,7 +273,10 @@ class Opts:
|
||||
return remaining arguments
|
||||
"""
|
||||
self.argv = argv
|
||||
(vals, args) = getopt(argv[1:], self.short_opts(), self.long_opts())
|
||||
try:
|
||||
(vals, args) = getopt(argv[1:], self.short_opts(), self.long_opts())
|
||||
except GetoptError, err:
|
||||
self.err(str(err))
|
||||
self.args = args
|
||||
for (k, v) in vals:
|
||||
for opt in self.options:
|
||||
@@ -331,7 +334,7 @@ class Opts:
|
||||
else:
|
||||
p = self.vals.defaults
|
||||
if os.path.exists(p):
|
||||
print 'Using config file %s\n' % (p)
|
||||
self.info('Using config file %s' % p)
|
||||
self.load(p, help)
|
||||
break
|
||||
else:
|
||||
|
||||