Mercurial > hg > cc > azure
diff master/bin/fixDates.py @ 27:dd19cf97b6dd
attempt to fix robustness pblms
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Sat, 10 Nov 2018 13:20:56 +0000 |
parents | b4e3beb2227e |
children | 580cc12c9712 |
line wrap: on
line diff
--- a/master/bin/fixDates.py Wed Nov 07 19:36:30 2018 +0000 +++ b/master/bin/fixDates.py Sat Nov 10 13:20:56 2018 +0000 @@ -22,20 +22,24 @@ year=int(ff.group(3)) except: # Unusual month or year field - d=parse("%s %s"%(ff.group(2),ff.group(3))) - if d is None: - print(5,ff.group(1),ff.group(2),ff.group(3),file=sys.stderr) - year=0 - month=0 - elif d.year<1970: - year=0 - month=1 - elif d.year>2019: - month=1 - year=2019 - else: - month=d.month - year=d.year + try: + d=parse("%s %s"%(ff.group(2),ff.group(3))) + if d is None: + print(5,ff.group(1),ff.group(2),ff.group(3),file=sys.stderr) + year=0 + month=0 + elif d.year<1970: + year=0 + month=1 + elif d.year>2019: + month=1 + year=2019 + else: + month=d.month + year=d.year + except Exception as e: + print(6,e,l,file=sys.stderr) + bogons+=1 count=int(ff.group(4)) key=(scheme,year,month) tab[key]=tab.get(key,0)+count @@ -75,9 +79,12 @@ else: key=(scheme,d.year,d.month) tab[key]=tab.get(key,0)+count - except Exception(e): + except Exception as e: print(4,e,l,file=sys.stderr) bogons+=1 +if tab=={}: + # ssh screwed up + exit(1) for ((s,m,y),c) in tab.items(): print(s,m,y,c,sep='\t') print(bogons,file=sys.stderr)