diff --git a/wetb/gtsdf/gtsdf.py b/wetb/gtsdf/gtsdf.py index 396695b38dd6e21064531942877119f19cf818a4..b948765bf458e127e669d5ed0cf52f0934256514 100644 --- a/wetb/gtsdf/gtsdf.py +++ b/wetb/gtsdf/gtsdf.py @@ -223,7 +223,9 @@ def save(filename, data, **kwargs): if not filename.lower().endswith('.hdf5'): filename += ".hdf5" - os.makedirs(os.path.dirname(os.path.abspath(filename)), exist_ok=True) + # exist_ok does not exist in Python27 + if not os.path.exists(os.path.dirname(os.path.abspath(filename))): + os.makedirs(os.path.dirname(os.path.abspath(filename)))#, exist_ok=True) f = h5py.File(filename, "w") try: f.attrs["type"] = "General time series data format" diff --git a/wetb/hawc2/htc_file.py b/wetb/hawc2/htc_file.py index 709637c10b40a50b278f2e89febba46140904f37..21427ca894f0b0600b350a3f70fbaef4637e1918 100644 --- a/wetb/hawc2/htc_file.py +++ b/wetb/hawc2/htc_file.py @@ -82,7 +82,9 @@ class HTCFile(HTCContents, HTCDefaults): filename = self.filename else: self.filename = filename - os.makedirs(os.path.dirname(filename), exist_ok=True) + # exist_ok does not exist in Python27 + if not os.path.exists(): + os.makedirs(os.path.dirname(filename))#, exist_ok=True) with open(filename, 'w') as fid: fid.write(str(self)) diff --git a/wetb/hawc2/log_file.py b/wetb/hawc2/log_file.py index 7d051eadc116a6a51908aa70bd9c574d89a96c62..d8cde89f98bb058bb549937dbc1b6c6370bf2d9e 100644 --- a/wetb/hawc2/log_file.py +++ b/wetb/hawc2/log_file.py @@ -67,7 +67,9 @@ class LogFile(object): def __str__(self): return self.txt def clear(self): - os.makedirs(os.path.dirname(self.filename), exist_ok=True) + # exist_ok does not exist in Python27 + if not os.path.exists(os.path.dirname(self.filename)): + os.makedirs(os.path.dirname(self.filename))#, exist_ok=True) with open(self.filename, 'w'): pass self.reset() diff --git a/wetb/hawc2/shear_file.py b/wetb/hawc2/shear_file.py index 03413ab990215a737fa8d65b01eca86c1ecc847d..04a768beb4d20d2832604c2d08f3264aca16c8f0 100644 --- a/wetb/hawc2/shear_file.py +++ b/wetb/hawc2/shear_file.py @@ -51,7 +51,9 @@ def save(filename, y_coordinates, z_coordinates, u=None, v=None, w=None): assert vuw[i].shape == shape, (i, vuw[i].shape, shape) - os.makedirs(os.path.dirname(filename), exist_ok=True) + # exist_ok does not exist in Python27 + if not os.path.exists(os.path.dirname(filename)): + os.makedirs(os.path.dirname(filename))#, exist_ok=True) with open(filename, 'w') as fid: fid.write(" # autogenerated shear file\n") fid.write(" %d %d\n" % (len(y_coordinates), len(z_coordinates))) diff --git a/wetb/hawc2/simulation.py b/wetb/hawc2/simulation.py index db26a980263a6f526a06c3743867de7759b429b9..f4d38e7003da64372460d12e266db75c2720d8ba 100644 --- a/wetb/hawc2/simulation.py +++ b/wetb/hawc2/simulation.py @@ -138,7 +138,9 @@ class Simulation(object): src = os.path.join(self.modelpath, src) for src_file in glob.glob(src): dst = os.path.join(self.tmp_modelpath, os.path.relpath(src_file, self.modelpath)) - os.makedirs(os.path.dirname(dst), exist_ok=True) + # exist_ok does not exist in Python27 + if not os.path.exists(os.path.dirname(dst)): + os.makedirs(os.path.dirname(dst))#, exist_ok=True) shutil.copy(src_file, dst) if not os.path.isfile(dst) or os.stat(dst).st_size != os.stat(src_file).st_size: print ("error copy ", dst) @@ -169,7 +171,9 @@ class Simulation(object): for src_file in glob.glob(src): dst_file = os.path.join(self.modelpath, os.path.relpath(src_file, self.tmp_modelpath)) - os.makedirs(os.path.dirname(dst_file), exist_ok=True) + # exist_ok does not exist in Python27 + if not os.path.exists(os.path.dirname(dst_file)): + os.makedirs(os.path.dirname(dst_file))#, exist_ok=True) if not os.path.isfile(dst_file) or os.path.getmtime(dst_file) != os.path.getmtime(src_file): shutil.copy(src_file, dst_file)