Skip to content

Commit

Permalink
Merge branch 'v1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
damies13 committed Mar 3, 2023
2 parents cd3adff + 97e44ea commit 7206c4e
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 28 deletions.
51 changes: 51 additions & 0 deletions Tests/Demo/rfswarm_demo.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
*** Settings ***
Documentation This Demo Test is for demonstrating and troubleshooting RFSwarm,
... It's known to work on any OS and only requires robot framework installed, no other libraries
... It also demonstrates the custom variables created by RFSwarm
Library OperatingSystem
*** Variables ***
${PATH} ${CURDIR}/example.txt
${alpha} abcdefghijklmnopqrstuvwxyz
${alpha10} ${alpha * 10}
${alpha100} ${alpha10 * 10}
${alpha1k} ${alpha100 * 10}
${FPATH} ${CURDIR}/Robot_${RFS_ROBOT}
*** Test Cases ***
RFSwarm Demo Test
# Create File ${PATH} Some text
# File Should Exist ${PATH}
# Copy File ${PATH} ~/file.txt
Create Some Files
Sleep 5
List Some Files
Sleep 5
Remove Some Files
Sleep 5
*** Keywords ***
Create Some Files
[Documentation] Create Some Files
Create Directory ${FPATH}
FOR ${i} IN RANGE 100
Create File ${FPATH}/I${RFS_ITERATION}_i${i}_test.txt ${alpha1k}
END
Wait Until Created ${FPATH}/I${RFS_ITERATION}_i99_test.txt
List Some Files
[Documentation] List Some Files
${FILS}= List Files In Directory ${FPATH}
Remove Some Files
[Documentation] Remove Some Files
Remove Files ${FPATH}/I${RFS_ITERATION}_*_test.txt
Wait Until Removed ${FPATH}/I${RFS_ITERATION}_i99_test.txt
#
146 changes: 121 additions & 25 deletions rfswarm_manager/rfswarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,67 @@ def tick_counter(self):
pass
time.sleep(aday)

def replace_rf_path_variables(self, pathin, localdir):
base.debugmsg(8, "pathin:", pathin)
base.debugmsg(8, "localdir:", localdir)
pathout = pathin
base.debugmsg(8, "pathout:", pathout)

# Issue #129 Handle `${CURDIR}/`
if pathout.find("${CURDIR}") >-1:
pathmod = pathout.replace("${CURDIR}", "")
base.debugmsg(8, "pathmod:", pathmod)
# https://stackoverflow.com/questions/1945920/why-doesnt-os-path-join-work-in-this-case
if platform.system() == "Windows":
pathmod = pathmod.replace("/", os.path.sep)
base.debugmsg(8, "pathmod:", pathmod)
pathout = os.path.abspath(os.path.join(localdir, *pathmod.split(os.path.sep)))
else:
pathout = os.path.abspath(os.path.join(os.path.sep, *localdir.split(os.path.sep), *pathmod.split(os.path.sep)))
base.debugmsg(8, "pathout:", pathout)

# Built-in variables - https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#built-in-variables

# ${TEMPDIR}
if pathout.find("${TEMPDIR}") >-1:
tmpdir = tempfile.gettempdir()
pathout = pathout.replace("${TEMPDIR}", tmpdir)
base.debugmsg(8, "pathout:", pathout)

# ${EXECDIR}
# not sure how to handle this for now

# ${/}
if pathout.find("${/}") >-1:
if pathout.find("${/}") == 0:
pathlst = "${rfpv}"+pathout.split("${/}")
pathjoin = os.path.join(*pathlst)
base.debugmsg(8, "pathlst:", pathlst)
base.debugmsg(8, "pathjoin:", pathjoin)
pathjoin = pathjoin.replace("${rfpv}", "")
base.debugmsg(8, "pathjoin:", pathjoin)
else:
pathlst = "${rfpv}"+pathout.split("${/}")
pathjoin = os.path.join(*pathlst)
base.debugmsg(8, "pathlst:", pathlst)
base.debugmsg(8, "pathjoin:", pathjoin)

