From b6651647c8b1e6d7cdd6d822cec3e9ac0fd22deb Mon Sep 17 00:00:00 2001 From: Daniel K Lyons <dlyons@nrao.edu> Date: Thu, 4 Mar 2021 14:08:18 -0700 Subject: [PATCH] Show the state pattern (untested) --- .../vulture/test/missing_arguments.condor | 4 ++++ apps/cli/executables/vulture/test/test_vulture.py | 14 ++++++++++++++ apps/cli/executables/vulture/vulture/condorlite.py | 13 ++++++++----- 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 apps/cli/executables/vulture/test/missing_arguments.condor diff --git a/apps/cli/executables/vulture/test/missing_arguments.condor b/apps/cli/executables/vulture/test/missing_arguments.condor new file mode 100644 index 000000000..ec7ef0930 --- /dev/null +++ b/apps/cli/executables/vulture/test/missing_arguments.condor @@ -0,0 +1,4 @@ +executable = echo +arguments = + +queue diff --git a/apps/cli/executables/vulture/test/test_vulture.py b/apps/cli/executables/vulture/test/test_vulture.py index c987b2d78..0d28946ef 100644 --- a/apps/cli/executables/vulture/test/test_vulture.py +++ b/apps/cli/executables/vulture/test/test_vulture.py @@ -56,6 +56,20 @@ def test_job_stdout(): os.remove("null.error") +def test_missing_arguments(): + """ + Test that vulture can handle a blank arguments + """ + test_job = Job("test/missing_arguments.condor") + test_job.execute() + with open("echo.out", "r") as f: + contents = f.read() + assert contents == "\n\n" + # Clean up output files + os.remove("echo.out") + os.remove("echo.error") + + def test_shell_script_in_working_directory(caplog): test_job = Job("test/localscript.condor") test_job.execute() diff --git a/apps/cli/executables/vulture/vulture/condorlite.py b/apps/cli/executables/vulture/vulture/condorlite.py index ab3724735..8ea4a880b 100644 --- a/apps/cli/executables/vulture/vulture/condorlite.py +++ b/apps/cli/executables/vulture/vulture/condorlite.py @@ -170,10 +170,10 @@ class Job: with open(file, "r") as f: # Split file into fields and command for line in f.readlines(): - if re.search(r" = ", line): - fields.append(line.rstrip()) + if re.search(r"=", line): + fields.append(line.strip()) else: - command = line.rstrip() + command = line.strip() except IOError as e: print(f"ERROR: Could not open/read '{file}'.") sys.exit(1) @@ -196,8 +196,11 @@ class Job: """ field_dict = {} for field in fields: - key, value = field.split(" = ") - field_dict[key] = value + # Sometimes there is no value on the other side of the equals sign + # e.g.: arguments = + # This is legal for HTCondor + parts = field.split("=") + field_dict[parts[0].strip()] = parts[1].strip() if len(parts) > 1 else "" return field_dict def execute(self): -- GitLab