Skip to content

Commit

Permalink
fix: exit() doesn't work with pyinstaller binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
kernel-dev committed Mar 30, 2022
1 parent 81cd3c7 commit f4d9f3d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# the program throwing an error if there are missing dependencies
# at the initial start-up phase of the program.
import requests
import sys
from src.info import color_text
from src.cli.ui import clear as clear_screen

Expand Down Expand Up @@ -33,13 +34,13 @@
print(color_text("This program needs an internet connection to run. "
"Please connect to the internet and restart this program.", "red"))
logger.critical("No internet connection found. Exiting OCSysInfo", __file__)
exit(0)
sys.exit(0)
if isinstance(e, PermissionError):
print(color_text("Could not access the required data. "
"Try running this program using elevated privileges.", "red"))
logger.critical("Could not access the required data. Exiting OCSysInfo\n\t"
f"^^^^^^^^{str(e)}", __file__)
exit(0)
sys.exit(0)
else:
raise e
finally:
Expand All @@ -49,4 +50,4 @@
logger.info("Successfully launched OCSysInfo.", __file__)
except KeyboardInterrupt:
logger.info("Exited successfully.", __file__)
exit(0)
sys.exit(0)
6 changes: 3 additions & 3 deletions src/cli/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ def handle(self, vals):
)

self.logger.info("Successfully exited after dumping.\n\n", __file__)
exit(0)
sys.exit(0)

def parse_flags(self, args):
if list(filter(lambda x: "-h" in x.lower(), args)):
self.help()
exit(0)
sys.exit(0)

vals = []

Expand Down Expand Up @@ -247,7 +247,7 @@ def prompts(self):
return self.prompts()

if not self.interactive:
exit(0)
sys.exit(0)

def prompt(self, missing, again=False):
if missing.get("Type") == "UNKNOWN":
Expand Down
2 changes: 1 addition & 1 deletion src/cli/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def dump_plist(self):
def quit(self):
clear()
self.logger.info("Successfully exited.\n\n")
exit(0)
sys.exit(0)

def create_ui(self):
options = [
Expand Down

0 comments on commit f4d9f3d

Please sign in to comment.