Skip to content

Commit

Permalink
Merge pull request #164 from bjamesv/patch-updatezinfo1
Browse files Browse the repository at this point in the history
fix suppressed updatezinfo OSErrors
  • Loading branch information
pganssle committed Jan 11, 2016
2 parents 28abd97 + c718484 commit d4baf97
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions dateutil/zoneinfo/rebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ def rebuild(filename, tag=None, format="gz", zonegroups=[], metadata=None):
try:
check_call(["zic", "-d", zonedir] + filepaths)
except OSError as e:
if e.errno == 2:
logging.error(
"Could not find zic. Perhaps you need to install "
"libc-bin or some other package that provides it, "
"or it's not in your PATH?")
raise
_print_on_nosuchfile(e)
raise
# write metadata file
with open(os.path.join(zonedir, METADATA_FN), 'w') as f:
json.dump(metadata, f, indent=4, sort_keys=True)
Expand All @@ -41,3 +37,15 @@ def rebuild(filename, tag=None, format="gz", zonegroups=[], metadata=None):
tf.add(entrypath, entry)
finally:
shutil.rmtree(tmpdir)

def _print_on_nosuchfile(e):
"""Print helpful troubleshooting message
e is an exception raised by subprocess.check_call()
"""
if e.errno == 2:
logging.error(
"Could not find zic. Perhaps you need to install "
"libc-bin or some other package that provides it, "
"or it's not in your PATH?")

0 comments on commit d4baf97

Please sign in to comment.