-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal_runner.py
48 lines (36 loc) · 1.12 KB
/
local_runner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import Tkinter
import tkFileDialog
import sys
import datetime
import shutil
import os
import traceback
from src import validator
LOG = False
def error_logger(type, value, tb):
shutil.copy(trouble_maker, "trouble_maker/" + os.path.basename(trouble_maker))
for line in traceback.format_exception(type, value, tb):
print line
if __name__ == "__main__":
if LOG:
sys.excepthook = error_logger
log = open("log/" + datetime.datetime.now().strftime("%Y%m%d") + ".log", "a")
sys.stdout = log
sys.stderr = log
log.write("*********************\n*")
log.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + "*\n*********************\n")
root = Tkinter.Tk()
root.withdraw()
f = tkFileDialog.askopenfilename()
if not f:
sys.exit(0)
global trouble_maker
trouble_maker = f
if LOG:
log.write("File name: " + f.encode("utf8", errors="ignore") + "\n\n")
v = validator.Validator(f, True)
if not v.parse_file():
v.produce_result_file(True)
sys.exit(-1)
v.perform_all_checks()
v.produce_result_file(False)