History

diffconfig: Gracefully exit if the default config files are not present

Handle gracefully the instance where config files are not present. Compatible with python versions 2.5, 2.6 and 2.7. The try/except is forward compatible with python version 3 once the entire script is ported.

Mike Pagano committed 13 years ago

Commit 6bf2e841 parent 11097a01 file · +7 −2Browse files

Showing the changes to scripts/diffconfig (1 of 1 file). Show all

Unified · Split

scripts/diffconfig+7−2
@@ -94,8 +94,13 @@ def main(): · 93 unmodified lines
94 configa_filename = sys.argv[1]94 configa_filename = sys.argv[1]
95 configb_filename = sys.argv[2]95 configb_filename = sys.argv[2]
96 96
97 a = readconfig(file(configa_filename))97 try:
98 b = readconfig(file(configb_filename))98 a = readconfig(file(configa_filename))
99 b = readconfig(file(configb_filename))
100 except (IOError):
101 e = sys.exc_info()[1]
102 print("I/O error[%s]: %s\n" % (e.args[0],e.args[1]))
103 usage()
99 104
100 # print items in a but not b (accumulate, sort and print)105 # print items in a but not b (accumulate, sort and print)
101 old = []106 old = []