Commit 17833123 authored by Brown, Joshua's avatar Brown, Joshua
Browse files

Simplify functions some more and formatting

parent 364e6958
Pipeline #267547 failed with stage
......@@ -612,7 +612,7 @@ def test_globus_process_from_esnet():
os.remove(abs_path_destination)
if globus_plugin.check(package):
result = globus_plugin.process(package)
globus_plugin.process(package)
# After processing we should verify that the file exists at the final location
assert os.path.exists(abs_path_destination)
......
......@@ -21,6 +21,49 @@ import re
import shutil
def checkTransferEndpoint(action_package: dict) -> (bool, str):
"""Makes sure each item to be transferred has the correct format
:Example:
>>> "items": [
>>> { "source": {
>>> "type": "globus relative",
>>> "path": "/file1.txt"
>>> },
>>> "destination": {
>>> "type": "globus relative",
>>> "path": "dest/file1.txt"
>>> }
>>> },
>>> { "source": {
>>> "type": "globus relative",
>>> "path": "/file2.txt"
>>> },
>>> "destination": {
>>> "type": "globus relative",
>>> "path": "dest/file2.txt"
>>> }
>>> }
>>> ]
"""
for item in action_package["items"]:
if "source" not in item:
return False, "'source' missing from 'items' in 'transfer'"
else:
valid, msg = checkEndpoint(item["source"], ["globus relative"])
if not valid:
return (False, "Error in source\n" + msg)
if "destination" not in item:
return False, "'destination' missing from 'items' in 'transfer'"
else:
valid, msg = checkEndpoint(item["destination"], ["globus relative"])
if not valid:
return (False, "Error in destination\n" + msg)
return True, ""
def getMappedCollections(config: dict) -> list[str]:
"""Returns a list of the UUIDs that are mapped collections
......@@ -540,22 +583,7 @@ class Globus(Plugin):
synchronous and asynchronous you have specified {action_package['type']}",
)
for item in action_package["items"]:
if "source" not in item:
return False, "'source' missing from 'items' in 'transfer'"
else:
valid, msg = checkEndpoint(item["source"], ["globus relative"])
if not valid:
return (False, "Error in source\n" + msg)
if "destination" not in item:
return False, "'destination' missing from 'items' in 'transfer'"
else:
valid, msg = checkEndpoint(item["destination"], ["globus relative"])
if not valid:
return (False, "Error in destination\n" + msg)
return True, ""
return checkTransferEndpoint(action_package)
def __runMoveToGlobusSanityCheck(self, action_package: dict) -> (bool, str):
supported_source_path_types = ["posix absolute", "posix user home"]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment