Skip to content

Commit c33d409

Browse files
committed
changed streaming domain; new install helper for new product launch
1 parent 2fe8d71 commit c33d409

4 files changed

Lines changed: 84 additions & 11 deletions

File tree

ISStreamer/Streamer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def __ship(retry_attempts, wait=0):
136136
elif (response.status == 401 or response.status == 403):
137137
self.console_message("ERROR: unauthorized access_key: " + self.AccessKey)
138138
elif (response.status == 402):
139-
self.console_message("AccessKey exceeded limit for month, check account at https://app.initialstate.com/#/account")
139+
self.console_message("AccessKey exceeded limit for month, check account")
140140
raise Exception("PAYMENT_REQUIRED")
141141
elif (response.status == 429):
142142
if "Retry-After" in response.msg:

ISStreamer/configutil.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def getConfig(ini_file_location=None):
1414
"offline_mode": "false",
1515
"offline_file": "./isstreamer_out.csv",
1616
"core_api_base": "https://api.initialstate.com",
17-
"stream_api_base": "https://groker.initialstate.com"
17+
"stream_api_base": "https://groker.init.st"
1818
}
1919

2020
if (ini_file_location != None):
@@ -27,7 +27,7 @@ def getConfig(ini_file_location=None):
2727
home = os.path.expanduser("~")
2828
config_file_home_path = os.path.abspath("{home}/isstreamer.ini".format(home=home))
2929
config_file_local_path = os.path.abspath("{current}/isstreamer.ini".format(current=os.getcwd()))
30-
30+
3131
config_file_exists = False
3232
config_file_path = config_file_home_path
3333
if (os.path.exists(config_file_home_path)):

ISStreamer/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.3.1'
1+
__version__ = '1.0.0'

install_scripts/python

100644100755
Lines changed: 80 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,84 @@ function check_for_isstreamer {
7979
pip install ISStreamer
8080
else
8181
echo "ISStreamer found, updating..."
82-
82+
8383
pip install --upgrade ISStreamer
8484
fi
85+
86+
isstreamer_version=$(python -c "import pkg_resources; print(pkg_resources.get_distribution('ISStreamer').version)")
87+
88+
echo "Found ISStreamer: $isstreamer_version"
89+
isstreamer_version_array=(${isstreamer_version//" "/ })
90+
isstreamer_version_num=${isstreamer_version_array[0]}
91+
isstreamer_version_num_array=(${isstreamer_version_num//./ })
92+
isstreamer_major_version=${isstreamer_version_num_array[0]}
93+
isstreamer_minor=${isstreamer_version_num_array[1]}
94+
isstreamer_minor_version_array=(${isstreamer_minor//"rc"/ })
95+
isstreamer_minor_version=${isstreamer_minor_version_array[0]}
96+
97+
echo "isstreamer major version: $isstreamer_major_version"
98+
echo "isstreamer minor version: $isstreamer_minor_version"
8599
}
86100

87101
function download_script {
88-
echo -n "Enter www.initialstate.com user email: "
89-
read username < /dev/tty
90-
echo -n "Enter www.initialstate.com password [input hidden]: "
102+
echo "Please select which Initial State app you're using: "
103+
echo "1) app.initialstate.com"
104+
echo "2) [NEW!] iot.app.initialstate.com"
105+
echo -n "Enter choice 1 or 2: "
106+
read app_version < /dev/tty
107+
108+
if [ "$app_version" = "1" ]; then
109+
echo -n "Enter app.initialstate.com user email: "
110+
read username < /dev/tty
111+
echo -n "Enter app.initialstate.com password [input hidden]: "
112+
read -s password < /dev/tty
113+
echo ""
114+
115+
if [ -z "$example_location" ]; then
116+
example_location="./is_example.py"
117+
fi
118+
119+
python_example=$(curl -X POST "https://api.initialstate.com/api/v1/python/example" -H "X-USER: $username" -H "X-SEC: $password" -H "Accept-Content: text/plain" -m 30 -d "" -s)
120+
121+
if [ "$python_example" = "INVALID_CREDENTIALS" ]; then
122+
echo "invalid credentials, let's try that again!"
123+
download_script
124+
else
125+
echo "$python_example" | sudo -u $SUDO_USER tee "$example_location" > /dev/null
126+
fi
127+
else
128+
echo -n "Enter iot.app.initialstate.com user email: "
129+
read username < /dev/tty
130+
echo -n "Enter iot.app.initialstate.com password [input hidden]: "
131+
read -s password < /dev/tty
132+
echo ""
133+
134+
if [ -z "$example_location" ]; then
135+
example_location="./is_example.py"
136+
fi
137+
138+
python_example=$(curl -X POST "https://api.init.st/dev-auth/python/example" -H "X-USER: $username" -H "X-PASS: $password" -H "Accept-Content: text/plain" -m 30 -d "" -s)
139+
140+
if [ "$python_example" = "INVALID_CREDENTIALS" ]; then
141+
echo "invalid credentials, let's try that again!"
142+
download_script
143+
elif [ "$python_example" = "NOT_CURRENT" ]; then
144+
echo "your account hasn't been migrated, go to iot.app.initialstate.com to sign in or create a new account"
145+
download_script
146+
elif [ "$python_example" = "{\"message\":\"Missing Authentication Token\"}" ]; then
147+
echo "there's currently an issue with this endpoint, try again later or email support@initialstate.com. Thanks!"
148+
exit 1
149+
else
150+
echo "$python_example" | sudo -u $SUDO_USER tee "$example_location" > /dev/null
151+
fi
152+
fi
153+
154+
}
155+
156+
function download_script_old {
157+
echo -n "Enter app.initialstate.com user email: "
158+
read username < /dev/tty
159+
echo -n "Enter app.initialstate.com password [input hidden]: "
91160
read -s password < /dev/tty
92161
echo ""
93162

@@ -96,7 +165,7 @@ function download_script {
96165
fi
97166

98167
python_example=$(curl -X POST "https://api.initialstate.com/api/v1/python/example" -H "X-USER: $username" -H "X-SEC: $password" -H "Accept-Content: text/plain" -m 30 -d "" -s)
99-
168+
100169
if [ "$python_example" = "INVALID_CREDENTIALS" ]; then
101170
echo "invalid credentials, let's try that again!"
102171
download_script
@@ -113,9 +182,13 @@ function setup_first_script {
113182
echo "Where do you want to save the example? [default: ./is_example.py]: "
114183
read example_location < /dev/tty
115184

116-
download_script
185+
if [ "$isstreamer_major_version" -gt "0" ]; then
186+
download_script
187+
else
188+
download_script_old
189+
fi
117190
fi
118-
191+
119192
echo "All done!"
120193
}
121194

0 commit comments

Comments
 (0)