forked from DogeCN/Plume-Lexicon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__main__.py
37 lines (33 loc) · 1017 Bytes
/
__main__.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
import sys, time, os
from res import version
from logic import LogicFrame
from libs.stdout import print
Debug = os.path.exists('res/DEBUG')
print(f'Translator {version.Translator} By Doge', 'Yellow', 'Bold')
print('Starting...', 'Green', 'Bold')
def main():
argv = sys.argv[1] if len(sys.argv) > 1 else None
fr = 'res/running'
difftime = time.time() - os.path.getatime(fr)
try:
lines = open(fr).readlines()
running = lines[0] == 'True\n' and difftime < 1
except: running = False
if running:
if argv: open(fr, 'a').write(f'{argv}\n')
else: open(fr, 'a').write('Show\n')
sys.exit()
else:
open(fr, 'w').write('True\n')
Frame = LogicFrame(argv)
sys.exit(Frame.exec())
if Debug:
main()
else:
for retry in range(5):
try: main()
except Exception as e:
print(f'Error: {e}', 'Red', 'Bold')
time.sleep(1)
print(f'Restarting... ({retry}/5)', 'Yellow', 'Bold')
else: break