Skip to content

Commit 39f8b2b

Browse files
Merge pull request #79 from thecuriousneutrino/master
IN2P3 SEs have been updated, and error handling of the get_SE method improved
2 parents 135dce0 + 2971196 commit 39f8b2b

3 files changed

Lines changed: 33 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9-
Nothing
9+
### Fixed
10+
- Basepath string for IN2P3-CC-XRD-tape and IN2P3-CC-XRD-disk is corrected (// is replaced with / for an exact string match with the host name string).
11+
- BackendException for cases where the get_SE method returns None because the host name string is not contained inside the file URL are added.
1012

1113
## [1.17.5] - 2022-02-26
1214
### Changed

t2kdm/backends.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,10 +1009,20 @@ def _replicate(self, source_surl, destination_surl, lurl, verbose=False, **kwarg
10091009
else:
10101010
out = None
10111011

1012-
source = storage.get_SE(source_surl).name
1013-
destination = storage.get_SE(destination_surl).name
1012+
source = storage.get_SE(source_surl)
1013+
if source is None:
1014+
raise BackendException(
1015+
"Could not find storage element with host name string contained inside %s."
1016+
% (source_surl)
1017+
)
1018+
destination = storage.get_SE(destination_surl)
1019+
if destination is None:
1020+
raise BackendException(
1021+
"Could not find storage element with host name string contained inside %s."
1022+
% (destination_surl)
1023+
)
10141024
try:
1015-
self._replicate_cmd(lurl, destination, source, _out=out, **kwargs)
1025+
self._replicate_cmd(lurl, destination.name, source.name, _out=out, **kwargs)
10161026
except sh.ErrorReturnCode as e:
10171027
if "No such file" in str(e.stderr):
10181028
raise DoesNotExistException("No such file or directory.")
@@ -1048,10 +1058,15 @@ def _put(self, localpath, surl, lurl, verbose=False, **kwargs):
10481058
out = sys.stdout
10491059
else:
10501060
out = None
1051-
se = storage.get_SE(surl).name
1061+
se = storage.get_SE(surl)
1062+
if se is None:
1063+
raise BackendException(
1064+
"Could not find storage element with host name string contained inside %s."
1065+
% (surl)
1066+
)
10521067

10531068
try:
1054-
self._add_cmd(lurl, localpath, se, _out=out, **kwargs)
1069+
self._add_cmd(lurl, localpath, se.name, _out=out, **kwargs)
10551070
except sh.ErrorReturnCode as e:
10561071
if "No such file" in str(e.stderr):
10571072
raise DoesNotExistException("No such file or directory.")
@@ -1063,7 +1078,12 @@ def _put(self, localpath, surl, lurl, verbose=False, **kwargs):
10631078
return True
10641079

10651080
def _remove(self, surl, lurl, last=False, verbose=False, **kwargs):
1066-
se = storage.get_SE(surl).name
1081+
se = storage.get_SE(surl)
1082+
if se is None:
1083+
raise BackendException(
1084+
"Could not find storage element with host name string contained inside %s."
1085+
% (surl)
1086+
)
10671087

10681088
if last:
10691089
# Delete lfn
@@ -1072,8 +1092,8 @@ def _remove(self, surl, lurl, last=False, verbose=False, **kwargs):
10721092
ret = self.dm.removeFile([lurl])
10731093
else:
10741094
if verbose:
1075-
print_("Removing replica of %s from %s." % (lurl, se))
1076-
ret = self.dm.removeReplica(se, [lurl])
1095+
print_("Removing replica of %s from %s." % (lurl, se.name))
1096+
ret = self.dm.removeReplica(se.name, [lurl])
10771097

10781098
if not ret["OK"]:
10791099
raise BackendException("Failed: %s" % (ret["Message"]))

t2kdm/storage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,15 @@ def __str__(self):
241241
type="disk",
242242
location="/europe/fr/in2p3",
243243
directpath="root://ccxrdrli04.in2p3.fr:1097/xrootd/in2p3.fr/disk/t2k.org",
244-
basepath="root://ccxrdrli04.in2p3.fr:1097//xrootd/in2p3.fr/disk/t2k.org",
244+
basepath="root://ccxrdrli04.in2p3.fr:1097/xrootd/in2p3.fr/disk/t2k.org",
245245
),
246246
StorageElement(
247247
"IN2P3-CC-XRD-tape",
248248
host="ccxrdrli04.in2p3.fr:1097/xrootd/in2p3.fr/tape",
249249
type="tape",
250250
location="/europe/fr/in2p3",
251251
directpath="root://ccxrdrli04.in2p3.fr:1097/xrootd/in2p3.fr/tape/t2k.org",
252-
basepath="root://ccxrdrli04.in2p3.fr:1097//xrootd/in2p3.fr/tape/t2k.org",
252+
basepath="root://ccxrdrli04.in2p3.fr:1097/xrootd/in2p3.fr/tape/t2k.org",
253253
),
254254
StorageElement(
255255
"IN2P3-CC-disk",

0 commit comments

Comments
 (0)