diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-04-16 01:19:24 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-04-16 01:19:24 -0400 |
commit | f86095bab5e5af6a2bf8be8ebe46d445864b4b71 (patch) | |
tree | fd1cfa3f7488190214e415d977a3af0e84177822 /mirrors | |
parent | 7aabbe788bb4e26ee9c7cfc0e18692b487e11099 (diff) | |
parent | 7da44456fd05f2ac74355825de7100e46e86449b (diff) |
Merge branch 'archweb-generic'
Diffstat (limited to 'mirrors')
-rw-r--r-- | mirrors/management/commands/mirrorcheck.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/mirrors/management/commands/mirrorcheck.py b/mirrors/management/commands/mirrorcheck.py index d2a27bee..8c17c78f 100644 --- a/mirrors/management/commands/mirrorcheck.py +++ b/mirrors/management/commands/mirrorcheck.py @@ -96,7 +96,7 @@ def parse_lastsync(log, data): try: parsed_time = datetime.utcfromtimestamp(int(data)) log.last_sync = parsed_time.replace(tzinfo=utc) - except ValueError: + except (TypeError, ValueError): # it is bad news to try logging the lastsync value; # sometimes we get a crazy-encoded web page. # if we couldn't parse a time, this is a failure. @@ -197,8 +197,11 @@ def check_rsync_url(mirror_url, location, timeout): log.duration = None else: logger.debug("success: %s, %.2f", url, log.duration) - with open(lastsync_path, 'r') as lastsync: - parse_lastsync(log, lastsync.read()) + if os.path.exists(lastsync_path): + with open(lastsync_path, 'r') as lastsync: + parse_lastsync(log, lastsync.read()) + else: + parse_lastsync(log, None) finally: if os.path.exists(lastsync_path): os.unlink(lastsync_path) |