forked from rcwoolley/device-cloud-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloud-test.py.in
More file actions
executable file
·39 lines (34 loc) · 1.01 KB
/
cloud-test.py.in
File metadata and controls
executable file
·39 lines (34 loc) · 1.01 KB
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
#!/usr/bin/env python
"""
This app is for testing connectivity using the default
iot-connect.cfg file. It will connect, report status and exit.
"""
import device_cloud as iot
import os
import sys
# Initialize client default called 'python-demo-app'
app_id = "cloud-test-py"
client = iot.Client(app_id)
# Use the same iot-connect as the device manager
def_config_file = "%etcdir%/iot-connect.cfg"
if os.path.isfile(def_config_file):
client.config.config_file = def_config_file
else:
print("Error: expected config file not found %s" % def_config_file)
sys.exit(1)
# use the device manager's device_id if it exists
def_config_dir = "%vardir%"
if os.path.isdir(def_config_dir):
client.config.config_dir = def_config_dir
else:
print("Error: expected config dir not found %s" % def_config_dir)
sys.exit(1)
client.initialize()
if client.connect(timeout=5) != iot.STATUS_SUCCESS:
print("Failed to connect")
ret = 1
else:
print("Connection succeeded")
ret = 0
client.disconnect()
sys.exit(ret)