[rhel6-branch 08/10] Improvements to loadkeys-stub

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Related: rhbz#706099
---
 command-stubs/loadkeys-stub |   41 +++++++++++++++++++++++------------------
 1 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/command-stubs/loadkeys-stub b/command-stubs/loadkeys-stub
index 1752717..2d1d434 100755
--- a/command-stubs/loadkeys-stub
+++ b/command-stubs/loadkeys-stub
@@ -2,7 +2,7 @@
 #
 # loadkeys-stub
 #
-# Copyright (C) 2007  Red Hat, Inc.  All rights reserved.
+# Copyright (C) 2007, 2011  Red Hat, Inc.  All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -18,30 +18,35 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-import os
 import sys
 
-# for testing
-if (os.path.exists('isys')):
-    sys.path.append('isys')
-
 sys.path.append('/usr/lib/anaconda')
-
 import isys
 
+
 def usage():
-    print "usage: %s keymap" %(sys.argv[0],)
-    sys.exit(1)
+    return 'Usage: %prog <keymap>'
+
+
+def main(prog, args):
 
-def main():
-    if len(sys.argv) != 2:
-        usage()
+    def err(msg):
+        sys.stderr.write('%s: %s' % (prog, msg))
+        sys.exit(1)
+
+    if len(args) > 1:
+        err("extra operand '%s'" % args[1])
+
+    try:
+        keymap = args[0]
+    except IndexError:
+        err('missing operand')
 
     try:
-        isys.loadKeymap(sys.argv[1])
-    except SystemError:
-        pass
-    sys.exit(0)
+        isys.loadKeymap(keymap)
+    except SystemError as e:
+        err(e)
+
 
-if __name__ == "__main__":
-    main()
+if __name__ == '__main__':
+    main(prog=sys.argv[0], args=sys.argv[1:])
-- 
1.7.3.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux