def get_rss_data(): feed_data = None try: # authentication exp = exp_sdk.start(uuid=scalaVars.uuid, api_key=scalaVars.api_key, host=scalaVars.host) # get feed data from EXP feed = exp.get_feed(uuid=scalaVars.feed_uuid) feed_data = feed.get_data() # stop connection exp.stop() scala5.ScalaPlayer.Log('Connection to EXP successful data downloaded') except exp_sdk.ExpError or exp_sdk.UnexpectedError: scala5.ScalaPlayer.LogExternalError(1000, 'ExpError', 'Error downloading data from EXP') except exp_sdk.RuntimeError: scala5.ScalaPlayer.LogExternalError(1000, 'RuntimeError', 'Please check start options of EXP SDK') except exp_sdk.AuthenticationError: scala5.ScalaPlayer.LogExternalError(1000, 'AuthenticationError', 'Unable to connect to EXP, please check credentials') except exp_sdk.ApiError: scala5.ScalaPlayer.LogExternalError(1000, 'ApiError', exp_sdk.ApiError.message) return feed_data
import exp_sdk import scala5 import scalalib from scalalib import sharedvars scalaVars = sharedvars() scala5.ScalaPlayer.Log('Starting EXP message listen') try: # authentication exp = exp_sdk.start(uuid=scalaVars.uuid, api_key=scalaVars.api_key, host=scalaVars.host) # Wait for a connection. while not exp.is_connected: scalalib.sleep(1000) # setup channel channel = exp.get_channel('scala-test-channel', consumer=True) listener = channel.listen('my-message', max_age=30) # listen to message while True: broadcast = listener.wait() if broadcast: scala5.ScalaPlayer.Log('Message received') scalaVars.EXPmessage = broadcast.payload scala5.ScalaPlayer.Log('Received message: ' + broadcast.payload) broadcast.respond('Message received thank you!') scalalib.sleep(1000) exp.stop()
# import libraries import exp_sdk import time import datetime exp_uuid = '110c7cba-f12c-43cf-ab62-e525b8de7f68' exp_api_key = '682e0a9d341b783c6856c4bf8f4f741c08f6251b641aaeec165e052efba7fbd164f0027f5ca3e310b38c247021919d64' exp_host = 'http://192.168.168.38:9000' now = datetime.datetime.now() # authentication exp = exp_sdk.start(uuid=exp_uuid, api_key=exp_api_key, host=exp_host) # Wait for a connection. while not exp.is_connected: time.sleep(1) # setup channel channel = exp.get_channel('scala-test-channel', consumer=True) responses = channel.broadcast('my-message', 'this message is send @' + now.isoformat()) # print response for response in responses: print responses exp.stop()
def setUp (self): super(Consumer, self).setUp() self.exp = exp_sdk.start(**self.consumer_credentials)
def setUp (self): super(User, self).setUp() self.exp = exp_sdk.start(**self.user_credentials)
def setUp (self): super(Device, self).setUp() self.exp = exp_sdk.start(**self.device_credentials)