if os.path.isfile(pathjoin):
pathout = pathjoin
base.debugmsg(8, "pathout:", pathout)
else:
# i guess this could be affected too https://stackoverflow.com/questions/1945920/why-doesnt-os-path-join-work-in-this-case
if platform.system() == "Windows":
pathout = os.path.abspath(os.path.join(*localdir.split(os.path.sep), *pathjoin.split(os.path.sep)))
else:
pathout = os.path.abspath(os.path.join(os.path.sep, *localdir.split(os.path.sep), *pathjoin.split(os.path.sep)))
base.debugmsg(8, "pathout:", pathout)

# ${:}
# ${\n}
# not sure whether to handle these for now

return pathout

def find_dependancies(self, hash):
keep_going = True
Expand Down Expand Up @@ -1311,15 +1371,25 @@ def find_dependancies(self, hash):
if resfile:
base.debugmsg(7, "resfile", resfile)
# here we are assuming the resfile is a relative path! should we also consider files with full local paths?
localrespath = os.path.abspath(os.path.join(localdir, resfile))
base.debugmsg(8, "localrespath", localrespath)
# Issue #129 Handle ``${CURDIR}/``
if resfile.find("${") >-1:
localrespath = base.replace_rf_path_variables(resfile, localdir)
else:
# i guess this could be affected too https://stackoverflow.com/questions/1945920/why-doesnt-os-path-join-work-in-this-case
if platform.system() == "Windows":
localrespath = os.path.abspath(os.path.join(*localdir.split(os.path.sep), *resfile.split(os.path.sep)))
else:
localrespath = os.path.abspath(os.path.join(os.path.sep, *localdir.split(os.path.sep), *resfile.split(os.path.sep)))
base.debugmsg(7, "localrespath", localrespath)
if os.path.isfile(localrespath):
newhash = self.hash_file(localrespath, resfile)
relfile = os.path.relpath(localrespath, start=localdir)
base.debugmsg(7, "relfile", relfile)
newhash = self.hash_file(localrespath, relfile)
base.debugmsg(7, "newhash", newhash)
self.scriptfiles[newhash] = {
'id': newhash,
'localpath': localrespath,
'relpath': resfile,
'relpath': relfile,
'type': linearr[0]
}

Expand Down Expand Up @@ -1700,16 +1770,24 @@ def SaveRunStats_SQL(self):
def report_text(self, _event=None):
base.debugmsg(6, "report_text")
colno = 0
while_cnt=0
while_max=100
filecount = 0
base.debugmsg(6, "RunStats")
base.debugmsg(6, "UpdateRunStats_SQL")
base.UpdateRunStats_SQL()
if "RunStats" not in base.dbqueue["ReadResult"]:
base.debugmsg(6, "Wait for RunStats")
while "RunStats" not in base.dbqueue["ReadResult"]:
time.sleep(0.1)
base.debugmsg(6, "Wait for RunStats>0")
while len(base.dbqueue["ReadResult"]["RunStats"])<1:
time.sleep(0.1)
if base.args.nogui:
if "RunStats" not in base.dbqueue["ReadResult"]:
base.debugmsg(6, "Wait for RunStats")
while_cnt = while_max
while "RunStats" not in base.dbqueue["ReadResult"] and while_cnt>0:
time.sleep(0.1)
while_cnt-=1
base.debugmsg(6, "Wait for RunStats>0")
while_cnt = while_max
while len(base.dbqueue["ReadResult"]["RunStats"])<1 and while_cnt>0:
time.sleep(0.1)
while_cnt-=1


if "RunStats" in base.dbqueue["ReadResult"] and len(base.dbqueue["ReadResult"]["RunStats"])>0:
Expand Down Expand Up @@ -1753,15 +1831,19 @@ def report_text(self, _event=None):
rowdata = row.values()
writer.writerow(rowdata)

if not base.args.nogui:
tkm.showinfo("RFSwarm - Info", "Report data saved to: {}".format(base.datapath))
filecount += 1

