displays an error message if a command fails, so that the user knows something went wrong

This commit is contained in:
Vishvananda Ishaya
2011-03-28 16:27:33 -07:00
parent 1d86e22153
commit 55ed6ea207

View File

@@ -1098,8 +1098,8 @@ def main():
script_name = argv.pop(0)
if len(argv) < 1:
print script_name + " category action [<args>]"
print "Available categories:"
for k, _ in CATEGORIES:
print _("Available categories:")
for k, _v in CATEGORIES:
print "\t%s" % k
sys.exit(2)
category = argv.pop(0)
@@ -1110,7 +1110,7 @@ def main():
actions = methods_of(command_object)
if len(argv) < 1:
print script_name + " category action [<args>]"
print "Available actions for %s category:" % category
print _("Available actions for %s category:") % category
for k, _v in actions:
print "\t%s" % k
sys.exit(2)
@@ -1122,9 +1122,12 @@ def main():
fn(*argv)
sys.exit(0)
except TypeError:
print "Possible wrong number of arguments supplied"
print _("Possible wrong number of arguments supplied")
print "%s %s: %s" % (category, action, fn.__doc__)
raise
except:
print _("Command failed, please check log for more info")
raise
if __name__ == '__main__':
main()