Merge lp:~javier.collado/utah/bug1075620 into lp:utah

Proposed by Javier Collado
Status: Merged
Approved by: Javier Collado
Approved revision: 732
Merged at revision: 732
Proposed branch: lp:~javier.collado/utah/bug1075620
Merge into: lp:utah
Diff against target: 14 lines (+3/-2)
1 file modified
utah/config.py (+3/-2)
To merge this branch: bzr merge lp:~javier.collado/utah/bug1075620
Reviewer Review Type Date Requested Status
Max Brustkern (community) Approve
Review via email: mp+133102@code.launchpad.net

Description of the change

This branch avoids json parsing errors for empty files (using os.path.getsize) just skipping them.

To post a comment you must log in.
Revision history for this message
Javier Collado (javier.collado) wrote :

As commented through IRC, the reason why /etc/utah/config was empty still is unknown. I'll investigate that and report a separate bug if needed.

Revision history for this message
Max Brustkern (nuclearbob) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utah/config.py'
2--- utah/config.py 2012-10-19 21:57:01 +0000
3+++ utah/config.py 2012-11-06 16:54:21 +0000
4@@ -84,8 +84,9 @@
5 for conffile in files:
6 if conffile is not None:
7 myfile = os.path.expanduser(conffile)
8- if os.path.isfile(myfile):
9- CONFIG.update(json.load(open(myfile)))
10+ if os.path.isfile(myfile) and os.path.getsize(myfile) > 0:
11+ with open(myfile) as fp:
12+ CONFIG.update(json.load(fp))
13
14 locals().update(CONFIG)
15

Subscribers

People subscribed via source and target branches