forked from M-Labs/artiq
1
0
Fork 0

worker_db: factor get_output_prefix()

This commit is contained in:
Robert Jördens 2016-04-07 23:04:23 +08:00
parent 16fdebad8e
commit 5b955e8ce8
1 changed files with 8 additions and 3 deletions

View File

@ -148,13 +148,18 @@ class DeviceManager:
self.active_devices.clear() self.active_devices.clear()
def get_hdf5_output(start_time, rid, name): def get_output_prefix(start_time, rid, name):
dirname = os.path.join("results", dirname = os.path.join("results",
time.strftime("%Y-%m-%d", start_time), time.strftime("%Y-%m-%d", start_time),
time.strftime("%H-%M", start_time)) time.strftime("%H-%M", start_time))
filename = "{:09}-{}.h5".format(rid, name) filename = "{:09}-{}".format(rid, name)
os.makedirs(dirname, exist_ok=True) os.makedirs(dirname, exist_ok=True)
return h5py.File(os.path.join(dirname, filename), "w") return os.path.join(dirname, filename)
def get_hdf5_output(start_time, rid, name):
prefix = get_output_prefix(start_time, rid, name)
return h5py.File("{}.h5".format(prefix), "w")
class DatasetManager: class DatasetManager: