Skip to content

Commit

Permalink
Fix code errors in v3 listener
Browse files Browse the repository at this point in the history
and hopefully v2 listener too
Issue #174
  • Loading branch information
damies13 committed Apr 1, 2024
1 parent 16b9048 commit b1db738
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions rfswarm_agent/rfswarm_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,10 +989,10 @@ def runthread(self, jobid):
metavars.append("RFS_INJECTSLEEP:{}".format(self.jobs[jobid]["injectsleepenabled"]))
if self.str2bool(self.jobs[jobid]["injectsleepenabled"]):
# injectsleepminimum
if "injectsleepminimum" in self.jobs[jobid]
if "injectsleepminimum" in self.jobs[jobid]:
metavars.append("RFS_SLEEPMINIMUM:{}".format(self.jobs[jobid]["injectsleepminimum"]))
# injectsleepmaximum
if "injectsleepmaximum" in self.jobs[jobid]
if "injectsleepmaximum" in self.jobs[jobid]:
metavars.append("RFS_SLEEPMAXIMUM:{}".format(self.jobs[jobid]["injectsleepmaximum"]))

for metavar in metavars:
Expand Down Expand Up @@ -1623,10 +1623,14 @@ def create_V3_listner_file(self):
fd.append(" t = threading.Thread(target=self.send_result, args=(payload,))")
fd.append(" t.start()")
fd.append("")
fd.append(" if str(self.injectsleep).lower in ('true', 't', 'yes', '1'):")
fd.append(" self.debugmsg(7, 'injectsleep: ', self.injectsleep)")
fd.append(" if str(self.injectsleep).lower() in ('true', 't', 'yes', '1'):")
fd.append(" self.debugmsg(8, 'data.to_dict(): ', data.to_dict())")
fd.append(" if 'lineno' in data.to_dict():")
fd.append(" tmeslp = self.randsleep(self.sleepminimum, self.sleepmaximum)")
fd.append(" index = parent.to_dict()['body'].index(data.to_dict())")
fd.append(" self.debugmsg(7, 'tmeslp: ', tmeslp)")
fd.append(" index = data.parent.to_dict()['body'].index(data.to_dict())")
fd.append(" self.debugmsg(7, 'index: ', index)")
fd.append(" data.parent.body.insert(index + 1, running.Keyword('Sleep', [tmeslp, 'Sleep added by RFSwarm']))")
fd.append("")
fd.append(" else:")
Expand All @@ -1636,7 +1640,7 @@ def create_V3_listner_file(self):
fd.append("")
fd.append(" def randsleep(self, min, max):")
fd.append(" isfloat = False")
fd.append(" if "." in str(min) or "." in str(max):")
fd.append(" if '.' in str(min) or '.' in str(max):")
fd.append(" isfloat = True")
fd.append(" if isfloat:")
fd.append(" return random.uniform(float(min), float(max))")
Expand Down Expand Up @@ -1821,8 +1825,10 @@ def create_V2_listner_file(self):
fd.append(" t = threading.Thread(target=self.send_result, args=(payload,))")
fd.append(" t.start()")
fd.append("")
fd.append(" if str(self.injectsleep).lower in ('true', 't', 'yes', '1'):")
fd.append(" self.debugmsg(7, 'injectsleep: ', self.injectsleep)")
fd.append(" if str(self.injectsleep).lower() in ('true', 't', 'yes', '1'):")
fd.append(" tmeslp = self.randsleep(self.sleepminimum, self.sleepmaximum)")
fd.append(" self.debugmsg(7, 'tmeslp: ', tmeslp)")
fd.append(" BuiltIn().run_keyword('Sleep', tmeslp, 'Sleep added by RFSwarm')")
fd.append("")
fd.append(" else:")
Expand All @@ -1832,7 +1838,7 @@ def create_V2_listner_file(self):
fd.append("")
fd.append(" def randsleep(self, min, max):")
fd.append(" isfloat = False")
fd.append(" if "." in str(min) or "." in str(max):")
fd.append(" if '.' in str(min) or '.' in str(max):")
fd.append(" isfloat = True")
fd.append(" if isfloat:")
fd.append(" return random.uniform(float(min), float(max))")
Expand Down

0 comments on commit b1db738

Please sign in to comment.