Skip to content

Commit

Permalink
Fix error during creation of exe by setting stdin to subprocess.DEVNULL
Browse files Browse the repository at this point in the history
  • Loading branch information
MyNameIsTrez committed Mar 16, 2022
1 parent 929fa2b commit 22ce061
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Python/stylua.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def run(input_folder_path, output_folder_path):
elif os.name == "posix": # If the OS is Linux
stylua_path = utils.path("Lib/stylua/Linux/stylua")

result = subprocess.run([stylua_path, output_path], capture_output=True, text=True)
# Setting stdin to subprocess.DEVNULL is necessary for the EXE not to throw "OSError: [WinError 6] The handle is invalid"
result = subprocess.run([stylua_path, output_path], capture_output=True, text=True, stdin=subprocess.DEVNULL)

if result.stderr:
raise WronglyFormattedLuaFile(result.stderr)
Expand Down
5 changes: 4 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Run manually: python main.py
# Build EXE: pyinstaller --noconsole --onefile --icon="Media/legacy-mod-converter.ico" --add-data="Media/github-icon.png;Media" --add-data="Media/discord-icon.png;Media" --add-data="Media/finish.wav;Media" --name="Legacy Mod Converter" main.py

# This is giving the error `pyinstaller: error: argument --add-binary: invalid add_data_or_binary value: 'Lib/stylua/Linux/stylua:Lib/stylua/Linux'`
# Build EXE: pyinstaller --noconsole --onefile --icon="Media/legacy-mod-converter.ico" --add-data="Media/github-icon.png;Media" --add-data="Media/discord-icon.png;Media" --add-data="Media/finish.wav;Media" --add-binary="Lib/stylua/Linux/stylua:Lib/stylua/Linux" --add-data="Lib/stylua/Windows/stylua.exe;Lib/stylua/Windows" --name="Legacy Mod Converter" main.py

# Build EXE: pyinstaller --noconsole --onefile --icon="Media/legacy-mod-converter.ico" --add-data="Media/github-icon.png;Media" --add-data="Media/discord-icon.png;Media" --add-data="Media/finish.wav;Media" --add-binary="Lib/stylua/Windows/stylua.exe;Lib/stylua/Windows" --name="Legacy Mod Converter" main.py

import traceback
import PySimpleGUI as sg
Expand Down

0 comments on commit 22ce061

Please sign in to comment.