Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Zetta Status Feed Examples (Python)
"""
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)
"""
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']
print
@SsgtS7ARK

This comment has been minimized.

Copy link

commented Sep 7, 2018

Hi Anthony,

Thank you for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.