Stefano,
I took your ex.py and modified it slightly to use a variable as the base
device name -
==========================
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('/')
name = 'sensor'
for i, sens in enumerate(owp.dir()):
print 'i = ', i, ' sens = ', sens
owp.write(sens+'alias', name + '%d' % i)
for j in range(i):
assert owp.present(name + '%d' % j)
for f in owp.dir():
print 'f = ', f
if __name__ == '__main__':
main()
==========================
I have tested this and it works, but if I change line 23 to
name = 'Xsensor'
and run it again I get
$ ./ex.py
i = 0 sens = /sensor0/
i = 1 sens = /sensor1/
Traceback (most recent call last):
File "./ex.py", line 39, in <module>
main()
File "./ex.py", line 30, in main
owp.write(sens+'alias', name + '%d' % i)
File "/usr/local/lib/python2.7/dist-packages/pyownet/protocol.py",
line 636, in write
raise OwnetError(-ret, self.errmess[-ret], path)
pyownet.protocol.OwnetError: [Errno 1] Startup - command line parameters
invalid: u'/sensor1/alias'
Is there some reason why I cannot change an alias a second time? Have I
done something stupid?
Thanks
Mick
------------------------------------------------------------------------------
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers