-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.py
executable file
·49 lines (40 loc) · 1.57 KB
/
run.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""╔═╗┌┬┐┌─┐┬─┐┌┬┐ ╔╦╗┌─┐┌┬┐┌─┐┬─┐ ╔═╗┬─┐┬┬ ┬┌─┐┌─┐┬ ┬
╚═╗│││├─┤├┬┘ │ ║║║├┤ │ ├┤ ├┬┘ ╠═╝├┬┘│└┐┌┘├─┤│ └┬┘
╚═╝┴ ┴┴ ┴┴└─ ┴ ╩ ╩└─┘ ┴ └─┘┴└─ ╩ ┴└─┴ └┘ ┴ ┴└─┘ ┴
By Dubell & Widegren
Usage:
run.py --mode=client|server [-v] [-vv]
Options:
-h, --help Show this screen.
--version Show version.
mode (client|server) Initiate server or client mode.
-v, --verbose Show information regarding setup.
-vv, --very-verbose Display everything.
"""
from docopt import docopt
from src.server import Server
from src.client import Client
from src.core import Core
import sys
import threading
import time
def main(arguments):
if arguments['--mode'] == 'client':
client = Client()
client.setup()
client.start()
elif arguments['--mode'] == 'server':
server = Server()
server.setup()
server.start()
else:
core.logger.error("You need to specify either server or client mode!")
while True:
# The main thread will loop forever until CTRL+C, which will cause all the threads and main program to close.
# However better cleanup is needed
time.sleep(1)
if __name__ == '__main__':
arguments = docopt(__doc__, version="Smart Meter Privacy 1.0")
main(arguments)