Ok, I think I see what's going on. Give me a couple of days to work
through some changes, I'll post them to CVS and let you know.

(I'm cross posting to the OWFS developers list to keep everyone up to date...)

- Peter


On 9/12/06, Brad Clements <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have just the beginnings of an airport gate controller, but one of my relays
> burned out, so haven't progressed too far yet on the code.
>
>
> Anyway, in addition to the hash problem, I'm getting occasional dropouts from 
> the
> USB adapter.
>
> So what happens is, when I use sensorList I get an exception because "None" is
> not a string and so doesn't have a split method.
>
> I think the python library needs a specific exception that can be tested for 
> when a
> sensor path is no longer valid or a communication timeout occurs.
>
> So, if I query a sensor that suddenly "isn't there", I want a specific 
> exception I can
> catch, not a generic attributeError.
>
>
> Consider the output pasted below, which corresponds to this simple program 
> that
> just polls over and over. I can accept a sensor temporarily going away, but 
> only if
> I can catch it and retry. The AttributeError I get is too generic to be 
> useful.
>
> # owinterface.py
> # interface with owfs for dallas stuff
>
> import time, sys, sets, new
>
> from ow import Sensor, init
>
> default_init = "localhost:3001"
>
> init(default_init)
>
> def sensor_hash(self):
>     return hash(self._path)
>
> # monkey patch
>
> Sensor.__hash__ = new.instancemethod(sensor_hash, None, Sensor)
>
> usb_interface = Sensor('/81.2BE924000000')
> open_switch = Sensor('/05.893A26000000')
> close_switch = Sensor('/05.973F26000000')
> root = Sensor('/')
>
> class Interface(object):
>     system_buttons = sets.Set([usb_interface, open_switch, close_switch])
>     def __init__(self):
>         pass
>
>     def sense_new_buttons(self):
>         """Look for new buttons on the interface, return list of them"""
>         all_buttons = sets.Set(root.sensorList())
>         new_buttons = all_buttons - self.system_buttons
>         missing_system_buttons = self.system_buttons - all_buttons
>         if missing_system_buttons:
>             print "missing buttons ", missing_system_buttons
>         return list(new_buttons)
>
>
> def poll_for_devices():
>     """just poll for devices at a regular rate"""
>     I = Interface()
>     while 1:
>         new_buttons = I.sense_new_buttons()
>         if new_buttons:
>             print new_buttons
>         time.sleep(0.5)
>         print ".",
>
> def main(args=None):
>     if args is None:
>         args = sys.argv[1:]
>
>     from optparse import OptionParser
>     parser = OptionParser(usage="%prog ", version="1.0")
>     parser.add_option("-k", "--poll", dest="do_poll", action="store_true",
>                      help="Poll bus for new devices")
>
>     (options, args) = parser.parse_args(args)
>     if options.do_poll:
>         poll_for_devices()
>     else:
>         parser.print_help()
>
> if __name__ == "__main__":
>     main(sys.argv[1:])
>
> # output below
>
>
>
> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
> . . . . . . . . . . . missing buttons
> Set([Sensor("/05.973F26000000")])
> .
> Traceback (most recent call last):
>   File "src/owinterface.py", line 66, in ?
>     main(sys.argv[1:])
>   File "src/owinterface.py", line 61, in main
>     poll_for_devices()
>   File "src/owinterface.py", line 44, in poll_for_devices
>     new_buttons = I.sense_new_buttons()
>   File "src/owinterface.py", line 32, in sense_new_buttons
>     all_buttons = sets.Set(root.sensorList())
>   File "/usr/local/lib/python2.4/site-packages/ow/__init__.py", line 462, in
> sensorList
>     return [ s for s in self.sensors( ) ]
>   File "/usr/local/lib/python2.4/site-packages/ow/__init__.py", line 439, in 
> sensors
>     yield Sensor( path )
>   File "/usr/local/lib/python2.4/site-packages/ow/__init__.py", line 235, in 
> __init__
>     self.useCache( self._useCache )
>   File "/usr/local/lib/python2.4/site-packages/ow/__init__.py", line 375, in
> useCache
>     self._attrs = dict( [ (n.replace( '.', '_' ), self._usePath + '/' + n )
> AttributeError: 'NoneType' object has no attribute 'split'
>
>
>
> --
> Brad Clements,                [EMAIL PROTECTED]    (315)268-1000
> http://www.murkworks.com
> AOL-IM or SKYPE: BKClements
>
>
>

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to