[ANSWERED]: return value from executeAction call

Posted on
Fri Jan 13, 2017 8:03 pm
DaveL17 offline
User avatar
Posts: 6757
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: [ANSWERED]: return value from executeAction call

FlyingDiver wrote:
Your callback doesn't match the actual name.

Code: Select all
    <CallbackMethod>refreshTheChartsActionTest</CallbackMethod>


Code: Select all
    def plotActionTest(self, pluginAction, dev, callerWaitingForResult):


But I don't know why the error message has the other name.

Winner, winner, chicken dinner.

What's weird is that if I strip out all the deviceId and wait stuff, the thing ran perfectly.

Thanks Joe. You're my hero.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Fri Jan 13, 2017 8:22 pm
DaveL17 offline
User avatar
Posts: 6757
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: [ANSWERED]: return value from executeAction call

For posterity. This works:

Caller:
Code: Select all
matplotlibPlugin = indigo.server.getPlugin("com.fogbert.indigoplugin.matplotlib")
try:
    result = matplotlibPlugin.executeAction("refreshTheChartsAPI", deviceId=0, waitUntilDone=True, props={'x_values': [1, 2, 3], 'y_values': [2, 4, 6], 'kwargs': {'linestyle': 'dashed', 'color': 'r', 'marker': 's', 'markerfacecolor': 'b',}, 'path': '/Library/Application Support/Perceptive Automation/Indigo 7/IndigoWebServer/images/controls/static/', 'filename': 'chart_api.png'})
    indigo.server.log(str(result))

except Exception as err:
    indigo.server.log(u"Exception occurred: {0}".format(err))

Actions.xml:
Code: Select all
<?xml version="1.0"?>
<Actions>
  <SupportURL>http://forums.indigodomo.com/viewforum.php?f=219</SupportURL>
  <Action id="refreshTheChartsAction">
    <Name>Redraw Charts</Name>
    <CallbackMethod>refreshTheChartsAction</CallbackMethod>
  </Action>
  <Action id="refreshTheChartsAPI" uiPath="hidden">
    <Name>Redraw Charts</Name>
    <CallbackMethod>plotActionTest</CallbackMethod>
  </Action>
</Actions>

plugin.py:
Code: Select all
    def plotActionTest(self, pluginAction, dev, callerWaitingForResult):
        try:
            plt.plot(pluginAction.props['x_values'], pluginAction.props['y_values'], **pluginAction.props['kwargs'])
            plt.savefig(u"{0}{1}".format(pluginAction.props['path'], pluginAction.props['filename']))
            plt.close('all')

        except Exception as err:
            indigo.server.log(u"API: {0}".format(err), isError=True)
            return u"Failure"

        return u"Success"

Result = Success

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Who is online

Users browsing this forum: No registered users and 4 guests