make sure errorcodes are returned

This commit is contained in:
Øyvind Saltvik 2012-08-10 21:41:31 +02:00
parent 5cfd91717f
commit c9588af3c3
2 changed files with 8 additions and 13 deletions

View file

@ -4,7 +4,7 @@ telldus.tdInit()
while True:
result = telldus.tdSensor()
if not result:
if not isinstance(result, tuple):
break
else:
protocol, model, sensorId, dataTypes = result
@ -13,13 +13,13 @@ while True:
# Retrieve the values the sensor supports
if dataTypes & telldus.TELLSTICK_TEMPERATURE:
result = telldus.tdSensorValue(protocol, model, sensorId, telldus.TELLSTICK_TEMPERATURE)
if result:
if isinstance(result, tuple):
value, timestamp = result
print "Temperature:\t%sC\t(%s)\n" % (value, str(timestamp))
if dataTypes & telldus.TELLSTICK_HUMIDITY:
result = telldus.tdSensorValue(protocol, model, sensorId, telldus.TELLSTICK_HUMIDITY)
if result:
if isinstance(result, tuple):
value, timestamp = result
print "Humidity:\t%s\t(%s)\n" % (value, str(timestamp))

View file

@ -31,17 +31,14 @@ estrdup(char *s)
static PyObject *
telldus_tdInit(PyObject *self)
{
tdInit();
Py_INCREF(Py_None);
return Py_None;
return PyLong_FromLong(tdInit());
}
static PyObject *
telldus_tdClose(PyObject *self)
{
tdClose();
Py_INCREF(Py_None);
return Py_None;
return PyLong_FromLong(tdClose();)
}
static PyObject *
@ -573,8 +570,7 @@ telldus_tdSensor(PyObject *self, PyObject *args)
}
else
{
Py_INCREF(Py_None);
return Py_None;
return PyLong_FromLong(result);
}
}
@ -614,8 +610,7 @@ telldus_tdSensorValue(PyObject *self, PyObject *args)
}
else
{
Py_INCREF(Py_None);
return Py_None;
return PyLong_FromLong(result);
}
}