Skip to content
Snippets Groups Projects
Commit 606d1287 authored by Karim Ahmed's avatar Karim Ahmed
Browse files

Merge branch 'feat/get_ts_from_oldest_file' into 'master'

feat/get_oldest_file's_timestamp

See merge request detectors/pycalibration!115
parents 07d41311 2e5827e9
No related branches found
No related tags found
1 merge request!115feat/get_oldest_file's_timestamp
......@@ -425,16 +425,23 @@ def get_notebook_name():
return environ.get("CAL_NOTEBOOK_NAME", "Unknown Notebook")
def get_dir_creation_date(directory, run):
def get_dir_creation_date(directory, run, tsdir=False):
"""
Return modification time of [directory]/[run]04
Return modification time of oldest file.h5 in [directory]/[run]04
:param directory: path to directory which contains runs
:param run: run number
:param tsdir: to get modification time of [directory]/[run]04.
:return: (datetime) modification time
"""
creation_time = stat("{}/r{:04d}".format(directory, run)).st_mtime
creation_time = datetime.datetime.fromtimestamp(creation_time)
if tsdir:
creation_time = stat("{}/r{:04d}".format(directory, run)).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)
return creation_time
......
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