Skip to content

Commit ee8c348

Browse files
committed
Merge branch 'master' into dev
2 parents 15b7c64 + bbde589 commit ee8c348

5 files changed

Lines changed: 55 additions & 7 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ docs/_build/
5353
# PyBuilder
5454
target/
5555

56+
.DS_Store
5657

5758
# example app private files
5859
isstreamer.ini

ISStreamer/Streamer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def __init__(self, bucket_name="", bucket_key="", access_key="", ini_file_locati
8686
self.console_message("stream_api_base: {api}".format(api=self.StreamApiBase))
8787

8888

89-
def set_bucket(self, bucket_name, bucket_key, retries=3):
89+
def set_bucket(self, bucket_name="", bucket_key="", retries=3):
9090

9191
def __create_bucket(new_bucket_name, new_bucket_key, access_key):
9292
api_base = self.StreamApiBase

example_app/example_read_csv.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1+
#########
2+
# Use: python ./example_read_csv.py -b your_bucket_key -k your_access_key -f 'csv_file_location.csv'
3+
# Note: The CSV file structure should NOT contain a header and should be in the following format
4+
# <ISO-8601 Date Time>,<StreamKey>,<StreamValue>/n
5+
##########
6+
17
import getopt, sys, time, csv
28
from ISStreamer.Streamer import Streamer
39

410
def read_args(argv):
511
try:
6-
opts, args = getopt.getopt(argv,"hb:k:f:",["bucket_name=", "access_key=", "file_location="])
12+
opts, args = getopt.getopt(argv,"hb:k:f:",["bucket_key=", "access_key=", "file_location="])
713
except getopt.GetoptError:
8-
print('example_read_csv.py -b <bucket_name> -k <access_key> -f <file_location>')
14+
print('example_read_csv.py -b <bucket_key> -k <access_key> -f <file_location>')
915
sys.exit(1)
1016

1117
for opt, arg in opts:
1218
if opt == '-h':
13-
print('example_read_csv.py -b <bucket_name> -k <access_key> -f <file_location>')
14-
elif opt in ("-b", "--bucket_name"):
19+
print('example_read_csv.py -b <bucket_key> -k <access_key> -f <file_location>')
20+
elif opt in ("-b", "--bucket_key"):
1521
bucket = arg
1622
elif opt in ("-k", "--access_key"):
1723
access_key = arg
@@ -20,17 +26,26 @@ def read_args(argv):
2026

2127
return bucket, access_key, file_location
2228

29+
def is_float(str):
30+
try:
31+
float(str)
32+
return True
33+
except ValueError:
34+
return False
2335

2436
if __name__ == "__main__":
2537
bucket, access_key, file_location = read_args(sys.argv[1:])
2638

27-
streamer = Streamer(bucket_name=bucket, access_key=access_key, buffer_size=20, offline=False)
39+
streamer = Streamer(bucket_name=bucket, bucket_key=bucket, access_key=access_key, buffer_size=20, offline=False)
2840

2941
with open(file_location, 'rb') as csvfile:
3042
reader = csv.reader(csvfile)
3143
counter = 0
3244
for row in reader:
33-
streamer.log(row[1], row[2], epoch=row[0])
45+
epoch = row[0]
46+
if not is_float(epoch):
47+
epoch = ((dateutil.parser.parse(epoch))-(dateutil.parser.parse("1970-01-01T00:00:00Z"))).total_seconds()
48+
streamer.log(row[1], row[2], epoch=epoch)
3449
counter += 1
3550

3651
if counter%10==0:

example_app/test_wifi.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import time
2+
from ISStreamer.Streamer import Streamer
3+
4+
streamer = Streamer(bucket_name="Testing Wifi", ini_file_location="./isstreamer.ini")
5+
6+
try:
7+
for num in range(1, 1000):
8+
streamer.log("num", num)
9+
print("iteration #{}".format(num))
10+
time.sleep(1)
11+
streamer.flush()
12+
except Exception as ex:
13+
print(ex)
14+
15+
streamer.close()

install_scripts/python

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
#!/bin/bash
22

33
echo "Beginning ISStreamer Python Easy Installation!"
4+
echo " _________ "
5+
echo " NN NN "
6+
echo " N N "
7+
echo " N NNNNNNN N "
8+
echo " N NN N N"
9+
echo "NNNNNNN N N N N"
10+
echo "N N N N N N"
11+
echo "N N N N N N"
12+
echo " "
13+
echo "NNNN NN NNNNNNNN NNNNNNN"
14+
echo "N N N N N N"
15+
echo "N N N N N N"
16+
echo "N N NN N NNNNNNN"
17+
echo " N NNNNNNN N "
18+
echo " N N "
19+
echo " NN NN "
20+
echo " --------- "
421
echo "This may take a couple minutes to install, grab some coffee :)"
522
echo "But don't forget to come back, I'll have questions later!"
623
echo ""

0 commit comments

Comments
 (0)