Skip to content

Commit 6bf2e84

Browse files
mpaganomichal42
authored andcommitted
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. Signed-off-by: Mike Pagano <mpagano@gentoo.org> Signed-off-by: Michal Marek <mmarek@suse.cz>
1 parent 11097a0 commit 6bf2e84

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎scripts/diffconfig‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,13 @@ def main():
9494
configa_filename = sys.argv[1]
9595
configb_filename = sys.argv[2]
9696

97-
a = readconfig(file(configa_filename))
98-
b = readconfig(file(configb_filename))
97+
try:
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()
99104

100105
# print items in a but not b (accumulate, sort and print)
101106
old = []

0 commit comments

Comments
 (0)