-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.py
executable file
·42 lines (35 loc) · 1.04 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/python3.6
from petal import Petal
import subprocess
import traceback
import os, ctypes
import sys
print("DETECTED ARGS: " + str(sys.argv))
if "-u" in sys.argv or "--update" in sys.argv:
try:
root = os.getuid() == 0
except AttributeError:
root = ctypes.windll.shell32.IsUserAdmin() != 0
if not root:
print("You are not root or administrator, auto updates wont work")
else:
print("Checking for updates before running...")
try:
subprocess.check_call(
[sys.executable, "-m", "pip", "install", "-r", "requirements.txt"]
)
except Exception as e:
print("Exception: " + str(e))
else:
print("Upgraded packages, starting program")
if "--dev-mode" in sys.argv:
print("ALERT: Using Developer Mode!")
bot = Petal(devmode=True)
else:
bot = Petal(devmode=False)
try:
print("Attempting to connect to Discord, please wait....")
sys.exit(bot.run())
except Exception as e:
traceback.print_exc()
sys.exit(e)