Skip to content
Snippets Groups Projects
Commit 9177a0fc authored by Steffen Hauf's avatar Steffen Hauf
Browse files

Backpropagate cal_tools

See merge request detectors/pycalibration!119
parents f0477fa2 e81d4334
No related branches found
No related tags found
1 merge request!119Backpropagate cal_tools
...@@ -434,15 +434,20 @@ def get_dir_creation_date(directory, run, tsdir=False): ...@@ -434,15 +434,20 @@ def get_dir_creation_date(directory, run, tsdir=False):
:param tsdir: to get modification time of [directory]/[run]04. :param tsdir: to get modification time of [directory]/[run]04.
:return: (datetime) modification time :return: (datetime) modification time
""" """
if tsdir: ntries = 100
creation_time = stat("{}/r{:04d}".format(directory, run)).st_mtime while ntries > 0:
else: try:
rfiles = glob("{}/r{:04d}/*.h5".format(directory, run)) if tsdir:
rfiles.sort(key=path.getmtime) creation_time = stat("{}/r{:04d}".format(directory, run)).st_mtime
creation_time = stat(rfiles[0]).st_mtime else:
rfiles = glob("{}/r{:04d}/*.h5".format(directory, run))
rfiles.sort(key=path.getmtime)
creation_time = stat(rfiles[0]).st_mtime
creation_time = datetime.datetime.fromtimestamp(creation_time) creation_time = datetime.datetime.fromtimestamp(creation_time)
return creation_time return creation_time
except: # catch stale file handle errors etc and try again
ntries -= 1
def get_random_db_interface(cal_db_interface): def get_random_db_interface(cal_db_interface):
...@@ -500,7 +505,6 @@ def get_from_db(device, constant, condition, empty_constant, ...@@ -500,7 +505,6 @@ def get_from_db(device, constant, condition, empty_constant,
metadata.calibration_constant_version = Versions.Timespan( metadata.calibration_constant_version = Versions.Timespan(
device=device, device=device,
start=creation_time) start=creation_time)
while ntries > 0: while ntries > 0:
this_interface = get_random_db_interface(cal_db_interface) this_interface = get_random_db_interface(cal_db_interface)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment