Don't spit out Python love when wrong arguments are given, better
authorjoey <>
Thu, 25 Aug 2005 06:47:41 +0000 (06:47 +0000)
committerjoey <>
Thu, 25 Aug 2005 06:47:41 +0000 (06:47 +0000)
detect this and exit with a proper error message

ud-host
ud-info

diff --git a/ud-host b/ud-host
index 319227b..0fa035a 100755 (executable)
--- a/ud-host
+++ b/ud-host
@@ -215,7 +215,12 @@ ListMode = 0
 FingerPrints = 0
 Host = None
 # Process options
-(options, arguments) = getopt.getopt(sys.argv[1:], "nh:a:rlf")
+try:
+   (options, arguments) = getopt.getopt(sys.argv[1:], "nh:a:rlf")
+except getopt.GetoptError, data:
+   print data
+   sys.exit(1)
+
 for (switch, val) in options:
    if (switch == '-h'):
       Host = val;
diff --git a/ud-info b/ud-info
index 5f144bd..3591161 100755 (executable)
--- a/ud-info
+++ b/ud-info
@@ -244,7 +244,12 @@ def MultiChangeAttr(Attrs,Attr):
 User = pwd.getpwuid(os.getuid())[0];
 BindUser = User;
 # Process options
-(options, arguments) = getopt.getopt(sys.argv[1:], "nu:c:a:r")
+try:
+   (options, arguments) = getopt.getopt(sys.argv[1:], "nu:c:a:r")
+except getopt.GetoptError, data:
+   print data
+   sys.exit(1)
+
 for (switch, val) in options:
    if (switch == '-u'):
       User = val;