From c718484c54a4a2ecf6bfc6986f4d90a6befbf126 Mon Sep 17 00:00:00 2001 From: bjv Date: Wed, 23 Dec 2015 12:12:57 -0800 Subject: refactored exception suite into function exception suite is now less prone to indentation typos --- dateutil/zoneinfo/rebuild.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'dateutil/zoneinfo') diff --git a/dateutil/zoneinfo/rebuild.py b/dateutil/zoneinfo/rebuild.py index ff3bea0..a66c1d9 100644 --- a/dateutil/zoneinfo/rebuild.py +++ b/dateutil/zoneinfo/rebuild.py @@ -25,11 +25,7 @@ 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?") + _print_on_nosuchfile(e) raise # write metadata file with open(os.path.join(zonedir, METADATA_FN), 'w') as f: @@ -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?") -- cgit v1.2.3