-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathexample-client.py
executable file
·49 lines (33 loc) · 1.02 KB
/
example-client.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/python3
import logging
import os
import pprint
import sys
from pysensorpush import PySensorPush
def setup_logger():
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter("%(name)s - %(levelname)s - %(message)s")
handler.setFormatter(formatter)
logger.addHandler(handler)
def main():
user = os.getenv("SENSORPUSH_USER", None)
password = os.getenv("SENSORPUSH_PASSWORD", None)
if None in (user, password):
print(
"ERROR! Must define env variables SENSORPUSH_USER and SENSORPUSH_PASSWORD"
)
raise SystemExit
# setup_logger()
pp = pprint.PrettyPrinter(indent=2)
sensorpush = PySensorPush(user, password)
print("--Gateways--")
pp.pprint(sensorpush.gateways)
print("\n--Sensors--")
pp.pprint(sensorpush.sensors)
print("\n--Samples--")
pp.pprint(sensorpush.samples)
if __name__ == "__main__":
main()