Created
June 24, 2017 08:38
-
-
Save anthonyeden/32ed260fa848378249c49e5867c2b2d1 to your computer and use it in GitHub Desktop.
Zetta Status Feed Examples (Python)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
I've had to patch the PySimpleSoap 'helpers.py' file | |
Here's the replacement version of datetime_u(s) | |
In the original file, this function starts on line 417 | |
This change strips any trailing "Z" character in timestamps | |
""" | |
# Functions to serialize/deserialize special immutable types: | |
def datetime_u(s): | |
fmt = "%Y-%m-%dT%H:%M:%S" | |
try: | |
return _strptime(s, fmt) | |
except ValueError: | |
try: | |
# strip trailing z - Anthony Eden Patch | |
if s[-1] == "Z": | |
warnings.warn('removing unsupported trailing Z', RuntimeWarning) | |
s = s[:-1] | |
# strip utc offset | |
if s[-3] == ":" and s[-6] in (' ', '-', '+'): | |
warnings.warn('removing unsupported UTC offset', RuntimeWarning) | |
s = s[:-6] | |
# parse microseconds | |
try: | |
return _strptime(s, fmt + ".%f") | |
except: | |
return _strptime(s, fmt) | |
except ValueError: | |
# strip microseconds (not supported in this platform) | |
if "." in s: | |
warnings.warn('removing unsuppported microseconds', RuntimeWarning) | |
s = s[:s.index(".")] | |
return _strptime(s, fmt) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Zetta Status Feed - Example Code | |
Written by Anthony Eden (http://mediarealm.com.au/) | |
https://mediarealm.com.au/articles/rcs-zetta-status-feed-getting-started/ | |
""" | |
# We need the PySimpleSoap library (https://pypi.python.org/pypi/PySimpleSOAP/1.16) | |
# Make sure you see my change to PySimpleSoap in the file "pysimplesoap-helpers-patch.py" | |
from pysimplesoap.client import SoapClient | |
# Connect to the Status Feed - make sure you put in the correct IP address | |
client = SoapClient( | |
wsdl = "http://192.168.0.2:3132/StatusFeed?wsdl", | |
trace = True | |
) | |
# Get a list of stations | |
stations = client.GetStations()['GetStationsResult'] | |
# Print the list of stations | |
print stations | |
# Print out all the metadata for each station | |
for station in stations: | |
stationId = station['Station']['ID'] | |
print "STATION ID", stationId | |
print client.GetStationFull(stationId)['GetStationFullResult']['Metadata'] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Anthony,
Thank you for this.