mirror of https://github.com/coddrago/Heroku
Add automatic restart after installing dependencies \ reinstalling telethon
parent
4b730c40d2
commit
1e307b98c2
|
@ -30,6 +30,7 @@ import sys
|
||||||
import getpass
|
import getpass
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import atexit
|
||||||
|
|
||||||
if (
|
if (
|
||||||
getpass.getuser() == "root"
|
getpass.getuser() == "root"
|
||||||
|
@ -70,6 +71,36 @@ def deps(e):
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
restart()
|
||||||
|
|
||||||
|
|
||||||
|
def restart():
|
||||||
|
if "HIKKA_DO_NOT_RESTART" in os.environ:
|
||||||
|
print("Got in a loop, exiting")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
print("🔄 Restarting...")
|
||||||
|
|
||||||
|
atexit.register(
|
||||||
|
lambda: os.execl(
|
||||||
|
sys.executable,
|
||||||
|
sys.executable,
|
||||||
|
"-m",
|
||||||
|
os.path.relpath(
|
||||||
|
os.path.abspath(
|
||||||
|
os.path.dirname(
|
||||||
|
os.path.abspath(__file__),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
*(sys.argv[1:]),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
os.environ["HIKKA_DO_NOT_RESTART"] = "1"
|
||||||
|
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info < (3, 8, 0):
|
if sys.version_info < (3, 8, 0):
|
||||||
print("🚫 Error: you must use at least Python version 3.8.0")
|
print("🚫 Error: you must use at least Python version 3.8.0")
|
||||||
|
@ -110,7 +141,7 @@ else:
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
print("🔄 Restart this script for changes to take effect!")
|
restart()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from . import log
|
from . import log
|
||||||
|
@ -118,33 +149,16 @@ else:
|
||||||
log.init()
|
log.init()
|
||||||
except ModuleNotFoundError as e: # pragma: no cover
|
except ModuleNotFoundError as e: # pragma: no cover
|
||||||
deps(e)
|
deps(e)
|
||||||
try:
|
sys.exit(1)
|
||||||
from . import log
|
|
||||||
|
|
||||||
log.init()
|
|
||||||
except ModuleNotFoundError as e2:
|
|
||||||
print(
|
|
||||||
"🚫 Error while installing dependencies. Please, do this manually!\n"
|
|
||||||
f"{str(e2)}\n"
|
|
||||||
"Run: pip3 install -r requirements.txt"
|
|
||||||
)
|
|
||||||
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from . import main
|
from . import main
|
||||||
except ModuleNotFoundError as e: # pragma: no cover
|
except ModuleNotFoundError as e: # pragma: no cover
|
||||||
deps(e)
|
deps(e)
|
||||||
try:
|
sys.exit(1)
|
||||||
from . import main
|
|
||||||
except ModuleNotFoundError as e2:
|
|
||||||
print(
|
|
||||||
"🚫 Error while installing dependencies. Please, do this manually!\n"
|
|
||||||
f"{str(e2)}\n"
|
|
||||||
"Run: pip3 install -r requirements.txt"
|
|
||||||
)
|
|
||||||
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
if "HIKKA_DO_NOT_RESTART" in os.environ:
|
||||||
|
del os.environ["HIKKA_DO_NOT_RESTART"]
|
||||||
|
|
||||||
main.hikka.main() # Execute main function
|
main.hikka.main() # Execute main function
|
||||||
|
|
Loading…
Reference in New Issue