Skip to content

Commit

Permalink
Stage 1, create job file for listener to read
Browse files Browse the repository at this point in the history
Issue #133
  • Loading branch information
damies13 committed Aug 20, 2023
1 parent 17325fb commit 408296a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions rfswarm_agent/rfswarm_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,23 @@ def runthread(self, jobid):

self.jobs[jobid]["Iteration"] += 1

self.debugmsg(9, "self.jobs[jobid]:", self.jobs[jobid])

# jobfile = os.path.join(self.scriptdir, "job_{}.json".format(jobid))
jobfile = os.path.join(self.scriptdir, "job_{}_{}.json".format(self.jobs[jobid]["ScriptIndex"], self.jobs[jobid]["Robot"]))

jobdata = {}
jobdata["StartTime"] = self.jobs[jobid]["StartTime"]
jobdata["EndTime"] = self.jobs[jobid]["EndTime"]
jobdata["Iteration"] = self.jobs[jobid]["Iteration"]
jobdata["Index"] = self.jobs[jobid]["ScriptIndex"]
jobdata["Robot"] = self.jobs[jobid]["Robot"]
jobdata["jobid"] = jobid
jobdata["Test"] = self.jobs[jobid]["Test"]

with open(jobfile, 'w') as jfile:
jfile.write(json.dumps(jobdata))

hash = self.jobs[jobid]['ScriptHash']
self.debugmsg(6, "runthread: hash:", hash)
test = self.jobs[jobid]['Test']
Expand Down Expand Up @@ -896,6 +913,7 @@ def runthread(self, jobid):

result = 0
try:
os.chdir(self.scriptdir)
# https://stackoverflow.com/questions/4856583/how-do-i-pipe-a-subprocess-call-to-a-text-file
with open(logFileName, "w") as f:
self.debugmsg(3, "Robot run with command: '", " ".join(cmd), "'")
Expand All @@ -915,6 +933,9 @@ def runthread(self, jobid):
result = 1
f.close()

if os.path.exists(jobfile):
os.remove(jobfile)

if self.xmlmode:
if os.path.exists(outputFile):
if self.xmlmode:
Expand Down

0 comments on commit 408296a

Please sign in to comment.