示例#1
0
def test_sensor_attrs_get_infinite_recursion(mocker):
    m = mocker.patch('onewire.Onewire.get', return_value=None)
    i = mocker.patch('onewire._ow.init', return_value=0)

    o = onewire.Onewire("Testdev")
    s = o.sensor('/test/path')
    with pytest.raises(onewire.OnewireException):
        s.read("temperature")
示例#2
0
 def __attrs_post_init__(self):
     import onewire
     super().__attrs_post_init__()
     self.onewire = onewire.Onewire(self.port.host)
示例#3
0
文件: ow2mqtt.py 项目: 3s1d/ow2mqtt
for name, value in config.items(section_name):
    sensors[name] = value
# [switches]
section_name = "switches"
switches = {}
for name, value in config.items(section_name):
    switches[name] = value
# [lamps]
section_name = "lamps"
lamps = {}
for name, value in config.items(section_name):
    lamps[name] = value

APPNAME = "ow2mqtt"

ow = onewire.Onewire(("%s:%s") % (OW_HOST, str(OW_PORT)))

# init logging
LOGFORMAT = '%(asctime)-15s %(message)s'
if VERBOSE:
    logging.basicConfig(filename=LOGFILE,
                        format=LOGFORMAT,
                        level=logging.DEBUG)
else:
    logging.basicConfig(filename=LOGFILE, format=LOGFORMAT, level=logging.INFO)

logging.info("Starting " + APPNAME)
if VERBOSE:
    logging.debug("DEBUG MODE")
else:
    logging.info("INFO MODE")