Skip to content

Commit 147ccf7

Browse files
authored
Merge pull request #28 from wikimedia/timestamps
Add timestamps to error output
2 parents d623ba5 + 58a70bd commit 147ccf7

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

main.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
from config import *
55
from reports import *
66
import sys
7+
from datetime import datetime
8+
import traceback
9+
710

811
def main ( args ):
912
wiki = args[1]
@@ -15,14 +18,21 @@ def main ( args ):
1518
else:
1619
methods.append(arg)
1720

18-
for m in methods:
19-
print( m )
20-
run = Run( wiki, dry_run )
21-
method = getattr( run, str( m ) )
22-
if not method:
23-
raise Exception( "Method not implemented" )
24-
else:
25-
method()
21+
try:
22+
for m in methods:
23+
print( m )
24+
run = Run( wiki, dry_run )
25+
method = getattr( run, str( m ) )
26+
if not method:
27+
raise Exception( "Method not implemented" )
28+
else:
29+
method()
30+
except Exception:
31+
ts = datetime.now().replace(microsecond=0).isoformat()
32+
print(ts + ' ', end='', file=sys.stderr)
33+
traceback.print_exc(file=sys.stderr)
34+
sys.exit(1)
35+
2636

2737
class Run:
2838
def __init__( self, wiki, dry_run ):

0 commit comments

Comments
 (0)