Skip to content

Commit

Permalink
startup checks on start.py
Browse files Browse the repository at this point in the history
checks for which command should the startup srcipt use for launching

for example sometimes python launches with python3 or python, so the check just fixes that issue for most platforms
  • Loading branch information
legitbox authored Oct 28, 2023
1 parent dd492bc commit 91813b5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,19 @@
# @link http://www.PieMC-Dev.github.io/

import subprocess
def check_python_version():
try:
# Attempt to run the 'python' command and check if it's available
subprocess.check_output('python --version', shell=True)
return 'python'
except subprocess.CalledProcessError:
try:
# Attempt to run the 'python3' command and check if it's available
subprocess.check_output('python3 --version', shell=True)
return 'python3'
except subprocess.CalledProcessError:
raise Exception("Neither 'python' nor 'python3' found in your system.")

selected_python_command = check_python_version()
print(f"launching with the command: {selected_python_command}")
subprocess.call(['python', '-m', 'piemc'])

0 comments on commit 91813b5

Please sign in to comment.