Skip to content

Instantly share code, notes, and snippets.

@miccoli
Created September 3, 2016 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miccoli/d16fcc01daff034d406832dca4decae3 to your computer and use it in GitHub Desktop.
Save miccoli/d16fcc01daff034d406832dca4decae3 to your computer and use it in GitHub Desktop.
pyownet script example
import sys
import time
import pyownet.protocol
TIMEOUT = 10
def main():
timeout_time = time.time() + TIMEOUT
while time.time() < timeout_time:
try:
owp = pyownet.protocol.proxy()
except pyownet.protocol.ConnError:
time.sleep(1)
else:
break
else:
# Error! creation of owp has timed out
sys.exit('Unable to open connection to owserver')
# Success! we have a connection to owserver
assert owp.present('/')
for i, sens in enumerate(owp.dir()):
owp.write(sens+'alias', 'sens%d' % i)
for j in range(i):
assert owp.present('sens%d' % j)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment