Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
Full pyinstaller support
Browse files Browse the repository at this point in the history
  • Loading branch information
iiPythonx committed Jan 15, 2023
1 parent 09858be commit 4ca1cbf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2022 StreamX Developers

# Modules
import os
import logging
from aiohttp import web
from rich.logging import RichHandler
Expand Down Expand Up @@ -31,11 +32,12 @@
serverSelectionTimeoutMS = 1000 # ms
)
try:
mongo.server_info()
log.info(f"Connected to MongoDB at {mongo.client.address[0]}!")
if os.getenv("SXPYINSTALLER") != "1":
mongo.server_info()
log.info(f"Connected to MongoDB at {mongo.client.address[0]}!")

app.mongo = mongo["streaming"]
app.payment = mongo["purchases"]
app.mongo = mongo["streaming"]
app.payment = mongo["purchases"]

except errors.ServerSelectionTimeoutError:
log.critical("FAILED to connect to MongoDB! Check MONGO* env and database status.")
Expand Down
6 changes: 4 additions & 2 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Modules
import os
import sys
import json
import logging
import requests
Expand All @@ -10,7 +11,7 @@
log, upstream_url = logging.getLogger("rich"), os.getenv("STREAMX_UPSTREAM", "")
def e(message: str) -> None:
log.critical(message)
exit(1)
sys.exit(1)

if not upstream_url.strip():
e("Missing upstream configuration URL!")
Expand All @@ -28,7 +29,8 @@ def e(message: str) -> None:
e("Configuration server is offline!")

else:
fp = os.path.join(os.path.dirname(os.path.dirname(__file__)), "config.json")
fl = os.path.dirname(__file__ if not getattr(sys, "frozen", False) else sys.executable)
fp = os.path.join(fl, "config.json")
if not os.path.isfile(fp):
e("Config upstream set to file but no configuration file exists!")

Expand Down

0 comments on commit 4ca1cbf

Please sign in to comment.