|
|
@@ -48,6 +48,7 @@ def discoverEndpoints(basePath): |
|
|
return ep_names
|
|
|
|
|
|
def discoverResources(endpoint, uri_path):
|
|
|
+ resources = []
|
|
|
uriObject = urlparse(baseURL + '/' + endpoint)
|
|
|
print 'discoverRES : ' + endpoint
|
|
|
httpConnection = httplib.HTTPConnection(uriObject.netloc)
|
|
|
@@ -63,7 +64,8 @@ def discoverResources(endpoint, uri_path): |
|
|
if resource['uri'] == uri_path:
|
|
|
print 'resource: ' + resource['uri']
|
|
|
return resource['uri']
|
|
|
- return 0
|
|
|
+ else:
|
|
|
+ return 0
|
|
|
|
|
|
def subscribe(resourceURI):
|
|
|
for ep in ep_names:
|
|
|
@@ -89,9 +91,9 @@ def longPoll(channelPath): |
|
|
if response.status == 200:
|
|
|
httpBody = response.read()
|
|
|
if len(httpBody) > 0:
|
|
|
- handleEvents(json.loads(httpBody))
|
|
|
+ handleNotifications(json.loads(httpBody))
|
|
|
|
|
|
- def handleEvents(events):
|
|
|
+ def handleNotifications(events):
|
|
|
if 'notifications' in events:
|
|
|
for notification in events['notifications']:
|
|
|
if (notification['ep'] in ep_names) and (notification['path'] == subscribeURI):
|
|
|
@@ -126,6 +128,7 @@ def actuateLEDbar(ledString = '0000000000'): |
|
|
print "Started"
|
|
|
|
|
|
discoverEndpoints(baseURL)
|
|
|
+
|
|
|
subscribe(subscribeURI)
|
|
|
|
|
|
try:
|
|
|
|
0 comments on commit
89d8dbc