in leda_python/deviceMbus.py [0:0]
def _getDeviceProfile(self, interface):
@dbus.service.method(interface, out_signature='s')
def getDeviceProfile(self):
_logger.debug("cloud_id:%s, method: getDeviceProfile", self.cloud_id)
try:
profile = self.callback_funs.getprofile_cb()
if (False == isinstance(profile, str)):
_logger.warning("getprofile_cb(cloud_id:%s) return args type is invalid: %s", self.cloud_id,
type(profile))
retDict = {
"code": exception.LEDA_ERROR_INVAILD_PARAM, # params invalid
"message": "getprofile_cb(cloud_id:%s) return args type is invalid: %s" % (
self.cloud_id, type(profile))
}
_logger.debug("getDeviceProfile(cloud_id:%s): retMsg: %s", self.cloud_id, retDict)
return json.dumps(retDict, ensure_ascii = False)
profile_dict = json.loads(profile)
except(AttributeError, ValueError, TypeError) as err:
_logger.warning('%s', err)
retDict = {
"code": exception.LEDA_ERROR_INVAILD_PARAM, # params invalid
"message": "%s" % (err)
}
_logger.debug("getDeviceProfile(cloud_id:%s): retMsg: %s", self.cloud_id, retDict)
return json.dumps(retDict, ensure_ascii = False)
except:
_logger.exception("Err")
retDict = {
"code": exception.LEDA_ERROR_FAILED, # params invalid
"message": "unkonwn error"
}
_logger.debug("getDeviceProfile(cloud_id:%s): retMsg: %s", self.cloud_id, retDict)
return json.dumps(retDict, ensure_ascii = False)
retDict = {
"code": exception.LEDA_SUCCESS,
"message": "successfully",
"params": {
"deviceProfile": profile_dict
}
}
_logger.debug("getDeviceProfile(cloud_id:%s): retMsg: %s", self.cloud_id, retDict)
return json.dumps(retDict, ensure_ascii = False)
return getDeviceProfile