-
Notifications
You must be signed in to change notification settings - Fork 0
/
state.py
43 lines (36 loc) · 1.24 KB
/
state.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
from datetime import datetime
import os
import sys
import aid
import conf
import us
def translate(states):
print('Started translating states in', states)
log_path = aid.make_path('logs/')
with open(log_path + 'states.' + str(datetime.now()), 'w') as common:
sys.stdout = common
sys.stderr = common
print('Translating', states)
for state in states:
if state == 'input':
continue
stdout = log_path + state + '.out'
if os.path.exists(stdout):
print(stdout, 'already exists. Delete it if you want to rerun.')
continue
aid.log_time('Translating ' + state)
with open(stdout, 'w') as sys.stdout:
with open(log_path + state + '.err', 'w') as sys.stderr:
aid.log_time()
try:
us.translate(state)
except Exception as e:
aid.log_error(e)
finally:
aid.log_time()
sys.stdout = common
sys.stderr = common
def test():
translate(['56'])
if __name__ == "__main__":
translate(os.listdir(conf.path_usa))