Skip to content

Commit fd056e9

Browse files
committed
Moved to try block
1 parent f691335 commit fd056e9

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,35 @@
22

33
This is companion code for my Medium article.
44

5+
## Populate Test Data
6+
7+
```
8+
chmod +x run_sensors.sh
9+
./run_sensors.sh
10+
```
11+
12+
## Query the Data
13+
14+
```
15+
python query_iot_data.py --help
16+
usage: query_iot_data.py [--help] [-U <USERNAME>] [-P <PASSWORD>]
17+
[-h <ADDRESS>] [-p <PORT>] [-n <NS>] [-s <SET>]
18+
[--sensor <SENSOR-ID>] [-i]
19+
20+
optional arguments:
21+
--help Displays this message.
22+
-U <USERNAME>, --username <USERNAME>
23+
Username to connect to database.
24+
-P <PASSWORD>, --password <PASSWORD>
25+
Password to connect to database.
26+
-h <ADDRESS>, --host <ADDRESS>
27+
Address of Aerospike server.
28+
-p <PORT>, --port <PORT>
29+
Port of the Aerospike server.
30+
-n <NS>, --namespace <NS>
31+
Port of the Aerospike server.
32+
-s <SET>, --set <SET>
33+
Port of the Aerospike server.
34+
--sensor <SENSOR-ID> Sensor ID
35+
-i, --interactive Interactive Mode
36+
```

query_iot_data.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,13 @@ def print_sensor_data(rec, pp):
130130
pp = pprint.PrettyPrinter(indent=2)
131131
sensor_id = options.sensor_id
132132
spacer = "=" * 30
133-
minute = 0
134-
key = (namespace, set, "sensor{}-12-31".format(sensor_id))
135-
print("\nRetrieve sensor{} data for 8-11am, December 31st".format(sensor_id))
136-
if options.interactive:
137-
pause()
138-
starts = 8 * 60
139-
ends = 11 * 60
140133
try:
134+
key = (namespace, set, "sensor{}-12-31".format(sensor_id))
135+
print("\nRetrieve sensor{} data for 8-11am, December 31st".format(sensor_id))
136+
if options.interactive:
137+
pause()
138+
starts = 8 * 60
139+
ends = 11 * 60
141140
ops = [
142141
lh.list_get_by_value_range(
143142
"t",

0 commit comments

Comments
 (0)