-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_loop.py
More file actions
78 lines (59 loc) · 1.76 KB
/
Copy pathrun_loop.py
File metadata and controls
78 lines (59 loc) · 1.76 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""
Created on Wed May 31, 2015
@author: mlu
"""
import math
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import cmath as cmath
from scipy import signal
import os
import threading
import subprocess
import datetime
import time
def log(s):
with open(os.path.join('data', 'run2', 'output.log'), 'w+') as f:
f.write(str(s) + "\n")
time_fmt = "%04d-%02d-%02d %02d.%02d.%02d"
dt = 1 # how often to check whether to stop
def now():
return tuple(datetime.datetime.now().timetuple()[:6])
def analyzer_cmds():
subprocess.call(["git", "pull"])
analyzer_globals = {}
while True:
try:
execfile("instruct_analyzer.py", analyzer_globals)
except NameError as e:
print e.message
log(e.message)
log(time_fmt % now())
subprocess.call(["git", "add", "--all"])
subprocess.call(['git', 'commit', '-m', '"data taken"'])
subprocess.call(['git', 'pull'])
subprocess.call(["git", "push", "origin", "master"])
if 'dt' not in analyzer_globals: analyzer_globals['dt'] = 1
time.sleep(analyzer_globals['dt'])
def q_cmds():
q_globals = {}
while True:
try:
execfile("transfer_func_Q.py", q_globals)
except Exception as e:
log(e.message)
if 'dt' not in q_globals: q_globals['dt'] = 1
time.sleep(q_globals['dt'])
analyzer_thread = threading.Thread(target=analyzer_cmds, args=())
q_thread = threading.Thread(target=q_cmds, args=())
analyzer_thread.daemon = True
q_thread.daemon = True
analyzer_thread.start()
q_thread.start()
while True:
time.sleep(dt)
with open('run_loop_instructions.txt') as f:
if "stop" in f:
break