forked from fbradyirl/openwrt-luci-rpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
52 lines (38 loc) · 1.25 KB
/
test.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
import logging
import sys, os
root = logging.getLogger()
root.setLevel(logging.DEBUG)
log = logging.getLogger(__name__)
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
root.addHandler(handler)
from openwrt_luci_rpc import OpenWrtRpc
env_name_ip_address = "OPENWRT_IP"
env_name_password = "OPENWRT_PASSWORD"
if not os.getenv(env_name_ip_address):
log.error("You need to set the router ip environment variable. e.g. ")
log.error("export {}=<YOUR_ROUTER_IP>".format(env_name_ip_address))
exit(1)
if not os.getenv(env_name_password):
log.error("You need to set the router password environment variable. e.g. ")
log.error("export {}=<YOUR_ROUTER_PASS>".format(env_name_password))
exit(1)
print('test valid')
r = OpenWrtRpc(os.getenv(env_name_ip_address), 'root', os.getenv(env_name_password), False)
# print('test invalid')
# r = OpenWrtRpc()
r.get_all_connected_devices(only_reachable=False)
#import ipdb
#ipdb.set_trace()
#
# r.get_all_connected_devices(only_reachable=False)
#
# import ipdb
# ipdb.set_trace()
#
# r.get_all_connected_devices(only_reachable=False)
#
# import ipdb
# ipdb.set_trace()