Generate a .exe with pyinstaller the following command:
pyinstaller --onefile --add-data "index.robot;." --noconsole index.py
but doing so with the flag of --noconsole returns this error Command '['robot','C:Users\\pathl\\index.robot']' returned non-zero exit status 120.
But if I omit the --noconsole flag it does work
The path of my .robot that I pass to the command I get from the following function:
def resource_path(self, relative_path):
try:
base_path = sys._MEIPASS
print("Meipass", base_path)
except:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
And this is the function that generates the error for me
def execute_robot_framework(self, object_key, local_directory):
try:
name_file_ctf = os.path.basename(object_key)
if os.path.exists(self.temp_logs_name):
os.remove(self.temp_logs_name)
logFile = open(self.temp_logs_name, 'w')
subprocess.run(['robot', self.directory_file_robot ], stdout=logFile, check=True)
except Exception as error:
self.log(f" {error}")
print(error)
I also tried this way but I still get an error:
def execute_robot(self):
try:
logFile = open(self.temp_logs_name, 'w')
robot.run(self.directory_file_robot, stdout=logFile)
except Exception as error:
self.log(f" {error}")
print(error)
and with this function I get this error: 'NoneType' object has no attribute 'write'
I wish I could pass the --noconsole flag since I do have a GUI in the script.