-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.py
34 lines (28 loc) · 923 Bytes
/
common.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
#!/usr/bin/python
import inspect
import logging
import os
import subprocess
def lineno():
"""Returns the current line number in our program."""
return inspect.currentframe().f_back.f_lineno
def log_setup():
i=0
if 'bse_last' in os.listdir("./"):
subprocess.call(["rm","-rf","bse_last"])
while(1):
if 'bse_out_'+str(i) in os.listdir("./"):
i=i+1
else:
break
subprocess.call(["mkdir","bse_out_"+str(i)])
subprocess.call(["ln","-s","bse_out_"+str(i),"bse_last"])
LOG_PATH = "./"+"bse_last"
LOG_FILENAME="bse.log"
logging.basicConfig(filename=LOG_FILENAME,pathname=LOG_PATH,
level=logging.DEBUG,
)
logging.info("Starting Log")
def log_close():
subprocess.call(["mv","bse.log","./bse_last"])
log=logging #Log can be changed so overide debug/info/error functions