Skip to content
Snippets Groups Projects

feat/get_oldest_file's_timestamp

Merged Karim Ahmed requested to merge feat/get_ts_from_oldest_file into master
1 file
+ 11
4
Compare changes
  • Side-by-side
  • Inline
@@ -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
Loading