diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-08-17 03:01:00 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-08-17 03:01:00 -0400 |
commit | 5845cee750eba9b5b9bd674d94d383addfc18f55 (patch) | |
tree | 0d9404985fa34f9d06ce4a43ff0e2876f55276de /leapsecond.py | |
parent | 7e81100c0c9e1b3ca1d65d89ca56ce8e619548a9 (diff) | |
download | gpsd-5845cee750eba9b5b9bd674d94d383addfc18f55.tar.gz |
Don't clobber existing leapseconds cache if USNO is not accessible.
Diffstat (limited to 'leapsecond.py')
-rwxr-xr-x | leapsecond.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/leapsecond.py b/leapsecond.py index bfe1fc22..b908eecd 100755 --- a/leapsecond.py +++ b/leapsecond.py @@ -113,12 +113,13 @@ def save_leapseconds(outfile): "Fetch the USNO leap-second history data and make a leap-second list." skip = True leapsecs = [] - # This code assumes that after 1980, leap-second increments are - # always integrally one second and every increment is listed here - leapsecs = [] try: + fetchobj = urllib.urlopen("ftp://maia.usno.navy.mil/ser7/tai-utc.dat") + # This code assumes that after 1980, leap-second increments are + # always integrally one second and every increment is listed here + leapsecs = [] fp = open(outfile, "w") - for line in urllib.urlopen("ftp://maia.usno.navy.mil/ser7/tai-utc.dat"): + for line in fetchobj: if line.startswith(" 1980"): skip = False if skip: |