-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnightcap.py
executable file
·66 lines (57 loc) · 1.88 KB
/
nightcap.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3.8
# region Imports
import os
import sys
import colorama
import traceback
from time import sleep
from pymongo.errors import ServerSelectionTimeoutError
from nightcapcore.invoker import Invoker
from nightcapcore.printers.print import Printer
from nightcapcore.helpers.screen import ScreenHelper
from nightcapcore.banner.splash import Splash
from src.enter_cmd import EnterCMD
from src.boot_checks import NightcapBootChecks
from src.shutdown_checks import NightcapShutdownChecks
DEVNULL = open(os.devnull, "wb")
try:
import readline
if "libedit" in readline.__doc__:
readline.parse_and_bind("bind ^I rl_complete")
else:
readline.parse_and_bind("tab: complete")
except ImportError:
sys.stdout.write("No readline module found, no tab completion available.\n")
else:
import rlcompleter
# endregion
# region __NAME__
if __name__ == "__main__":
try:
colorama.init()
Splash().getSplash()
sleep(0.5)
ScreenHelper().clearScr()
_invoker = Invoker()
_invoker.set_on_start(NightcapBootChecks())
_invoker.execute()
_invoker.set_on_start(EnterCMD())
_invoker.execute()
except KeyboardInterrupt as ke:
ScreenHelper().clearScr()
Printer().print_formatted_delete(text="Forced Termination!!", leadingBreaks=2, endingBreaks=1)
exit()
except ServerSelectionTimeoutError as e:
Printer().print_error("ERROR CONNECTING WITH REMOTE CONTAINERS :: %s" % (str(e)))
except Exception as e:
traceback.print_exception()
Printer().print_error(e)
finally:
Printer().print_underlined_header("Cleaning up...")
try:
_invoker = Invoker()
_invoker.set_on_start(NightcapShutdownChecks())
_invoker.execute()
except Exception as e:
Printer().print_error(e)
# endregion