-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathimage_watchdog_autorestart.py
38 lines (34 loc) · 1.69 KB
/
image_watchdog_autorestart.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
import subprocess
import logging
from measurement_directory import measurement_directory, todays_measurements
import enrico_bot
# logger = logging.getLogger(__name__)
# logger.setLevel(logging.DEBUG)
# formatter = logging.Formatter('%(asctime)s:%(name)s:%(message)s')
# file_handler = logging.FileHandler(measurement_directory(
# measurement_name='') + 'image_watchdog_autorestart_debugging.log')
# file_handler.setLevel(logging.DEBUG)
# file_handler.setFormatter(formatter)
# logger.addHandler(file_handler)
print('These names already exist: ')
print(todays_measurements())
run_idx = input('Enter run index: ')
name = input('Enter measurement_name: ')
measurement_name = 'run{idx}_{name}'.format(idx=run_idx, name=name)
n_images_per_run = input(
'How many images arrive per shot? e.g. 3 for triple imaging ')
i = 0
while True:
if i == 0:
print('python image_watchdog.py {name} {n_images}'.format(name=measurement_name,
n_images=n_images_per_run))
p1 = subprocess.run('python image_watchdog.py {name} {n_images}'.format(name=measurement_name,
n_images=n_images_per_run),
shell=True)
enrico_bot.post_message('image_watchdog.py restarted automatically.')
print('\n restarting')
i += 1
else:
p1 = subprocess.run('python image_watchdog.py {name} {n_images}'.format(name=measurement_name + '_aftercrash',
n_images=n_images_per_run),
shell=True)