-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathnordpy.py
executable file
·62 lines (47 loc) · 2.07 KB
/
nordpy.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
#!/usr/bin/python3
from bin.gui_components.root_password_window import RootPermissionWindow
import os
import argparse
def get_parser():
parser = argparse.ArgumentParser(prog="nordpy",
description='An application to connect to NordVPN servers')
connection_group = parser.add_mutually_exclusive_group()
connection_group.add_argument('--quick-connect', action="store_true",
help='connects to the last chosen server type')
connection_group.add_argument('--quick-disconnect', action="store_true",
help='disconnects nordpy VPN connection')
connection_group.add_argument('--status', action="store_true",
help='checks if any VPN connection is running')
parser.add_argument('--wait-connection', action="store_true",
help='wait connection before trying to start VPN')
parser.add_argument('--all', action="store_false",
help='check status among all connection types')
return parser
def main():
# if file is launched without root privileges
parser = get_parser()
parsed_args = parser.parse_args()
if parsed_args.quick_connect:
from bin.command_line_util import quick_connect
quick_connect(parsed_args.wait_connection)
elif parsed_args.quick_disconnect:
from bin.command_line_util import quick_disconnect
quick_disconnect()
elif parsed_args.status:
from bin.command_line_util import status
print(status(parsed_args.all))
elif os.geteuid() != 0:
root_request_win = RootPermissionWindow()
root_request_win.mainloop()
# checking if a correct password has been inserted
from bin.gui_components.root_password_window import password_inserted
if password_inserted is None:
return
import bin.root
bin.root.get_root_permissions(password_inserted)
del password_inserted
from bin.gui import gui
app = gui()
app.mainloop()
if __name__ == "__main__":
main()