Created
September 3, 2016 13:18
-
-
Save miccoli/d16fcc01daff034d406832dca4decae3 to your computer and use it in GitHub Desktop.
pyownet script example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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