#476 Haystack watchSub & python

Sasa Pesic Tue 14 Mar

Hello,

I am trying to use Python requests.post(...) for watchSub and does not seem to work. Anyone has a solution to using watchSub from a simple python script, with any library?

Thanks you!

Christian Tremblay Wed 15 Mar

We have built pyhaystack (http://pyhaystack.readthedocs.io/en/latest/)

watchSub has not been fully implemented but my colleague Stuart told me a few weeks ago that he has a good idea of the way we could handle them.

It would also be nice having some help

You can reach us here : https://gitter.im/ChristianTremblay/pyhaystack

Stuart Longland Wed 15 Mar

pyhaystack can do it, but you sort-of need to reach around to the back-end:

import hszinc
from pyhaystack.client import get_session

session = get_session(…)
grid = hszinc.Grid()
grid.metadata['watchDis'] = 'my new watch'
grid.column['id'] = {}
grid.append({'id': hszinc.Ref('my.first.point')})
grid.append({'id': hszinc.Ref('my.second.point')})
grid.append({'id': hszinc.Ref('my.third.point')})

op = session._post_grid('watchSub', grid=grid, callback=lambda *a, **kwa : None)
op.wait()'
print (op.result)

That should print the watchSub response. Similar for watchPoll. It is on my TODO list to add methods for doing this to pyhaystack, but that's basically the gist of how you can do it.

Login or Signup to reply.