diff --git a/wetb/hawc2/htc_file.py b/wetb/hawc2/htc_file.py index fc51e0768152a51d46cc18532768cc34f0d42ba2..b5ad46c51b68c8e9449c654a8da59bd658d33b0d 100644 --- a/wetb/hawc2/htc_file.py +++ b/wetb/hawc2/htc_file.py @@ -14,7 +14,7 @@ from io import open from builtins import str from future import standard_library from wetb.utils.process_exec import pexec -from wetb.utils.cluster_tools.cluster_resource import unix_path +from wetb.utils.cluster_tools.cluster_resource import unix_path, unix_path_old standard_library.install_aliases() from collections import OrderedDict @@ -104,7 +104,7 @@ class HTCFile(HTCContents, HTCDefaults): def readfilelines(self, filename): - with open(unix_path(filename), encoding='cp1252') as fid: + with open(unix_path_old(filename), encoding='cp1252') as fid: lines = list(fid.readlines()) if lines[0].encode().startswith(b'\xc3\xaf\xc2\xbb\xc2\xbf'): lines[0] = lines[0][3:] diff --git a/wetb/utils/cluster_tools/cluster_resource.py b/wetb/utils/cluster_tools/cluster_resource.py index aea4f8df24ee74610926f0ea66e8d19b8c14857e..78ed0f1356555b9535ed5e0e05c87c383654aa9b 100644 --- a/wetb/utils/cluster_tools/cluster_resource.py +++ b/wetb/utils/cluster_tools/cluster_resource.py @@ -42,18 +42,19 @@ def unix_path(path, cwd=None, fail_on_missing=False): path+="/" return path.replace("\\","/") -# filename = os.path.realpath(filename.replace("\\", "/")).replace("\\", "/") -# ufn, rest = os.path.splitdrive(filename) -# ufn += "/" -# for f in rest[1:].split("/"): -# f_lst = [f_ for f_ in os.listdir(ufn) if f_.lower() == f.lower()] -# if len(f_lst) > 1: -# f_lst = [f_ for f_ in f_lst if f_ == f] -# elif len(f_lst) == 0: -# raise IOError("'%s' not found in '%s'" % (f, ufn)) -# else: # one match found -# ufn = os.path.join(ufn, f_lst[0]) -# return ufn.replace("\\", "/") +def unix_path_old(filename): + filename = os.path.realpath(filename.replace("\\", "/")).replace("\\", "/") + ufn, rest = os.path.splitdrive(filename) + ufn += "/" + for f in rest[1:].split("/"): + f_lst = [f_ for f_ in os.listdir(ufn) if f_.lower() == f.lower()] + if len(f_lst) > 1: + f_lst = [f_ for f_ in f_lst if f_ == f] + elif len(f_lst) == 0: + raise IOError("'%s' not found in '%s'" % (f, ufn)) + else: # one match found + ufn = os.path.join(ufn, f_lst[0]) + return ufn.replace("\\", "/")