Skip to content
Snippets Groups Projects
Commit 9808a8d9 authored by Daniel Lyons's avatar Daniel Lyons
Browse files

Make vulture resolve scripts adjacent to the condor submit file

parent 9159114a
No related branches found
No related tags found
1 merge request!118Vulture: allow empty arguments
Pipeline #821 passed
executable = test.sh
arguments = hello
queue
\ No newline at end of file
#!/bin/sh
echo $*
......@@ -56,6 +56,16 @@ def test_job_stdout():
os.remove("null.error")
def test_shell_script_in_working_directory(caplog):
test_job = Job("test/localscript.condor")
test_job.execute()
with open("test.sh.out", "r") as f:
contents = f.read()
assert "hello" in contents
os.remove("test.sh.out")
os.remove("test.sh.error")
def test_job_stderr():
"""
Test that vulture writes correct output from stderr to a log file
......
......@@ -133,6 +133,7 @@ class Job:
:param write_log: Boolean that determines whether a log file will be written
"""
self.fields, self.command = self.parse(file)
self.job_directory = Path(file).resolve().parent
self.write_log = write_log
if self.write_log:
if self.fields.get("executable"):
......@@ -216,8 +217,19 @@ class Job:
# Execute
if self.fields.get("executable"):
# So there is a thing that can happen here, where the condor file refers to a script in the same directory
# HTCondor will happily execute such a thing, but using subprocess.run like this will not. So we have to
# detect if there is a file in the current directory with the same name as the executable, and if there is,
# we must prefix with "./" to get the right behavior.
if (self.job_directory / self.fields["executable"]).exists():
executable = str(
(self.job_directory / self.fields["executable"]).resolve()
)
else:
executable = self.fields["executable"]
process = subprocess.run(
[self.fields["executable"], self.fields["arguments"]],
[executable, self.fields["arguments"]],
capture_output=capture_output,
text=True,
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment