Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

startup checks on start.py #46

Merged
merged 1 commit into from
Oct 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'])