forked from hundeboll/riddler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.py
executable file
·38 lines (31 loc) · 1.2 KB
/
node.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
#!/usr/bin/env python2
import sys
import argparse
import node_server as server
parser = argparse.ArgumentParser(description="Riddler Node Application")
parser.add_argument("--config", default="node_defaults")
(args,dummy) = parser.parse_known_args()
try:
c = __import__(args.config)
defaults = dict((k, v) for k,v in c.__dict__.iteritems() if not k.startswith('__'))
except ImportError:
print("Unable to load config file: {0}".format(args.config))
sys.exit(1)
parser.add_argument("--wifi_iface")
parser.add_argument("--host", help="IP Address of interface to bind")
parser.add_argument("--port", type=int, help="Port number to listen on")
parser.add_argument("--mesh_host")
parser.add_argument("--mesh_port", type=int)
parser.add_argument("--fox_path", type=str)
parser.set_defaults(**defaults)
args = parser.parse_args()
class node:
def __init__(self):
self.server = server.server(args) #Creating a new object of server
self.server.create() #creates server for node
self.server.serve() #makes the server do, what it does best. Serve!
if __name__ == "__main__":
try:
n = node() #Creating a new object of node
except KeyboardInterrupt:
print("Quit")