I have robot files inside a directory I need to run all the robot file inside it in sorted order.
Below is my code. is it right code or Can we do multithreading for this
import robot
import os
_files = []
for (dirname,dirs,files) in os.walk('.'):
for filename in files:
if filename.endswith('.robot'):
_files.append(filename)
print (sorted(_files))
s = sorted(_files)
for i in s:
robot.run(s)
Try Pabot it's a parallel executor.
Install pabot:
pip install -U robotframework-pabot
Example for usage:
pabot test_directory
UPDATE: Also you can use that command line and execute it from python:
pabot --argumentfile1 arg1.txt --argumentfile2 arg2.txt
To build this command line use that code:
"""your code here..."""
res = ["pabot"]
i = 0
for filename in s:
i+=1
res.append("--argumentfile{} {}".format(i, filename))
exec_line = ' '.join(res)
os.system(exec_line)