本文整理匯總了Python中domogik.common.database.DbHelper.update_device方法的典型用法代碼示例。如果您正苦於以下問題:Python DbHelper.update_device方法的具體用法?Python DbHelper.update_device怎麽用?Python DbHelper.update_device使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類domogik.common.database.DbHelper
的用法示例。
在下文中一共展示了DbHelper.update_device方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: DBConnector
# 需要導入模塊: from domogik.common.database import DbHelper [as 別名]
# 或者: from domogik.common.database.DbHelper import update_device [as 別名]
#.........這裏部分代碼省略.........
if reason:
msg.add_data('reason', reason)
self.log.debug(msg.get())
self.reply(msg.get())
# send the pub message
if status and res:
dev = self._db.get_device(res.device_id)
self._pub.send_event('device.update',
{"device_id" : res.device_id,
"client_id" : dev['client_id']})
def _mdp_reply_devices_update_result(self, data):
status = True
reason = False
self.log.debug(u"Updating device : {0}".format(data))
try:
data = data.get_data()
if 'did' in data:
did = data['did']
if 'name' not in data:
name = None
else:
name = data['name']
if 'reference' not in data:
ref = None
else:
ref = data['reference']
if 'description' not in data:
desc = None
else:
desc = data['description']
# do the update
res = self._db.update_device(did, \
d_name=name, \
d_description=desc, \
d_reference=ref)
if not res:
status = False
else:
status = True
else:
status = False
reason = "There is no such device"
self.log.debug(reason)
# delete done
except DbHelperException as d:
status = False
reason = "Error while updating device: {0}".format(d.value)
self.log.error(reason)
except:
status = False
reason = "Error while updating device: {0}".format(traceback.format_exc())
self.log.error(reason)
# send the result
msg = MQMessage()
msg.set_action('device.update.result')
msg.add_data('status', status)
if reason:
msg.add_data('reason', reason)
self.log.debug(msg.get())
self.reply(msg.get())
# send the pub message
if status and res:
self._pub.send_event('device.update',
{"device_id" : res.id,