-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbatch.py
48 lines (39 loc) · 1.34 KB
/
batch.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
# standard modules
import datetime
import logging
import datetime
import logging
import os
import sys
import warnings
# 3rd party modules
from configobj import ConfigObj
# PFP modules
sys.path.append('scripts')
from scripts import pfp_batch
from scripts import pfp_log
warnings.filterwarnings("ignore", category=Warning)
logger = logging.getLogger("pfp_log")
class Bunch:
def __init__(self, **kwds):
self.__dict__.update(kwds)
if (__name__ == '__main__'):
# get the logger
now = datetime.datetime.now()
log_file_name = "batch_" + now.strftime("%Y%m%d%H%M") + ".log"
log_file_name = os.path.join("logfiles", log_file_name)
logger = pfp_log.CreateLogger("pfp_log", log_file_name=log_file_name,
to_screen=True)
cfg_file_name = sys.argv[1]
if not os.path.isfile(cfg_file_name):
msg = "Batch control file " + cfg_file_name + " not found"
logger.error(msg)
sys.exit()
cfg_batch = ConfigObj(cfg_file_name, indent_type=" ", list_values=False,
write_empty_values=True)
main_ui = Bunch(stop_flag=False, cfg=cfg_batch, mode="batch")
if cfg_batch["level"] in ["batch", "batch_levels"]:
pfp_batch.do_levels_batch(main_ui)
else:
msg = " Unrecognised batch type: " + str(cfg_batch["level"])
logger.error(msg)