Skip to content

Commit 3ab4c91

Browse files
committed
+ added requirements.txt
* updated imports + added import option for private credentials and server definitions Signed-off-by: Stefan Langer <[email protected]>
1 parent 55b2617 commit 3ab4c91

File tree

4 files changed

+35
-10
lines changed

4 files changed

+35
-10
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,7 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
# Ignore file with private credentials
132+
/my_tb_credentials.py
133+
/my_tb_server_defs.py

iot-sglux-com-example.py

+26-9
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,36 @@
33
import json
44
import requests
55
import datetime
6-
import time
7-
import os
8-
import pprint
6+
import os, sys
97
import dateutil
10-
from dateutil.parser import parse
11-
from dateutil.tz import gettz
8+
from dateutil.parser import *
129
from prettytable import PrettyTable
1310

14-
#import credentials from file: PLEASE UPDATE IN ANY CASE
15-
from tb_credentials import username, password
11+
# try to import credentials from your private my_tb_credentials.py file
12+
try:
13+
from my_tb_credentials import username, password
14+
except ImportError:
15+
# if that file does not exist, try to import the credential template
16+
try:
17+
from tb_credentials import username, password
18+
except ImportError:
19+
print("You should copy tb_credentials.py to my_tb_credentials.py and fill it with your actual data!")
20+
print(sys.exc_info())
21+
exit()
22+
23+
24+
# try to import credentials from your private my_tb_server_defs.py file
25+
try:
26+
from my_tb_server_defs import tb_server_url, tb_server_api, tb_server_auth
27+
except ImportError:
28+
# if that file does not exist, try to import the credential template
29+
try:
30+
from tb_server_defs import tb_server_url, tb_server_api, tb_server_auth
31+
except ImportError:
32+
print("You should copy tb_server_defs.py to my_tb_server_defs.py and fill it with your actual data!")
33+
print(sys.exc_info())
34+
exit()
1635

17-
# import server URLS to be used: PLEASE UPDATE IF REQUIRED
18-
from tb_server_defs import tb_server_url, tb_server_api, tb_server_auth
1936

2037
from pylux_tb import *
2138

requirements.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
requests
2+
datetime
3+
prettytable
4+
python-dateutil

tb_server_defs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# please put the thingsboard server URL (IP) here
44
global tb_server_url
5-
tb_server_url = 'https://iot.sglux.com'
5+
tb_server_url = 'https://mytb.mydomain.com'
66

77
# definition of authorization address
88
# this should not need modifikation!

0 commit comments

Comments
 (0)