base.debugmsg(6, "Wait for Agents")
while "Agents" not in base.dbqueue["ReadResult"]:
time.sleep(0.1)
base.debugmsg(6, "Wait for Agents>0")
while len(base.dbqueue["ReadResult"]["Agents"])<1:
time.sleep(0.1)
if base.args.nogui:
while_cnt = while_max
base.debugmsg(6, "Wait for Agents")
while "Agents" not in base.dbqueue["ReadResult"] and while_cnt>0:
time.sleep(0.1)
while_cnt-=1
base.debugmsg(6, "Wait for Agents>0")
while_cnt = while_max
while len(base.dbqueue["ReadResult"]["Agents"])<1 and while_cnt>0:
time.sleep(0.1)
while_cnt-=1

if "Agents" in base.dbqueue["ReadResult"] and len(base.dbqueue["ReadResult"]["Agents"])>0:
fileprefix = base.run_name
Expand All @@ -1785,13 +1867,19 @@ def report_text(self, _event=None):
rowdata = row.values()
writer.writerow(rowdata)

filecount += 1

base.debugmsg(6, "Wait for RawResults")
while "RawResults" not in base.dbqueue["ReadResult"]:
time.sleep(0.1)
base.debugmsg(6, "Wait for RawResults>0")
while len(base.dbqueue["ReadResult"]["RawResults"])<1:
time.sleep(0.1)
if base.args.nogui:
base.debugmsg(6, "Wait for RawResults")
while_cnt = while_max
while "RawResults" not in base.dbqueue["ReadResult"] and while_cnt>0:
time.sleep(0.1)
while_cnt-=1
base.debugmsg(6, "Wait for RawResults>0")
while_cnt = while_max
while len(base.dbqueue["ReadResult"]["RawResults"])<1 and while_cnt>0:
time.sleep(0.1)
while_cnt-=1

if "RawResults" in base.dbqueue["ReadResult"] and len(base.dbqueue["ReadResult"]["RawResults"])>0:
fileprefix = base.run_name
Expand All @@ -1815,6 +1903,14 @@ def report_text(self, _event=None):
rowdata = row.values()
writer.writerow(rowdata)

filecount += 1

if not base.args.nogui:
if filecount>0:
tkm.showinfo("RFSwarm - Info", "Report data saved to: {}".format(base.datapath))
else:
tkm.showwarning("RFSwarm - Warning", "No report data to save.")

def create_metric(self, MetricName, MetricType):
# Save Metric Data
# First ensure a metric for this agent exists
Expand Down
2 changes: 1 addition & 1 deletion rfswarm_reporter/rfswarm_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def report_new_section(self, parent, name):
while id in base.report:
time.sleep(0.1)
id = "{:02X}".format(int(time.time()*10000))

base.debugmsg(7, "id:", id)
self.report_add_section(parent, id, name)
# base.report_save() # report_set_order in report_add_section will save
Expand Down
2 changes: 1 addition & 1 deletion setup-manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# I needed a recent version of pip (pip 21.0.1 worked my previous <20 version didn't) for matplotlib
# to actually install withput error
# https://matplotlib.org/stable/users/installing.html
install_requires=['configparser', 'HTTPServer', 'pillow', 'psutil', 'pip>=21,>=22', 'matplotlib'],
install_requires=['configparser', 'HTTPServer', 'pillow>=9.1.0', 'psutil', 'pip>=21,>=22', 'matplotlib', 'requests'],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Topic :: Software Development :: Testing",
Expand Down
2 changes: 1 addition & 1 deletion setup-reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# https://matplotlib.org/stable/users/installing.html
# zoneinfo requires python 3.9
# tzlocal is needed to get the local timezone in a format that zoneinfo likes
install_requires=['configparser', 'pillow', 'pip>=21,>=22', 'matplotlib', 'python-docx', 'openpyxl', 'tzlocal>=4.1'],
install_requires=['configparser', 'pillow>=9.1.0', 'pip>=21,>=22', 'matplotlib', 'python-docx', 'openpyxl', 'tzlocal>=4.1'],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Topic :: Software Development :: Testing",
Expand Down

0 comments on commit 7206c4e

Please sign in to comment.