Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pyinstaller_fail = True
cs.start() # Capture stderr so PyInstaller output can be send to UI
sys.argv = shlex.split(command) + extra_args # Put command into sys.argv and extra args
try:
eel.addOutput("Executing: {0}\n".format(command))
pyi.run() # Execute PyInstaller
pyinstaller_fail = False
except:
eel.addOutput("An error occurred, traceback follows:\n")
eel.addOutput(traceback.format_exc())
cs.stop() # Stop stderr capture
# Move project if there was no failure
if pyinstaller_fail:
eel.addOutput("\n")
eel.addOutput("Project output will not be moved to output folder\n")
else:
output_directory = os.path.abspath(output) # Use absolute directories
eel.addOutput("Moving project to: {0}\n".format(output_directory))
try:
move_project(dist_path, output_directory)
except:
eel.addOutput("Failed to move project, traceback follows:\n")
eel.addOutput(traceback.format_exc())
eel.addOutput("Complete.\n")
eel.outputComplete()
# Run PyInstaller
pyinstaller_fail = True
cs.start() # Capture stderr so PyInstaller output can be send to UI
sys.argv = shlex.split(command) + extra_args # Put command into sys.argv and extra args
try:
eel.addOutput("Executing: {0}\n".format(command))
pyi.run() # Execute PyInstaller
pyinstaller_fail = False
except:
eel.addOutput("An error occurred, traceback follows:\n")
eel.addOutput(traceback.format_exc())
cs.stop() # Stop stderr capture
# Move project if there was no failure
if pyinstaller_fail:
eel.addOutput("\n")
eel.addOutput("Project output will not be moved to output folder\n")
else:
output_directory = os.path.abspath(output) # Use absolute directories
eel.addOutput("Moving project to: {0}\n".format(output_directory))
try:
move_project(dist_path, output_directory)
except:
eel.addOutput("Failed to move project, traceback follows:\n")
eel.addOutput(traceback.format_exc())
eel.addOutput("Complete.\n")
eel.outputComplete()
def convert(command, output, disable_recursion_limit):
""" Package the executable passing the arguments the user requested """
eel.addOutput("Running auto-py-to-exe v" + version)
# Notify the user of the workspace and setup building to it
eel.addOutput("Building in the current instances temporary directory at {}\n".format(temporary_directory))
eel.addOutput("To get a new temporary directory, restart this application\n")
dist_path = os.path.join(temporary_directory, 'application')
build_path = os.path.join(temporary_directory, 'build')
extra_args = ['--distpath', dist_path] + ['--workpath', build_path] + ['--specpath', temporary_directory]
# If the Recursion Limit is enabled, set it
if not disable_recursion_limit:
sys.setrecursionlimit(5000)
eel.addOutput("Recursion Limit is set to 5000\n")
else:
sys.setrecursionlimit(DEFAULT_RECURSION_LIMIT) # In the case the limit was set and now the user doesn't want it set
# Run PyInstaller
pyinstaller_fail = True
cs.start() # Capture stderr so PyInstaller output can be send to UI
sys.argv = shlex.split(command) + extra_args # Put command into sys.argv and extra args
try:
build_path = os.path.join(temporary_directory, 'build')
extra_args = ['--distpath', dist_path] + ['--workpath', build_path] + ['--specpath', temporary_directory]
# If the Recursion Limit is enabled, set it
if not disable_recursion_limit:
sys.setrecursionlimit(5000)
eel.addOutput("Recursion Limit is set to 5000\n")
else:
sys.setrecursionlimit(DEFAULT_RECURSION_LIMIT) # In the case the limit was set and now the user doesn't want it set
# Run PyInstaller
pyinstaller_fail = True
cs.start() # Capture stderr so PyInstaller output can be send to UI
sys.argv = shlex.split(command) + extra_args # Put command into sys.argv and extra args
try:
eel.addOutput("Executing: {0}\n".format(command))
pyi.run() # Execute PyInstaller
pyinstaller_fail = False
except:
eel.addOutput("An error occurred, traceback follows:\n")
eel.addOutput(traceback.format_exc())
cs.stop() # Stop stderr capture
# Move project if there was no failure
if pyinstaller_fail:
eel.addOutput("\n")
eel.addOutput("Project output will not be moved to output folder\n")
else:
output_directory = os.path.abspath(output) # Use absolute directories
eel.addOutput("Moving project to: {0}\n".format(output_directory))
try:
move_project(dist_path, output_directory)
try:
eel.addOutput("Executing: {0}\n".format(command))
pyi.run() # Execute PyInstaller
pyinstaller_fail = False
except:
eel.addOutput("An error occurred, traceback follows:\n")
eel.addOutput(traceback.format_exc())
cs.stop() # Stop stderr capture
# Move project if there was no failure
if pyinstaller_fail:
eel.addOutput("\n")
eel.addOutput("Project output will not be moved to output folder\n")
else:
output_directory = os.path.abspath(output) # Use absolute directories
eel.addOutput("Moving project to: {0}\n".format(output_directory))
try:
move_project(dist_path, output_directory)
except:
eel.addOutput("Failed to move project, traceback follows:\n")
eel.addOutput(traceback.format_exc())
eel.addOutput("Complete.\n")
eel.outputComplete()
def open_output_folder(folder):
""" Open the folder of there the package was moved to """
folder_directory = os.path.abspath(folder) # Use absolute directories
if platform.system() == 'Windows':
os.startfile(folder_directory, 'explore')
elif platform.system() == 'Linux':
os.system('xdg-open "' + folder_directory + '"')
elif platform.system() == 'Darwin':
os.system('open "' + folder_directory + '"')
else:
eel.addOutput("Unable to open output folder: " + folder_directory)
eel.addOutput("An error occurred, traceback follows:\n")
eel.addOutput(traceback.format_exc())
cs.stop() # Stop stderr capture
# Move project if there was no failure
if pyinstaller_fail:
eel.addOutput("\n")
eel.addOutput("Project output will not be moved to output folder\n")
else:
output_directory = os.path.abspath(output) # Use absolute directories
eel.addOutput("Moving project to: {0}\n".format(output_directory))
try:
move_project(dist_path, output_directory)
except:
eel.addOutput("Failed to move project, traceback follows:\n")
eel.addOutput(traceback.format_exc())
eel.addOutput("Complete.\n")
eel.outputComplete()
except:
eel.addOutput("An error occurred, traceback follows:\n")
eel.addOutput(traceback.format_exc())
cs.stop() # Stop stderr capture
# Move project if there was no failure
if pyinstaller_fail:
eel.addOutput("\n")
eel.addOutput("Project output will not be moved to output folder\n")
else:
output_directory = os.path.abspath(output) # Use absolute directories
eel.addOutput("Moving project to: {0}\n".format(output_directory))
try:
move_project(dist_path, output_directory)
except:
eel.addOutput("Failed to move project, traceback follows:\n")
eel.addOutput(traceback.format_exc())
eel.addOutput("Complete.\n")
eel.outputComplete()
cs.stop() # Stop stderr capture
# Move project if there was no failure
if pyinstaller_fail:
eel.addOutput("\n")
eel.addOutput("Project output will not be moved to output folder\n")
else:
output_directory = os.path.abspath(output) # Use absolute directories
eel.addOutput("Moving project to: {0}\n".format(output_directory))
try:
move_project(dist_path, output_directory)
except:
eel.addOutput("Failed to move project, traceback follows:\n")
eel.addOutput(traceback.format_exc())
eel.addOutput("Complete.\n")
eel.outputComplete()
def write(self, message):
""" When sys.stderr.write is called, it will re directed here """
# Filter pre-defined lines that don't need to be sent
for single_filter in self.filters:
if not single_filter.match(message) is None:
return
if self.ui_started:
# Send making sure there is a newline at the end
if message.endswith('\n'):
eel.addOutput(message)
else:
eel.addOutput(message + '\n')
else:
self.original.write(message)
self.original.flush()