-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
49 lines (39 loc) · 1.24 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
import os
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
print("Working directory:", dname)
os.chdir(dname)
from Server.server import Server
import subprocess
import sys
import threading
import ctypes
def run_as_admin(argv=None, debug=False):
shell32 = ctypes.windll.shell32
if argv is None and shell32.IsUserAnAdmin():
return True
if argv is None:
argv = sys.argv
if hasattr(sys, '_MEIPASS'):
# Support pyinstaller wrapped program.
arguments =argv[1:]
else:
arguments = argv
argument_line = u' '.join(arguments)
executable = sys.executable
ret = shell32.ShellExecuteW(None, u"runas", executable, argument_line, None, 1)
if int(ret) <= 32:
return False
return None
def runAnalyzer():
proc = subprocess.Popen([sys.executable, "Static/analyzer.py"], shell=False)
proc.communicate()
#shell32 = ctypes.windll.shell32
#ret = shell32.ShellExecuteW(None, u"runas", sys.executable, "Static/analyzer.py", None, 1)
if __name__ == "__main__":
if os.name == 'nt':
# Should not be run at Linux
run_as_admin()
threading.Thread(target=runAnalyzer).start()
server = Server(ip='127.0.0.1', port=8888)
server.run()