本文整理汇总了Python中com.cloudMedia.theKuroBox.sdk.util.logger.Logger.log_info方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.log_info方法的具体用法?Python Logger.log_info怎么用?Python Logger.log_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.cloudMedia.theKuroBox.sdk.util.logger.Logger
的用法示例。
在下文中一共展示了Logger.log_info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
# 需要导入模块: from com.cloudMedia.theKuroBox.sdk.util.logger import Logger [as 别名]
# 或者: from com.cloudMedia.theKuroBox.sdk.util.logger.Logger import log_info [as 别名]
def start(self):
'''
Initialize all services required by automation app.
'''
MethodController.instance() # Must listen to groups and methods added event before bootstrap.
# Bootstrap
try:
bs = BootstrapService()
Logger.log_info("Bootstrap update kbx method ...")
bs.update_kbx_method()
Logger.log_info("Bootstrap update kbx group ...")
bs.update_kbx_group()
Logger.log_info("Bootstrap register trigger schedulers ...")
bs.register_trigger_schedulers()
Logger.log_info("Bootstrap register timer module schedulers ...")
bs.register_timer_module_schedulers()
except Exception as e:
bs.rollback()
Logger.log_error("AutomationModuleWrapper.start bootstrap ex:", e)
traceback.print_exc()
raise e
else:
bs.commit()
Logger.log_info("Bootstrap process completed!")
self.__apiService = APIService()
self.__ruleService = RuleService()
self.__sceneService = SceneService()
self.__serService = SceneExecutionResultService.instance()
示例2: db_3_update
# 需要导入模块: from com.cloudMedia.theKuroBox.sdk.util.logger import Logger [as 别名]
# 或者: from com.cloudMedia.theKuroBox.sdk.util.logger.Logger import log_info [as 别名]
def db_3_update(self, resourcePath):
''' convert all "rgb" to "hsb" '''
from com.cloudMedia.theKuroBox.sdk.util.colorUtils import ColorUtils
for idCol, tableName in [("reId", "rule_execution"), ("seId", "scene_execution")]:
toBeUpdateds = deque()
rows = self.__con.execute('SELECT "' + idCol + '", "kbxMethodParams" ' + \
'FROM "' + tableName + '" ' + \
'WHERE "kbxMethodParams" LIKE ?', ('%"r"%', )).fetchall()
for row in rows:
methodRow = dict(row)
kbxMethodParams = methodRow["kbxMethodParams"]
for kbxMethodParam in kbxMethodParams:
kbxParamCurrentValue = kbxMethodParam["kbxParamCurrentValue"]
if isinstance(kbxParamCurrentValue, dict):
if not {"r", "g", "b"}.difference(kbxParamCurrentValue):
hsbDict = ColorUtils.rgb_to_hsb(kbxParamCurrentValue["r"],
kbxParamCurrentValue["g"],
kbxParamCurrentValue["b"])
kbxMethodParam["kbxParamCurrentValue"] = hsbDict
toBeUpdateds.append(methodRow)
for methodRow in toBeUpdateds:
self.__con.execute('UPDATE "' + tableName + '" SET "kbxMethodParams"=? WHERE "' + idCol + '"=?',
(methodRow["kbxMethodParams"], methodRow[idCol]))
Logger.log_info("Database v3 update: RGB -> HSB (%i entries from %s migrated)" % (len(toBeUpdateds), str(tableName)))
Logger.log_info("Database v3 update completed")
示例3: post_system_connected
# 需要导入模块: from com.cloudMedia.theKuroBox.sdk.util.logger import Logger [as 别名]
# 或者: from com.cloudMedia.theKuroBox.sdk.util.logger.Logger import log_info [as 别名]
def post_system_connected(self):
super().post_system_connected()
Logger.log_info("post_system_connected starts...")
DebugModule.DEBUG_POST_SYSTEM_CONNECTED.append(time.time())
self.__automationModule.start()
Logger.log_info("post_system_connected ends...")
示例4: __broadcast_message__rule_updated
# 需要导入模块: from com.cloudMedia.theKuroBox.sdk.util.logger import Logger [as 别名]
# 或者: from com.cloudMedia.theKuroBox.sdk.util.logger.Logger import log_info [as 别名]
def __broadcast_message__rule_updated(self, ruleId):
try:
rule = self.__ruleController.get_summary(ruleId)
except Exception as e:
Logger.log_error("RuleService.__broadcast_message__rule_updated get_summary ex:", e)
return
eventTag = AppConstants.EVENT_RULE_UPDATED
eventData = rule
self.__broadcast_message(eventTag, eventData)
Logger.log_info("Rule Updated:", rule["ruleName"])
示例5: __broadcast_message__scene_updated
# 需要导入模块: from com.cloudMedia.theKuroBox.sdk.util.logger import Logger [as 别名]
# 或者: from com.cloudMedia.theKuroBox.sdk.util.logger.Logger import log_info [as 别名]
def __broadcast_message__scene_updated(self, sceneId):
try:
scene = self.__sceneController.get_summary(sceneId)
except Exception as e:
Logger.log_error("SceneService.__broadcast_message__scene_updated get_summary ex:", e)
scene = None
eventTag = AppConstants.EVENT_SCENE_UPDATED
eventData = {"sceneId":sceneId, "newSceneSummary":scene}
self.__broadcast_message(eventTag, eventData)
Logger.log_info("Scene Updated:", scene["sceneName"])
示例6: __broadcast_message__scene_update_failed
# 需要导入模块: from com.cloudMedia.theKuroBox.sdk.util.logger import Logger [as 别名]
# 或者: from com.cloudMedia.theKuroBox.sdk.util.logger.Logger import log_info [as 别名]
def __broadcast_message__scene_update_failed(self, sceneId, sceneName=None):
'''
sceneName - For debugging purpose.
'''
try:
scene = self.__sceneController.get_summary(sceneId)
except Exception:
scene = None
eventTag = AppConstants.EVENT_SCENE_UPDATE_FAILED
eventData = {"sceneId": sceneId, "oldSceneSummary":scene}
self.__broadcast_message(eventTag, eventData)
Logger.log_info("Scene Update Failed:", sceneName)
示例7: __broadcast_message__rule_update_failed
# 需要导入模块: from com.cloudMedia.theKuroBox.sdk.util.logger import Logger [as 别名]
# 或者: from com.cloudMedia.theKuroBox.sdk.util.logger.Logger import log_info [as 别名]
def __broadcast_message__rule_update_failed(self, ruleId, ruleName=None):
'''
ruleName - For debugging purpose.
'''
try:
rule = self.__ruleController.get_summary(ruleId)
except Exception:
rule = None
eventTag = AppConstants.EVENT_RULE_UPDATE_FAILED
eventData = {"ruleId": ruleId, "oldRuleSummary":rule}
self.__broadcast_message(eventTag, eventData)
Logger.log_info("Rule Update Failed:", ruleName)
示例8: __broadcast_message__rule_update_started
# 需要导入模块: from com.cloudMedia.theKuroBox.sdk.util.logger import Logger [as 别名]
# 或者: from com.cloudMedia.theKuroBox.sdk.util.logger.Logger import log_info [as 别名]
def __broadcast_message__rule_update_started(self, ruleId, ruleName=None):
eventTag = AppConstants.EVENT_RULE_UPDATE_STARTED
eventData = {"ruleId":ruleId, "newRuleName":ruleName}
self.__broadcast_message(eventTag, eventData)
Logger.log_info("Rule Start Update:", ruleName)
示例9: db_2_update
# 需要导入模块: from com.cloudMedia.theKuroBox.sdk.util.logger import Logger [as 别名]
# 或者: from com.cloudMedia.theKuroBox.sdk.util.logger.Logger import log_info [as 别名]
def db_2_update(self, resourcePath):
self.__execute_script("/".join([resourcePath, "tablestructure.sql"]))
Logger.log_info("Database v2 update: Table structures built")
Logger.log_info("Database v2 update completed")
示例10: db_1_update
# 需要导入模块: from com.cloudMedia.theKuroBox.sdk.util.logger import Logger [as 别名]
# 或者: from com.cloudMedia.theKuroBox.sdk.util.logger.Logger import log_info [as 别名]
def db_1_update(self, resourcePath):
Logger.log_info("Database v1 update started")
self.__execute_script("/".join([resourcePath, "tablestructure.sql"]))
Logger.log_info("Database v1 update: Table structures built")
# #################### Migration codes ####################
try:
from automationApp.migration.storage import Storage
allGroups = Storage.list_all_groups()
if len(allGroups) > 0: # Probably no rule is set.
'''
All Groups: e.g. {25: 'Yeelight Blue II'}
'''
for kbxGroupId, kbxGroupLabel in allGroups.items():
self.__con.execute('INSERT INTO "kbx_group"("kbxGroupId", "kbxGroupLabel", "kbxGroupStatus") VALUES (?, ?, ?)',
(kbxGroupId, kbxGroupLabel, -1))
del(allGroups)
'''
All Groups Methods: e.g. {69: 25, 71: 25}
'''
allMethodGroups = Storage.list_all_method_groups()
for kbxMethodId, kbxGroupId in allMethodGroups.items():
self.__con.execute('INSERT INTO "kbx_method"("kbxMethodId", "kbxGroupId", "kbxMethodStatus") ' + \
'VALUES (?, ?, ?)',
(kbxMethodId, kbxGroupId, -1))
'''
All Rules: e.g. [{
'execution': [{'kbxMethodId': 71, 'kbxMethodParams': [{'kbxParamCurrentValue': '4', 'kbxParamName': 'pairedDeviceId'},{'kbxParamCurrentValue': [False], 'kbxParamName': 'on'}]}],
'trigger': {'type': 0, 'value': None},
'ruleId': '1425284835.0756288',
'enabled': True,
'condition': [{'kbxMethodId': 69, 'kbxMethodParams': [{'kbxParamCurrentValue': '4', 'kbxParamName': 'pairedDeviceId'}, {'kbxParamCurrentValue': [True], 'kbxParamName': 'on'}]}],
'ruleName': 'ReTestet'
}]
'''
allRules = Storage.list_all_rules()
cursor = self.__con.cursor()
createdTime = updatedTime = time.time()
triggerController = TriggerController.instance()
for sort, rule in enumerate(allRules):
trigger = triggerController.parse_to_trigger_dto(rule["trigger"])
cursor.execute('INSERT INTO "rule"("ruleName", "ruleProtected", "trigger", "enabled", "statusProcessed", "createdTime", "updatedTime", "sort") ' + \
'VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
(rule["ruleName"], False, json.dumps(trigger),
rule["enabled"], "updated", createdTime,
updatedTime, sort))
ruleId = cursor.lastrowid
for vals in (["execution", "rule_execution", "reRuleId"], ["condition", "rule_condition", "rcRuleId"]):
for kbxMethodSort, kbxMethodWithCurrentValue in enumerate(rule[vals[0]]):
self.__con.execute('INSERT INTO "' + vals[1] + '"("' + vals[2] + '", "kbxMethodId", "kbxMethodParams", "createdTime", "sort") ' + \
'VALUES (?, ?, ?, ?, ?)',
(ruleId, kbxMethodWithCurrentValue["kbxMethodId"],
json.dumps(kbxMethodWithCurrentValue["kbxMethodParams"]),
createdTime, kbxMethodSort))
cursor.close()
del(allRules)
self.__con.commit()
except Exception as e:
self.__con.rollback()
Logger.log_warning("Database failed to migrate rules from system, ex:", e , "---- rolled back")
else:
Logger.log_info("Database v1 update: Rules migrated")
try:
Storage.delete_all_rules()
Storage.delete_all_method_groups()
Storage.delete_all_groups()
except Exception as e:
Logger.log_warning("Database failed to remove rules from system after migration, ex:", e)
# #################### End of migration codes ####################
self.__execute_script("/".join([resourcePath, "triggers.sql"]))
Logger.log_info("Database v1 update: Triggers built")
self.__execute_script("/".join([resourcePath, "indexes.sql"]))
Logger.log_info("Database v1 update: Indexes built")
Logger.log_info("Database v1 update completed")
示例11: __trigger_rule_implementation
# 需要导入模块: from com.cloudMedia.theKuroBox.sdk.util.logger import Logger [as 别名]
# 或者: from com.cloudMedia.theKuroBox.sdk.util.logger.Logger import log_info [as 别名]
def __trigger_rule_implementation(self, ruleId, checkCondition=False, eventTag=None, eventData=None, eventMethodId=None):
'''
Triggers a rule by given ruleId.
'''
Logger.log_info("trigger rule id:", ruleId)
# Check if rule is "updated" AND enabled.
statusProcessed, enabled = self.__ruleController.get_status_processed_and_enabled(ruleId)
if statusProcessed != AppConstants.RULE_STATUS_UPDATED or enabled != True:
return
self.__ruleExecInfos.setdefault(ruleId, RuleExecInfo())
ruleExecInfo = self.__ruleExecInfos.get(ruleId)
ruleExecInfo.increase_trigger_count()
triggerCountInThisSession = ruleExecInfo.get_trigger_count()
with ruleExecInfo.get_rlock():
#=======================================================================
# Check conditions
#=======================================================================
if checkCondition is True:
# Check if we should proceed (stop if there is another pending request on the same ruleId).
if triggerCountInThisSession != ruleExecInfo.get_trigger_count():
return
methodListToCheck = deque()
result = self.__ruleController.list_conditions(ruleId)
methodCheckingTime = int(time.time())
for row in result:
if row["kbxMethodStatus"] not in (SharedMethod.METHOD_STATUS_ACTIVE, SharedMethod.METHOD_STATUS_INACTIVE):
return
else:
methodArgs = row["kbxMethodParams"]
kwargs = {methodArg[AppConstants.ARG_NAME]:methodArg[AppConstants.ARG_CURRENT_VALUE] for methodArg in methodArgs}
if eventTag is not None and eventMethodId == row["kbxMethodId"]:
kwargs[AppConstants.KEY_CONDITION_EVENT_TAG] = eventTag
kwargs[AppConstants.KEY_CONDITION_EVENT_DATA] = eventData
if AppInfo.REQUEST_KEY_LANGUAGE not in kwargs:
kwargs[AppInfo.REQUEST_KEY_LANGUAGE] = AppInfo.DEFAULT_API_LANGUAGE
kwargs["kbxMethodName"] = row["kbxMethodName"]
kwargs["kbxModuleName"] = row["kbxModuleName"]
kwargs["kbxGroupId"] = row["kbxGroupId"]
kwargs["kbxMethodAppId"] = row["kbxMethodAppId"]
# Update ruleId if it is required by the method
if "ruleId" in kwargs:
kwargs["ruleId"] = str(ruleId)
callId = hash(str(kwargs)) # Generate condition checking ID
kwargs[AppConstants.KEY_CONDITION_TIMESTAMP] = methodCheckingTime # So that timestamp will not caused the generated id to be different
methodListToCheck.append({"callId":callId,
"callFn":SharedMethod.call,
"callKwargs":kwargs})
#===============================================================
# Submit all conditions for checking
#===============================================================
methodListToCheckLen = len(methodListToCheck)
if methodListToCheckLen > 0:
ruleExecResult = RuleExecResult(methodListToCheckLen)
for methodItem in methodListToCheck:
self.__condCallGroup.submit(callbackFn=self.__on_method_call_complete, ruleExecResult=ruleExecResult, **methodItem)
result = ruleExecResult.wait(40.0)
if result is False or ruleExecResult.get_result() is False:
return # Failed at condition checking.
# Clear cache
del(methodListToCheck)
del(methodCheckingTime)
del(methodListToCheckLen)
# Check if we should proceed (stop if there is another pending request on the same ruleId).
if triggerCountInThisSession != ruleExecInfo.get_trigger_count():
return
#=======================================================================
# Execute executions
#=======================================================================
methodListToExec = deque()
result = self.__ruleController.list_executions(ruleId)
methodExecTime = int(time.time())
for row in result:
if row["kbxMethodStatus"] not in (SharedMethod.METHOD_STATUS_ACTIVE, SharedMethod.METHOD_STATUS_INACTIVE):
continue
else:
methodArgs = row["kbxMethodParams"]
kwargs = {methodArg[AppConstants.ARG_NAME]:methodArg[AppConstants.ARG_CURRENT_VALUE] for methodArg in methodArgs}
if AppInfo.REQUEST_KEY_LANGUAGE not in kwargs:
kwargs[AppInfo.REQUEST_KEY_LANGUAGE] = AppInfo.DEFAULT_API_LANGUAGE
kwargs["kbxMethodName"] = row["kbxMethodName"]
kwargs["kbxModuleName"] = row["kbxModuleName"]
#.........这里部分代码省略.........
示例12: __execute_scene_implementation
# 需要导入模块: from com.cloudMedia.theKuroBox.sdk.util.logger import Logger [as 别名]
# 或者: from com.cloudMedia.theKuroBox.sdk.util.logger.Logger import log_info [as 别名]
def __execute_scene_implementation(self, sceneId, execution, serObj, language):
'''
** Call execute_scene; DO NOT call this function directly.
'''
Logger.log_info("execute scene id:", sceneId)
def execution_func(sceneThreadEvent, kbxMethodId, seri, **kwargs):
try:
if kbxMethodId == -291:
# Delay Timer
delayInSec = kwargs["delayInSec"]
sceneThreadEvent.wait(delayInSec)
seri["seriError"] = None
else:
# Execute method
result = SharedMethod.call(**kwargs)
seri["seriError"] = str(result)
seri["seriStatus"] = "ok"
except Exception as e:
seri["seriStatus"] = "error"
seri["seriError"] = str(e)
Logger.log_debug("Execution failed, method:", kwargs["kbxMethodName"])
finally:
sceneThreadEvent.set()
try:
# Record for debugging purpose
serStartTime = time.time()
#===================================================================
# Prepare to execute execution methods
#===================================================================
sceneExecLock = self.__sceneExecLocks.get(sceneId)
sceneThreadEvent = sceneExecLock.get_thread_event()
seris = deque()
methodExecTime = int(time.time())
isLoopCompleted = True
for row in execution:
kbxMethodId = row["kbxMethodId"]
kbxMethodName = row["kbxMethodName"]
kbxGroupId = row["kbxGroupId"]
kbxMethodStatus = row["kbxMethodStatus"]
methodParamsWithCurrentValues = row["kbxMethodParams"]
seri = {"kbxMethodId":kbxMethodId,
"kbxGroupId":kbxGroupId,
"kbxMethodName":kbxMethodName,
"kbxMethodParams":methodParamsWithCurrentValues}
seris.append(seri)
# Check is stop
if sceneExecLock.is_stop():
if not isLoopCompleted:
serEndTime = time.time()
isLoopCompleted = False
# === Execution interrupted ===
continue
# Check is method not removed
elif kbxMethodStatus not in (SharedMethod.METHOD_STATUS_ACTIVE, SharedMethod.METHOD_STATUS_INACTIVE):
seri["seriStatus"] = "error"
seri["seriError"] = "method is removed"
continue
kwargs = {methodParam[AppConstants.ARG_NAME]: methodParam[AppConstants.ARG_CURRENT_VALUE]
for methodParam in methodParamsWithCurrentValues}
if AppInfo.REQUEST_KEY_LANGUAGE not in kwargs:
kwargs[AppInfo.REQUEST_KEY_LANGUAGE] = AppInfo.DEFAULT_API_LANGUAGE
kwargs["kbxMethodName"] = kbxMethodName
kwargs["kbxGroupId"] = kbxGroupId
kwargs["kbxModuleName"] = row["kbxModuleName"]
kwargs["kbxMethodAppId"] = row["kbxMethodAppId"]
kwargs[AppConstants.KEY_ACTION_TIMESTAMP] = methodExecTime
#===========================================================
# Execute method
#===========================================================
sceneThreadEvent.clear()
execThread = threading.Thread(target=execution_func, args=[sceneThreadEvent, row["kbxMethodId"], seri], kwargs=kwargs)
execThread.daemon = False
execThread.start()
sceneThreadEvent.wait() # Event will be set by "stop_scene" or SharedMethod.call returns.
# Check is stop
if sceneExecLock.is_stop():
if not isLoopCompleted:
serEndTime = time.time()
isLoopCompleted = False
# === Execution interrupted ===
continue
if isLoopCompleted:
# Record for debugging purpose
#.........这里部分代码省略.........
示例13: __broadcast_message__favorited_scene_deleted
# 需要导入模块: from com.cloudMedia.theKuroBox.sdk.util.logger import Logger [as 别名]
# 或者: from com.cloudMedia.theKuroBox.sdk.util.logger.Logger import log_info [as 别名]
def __broadcast_message__favorited_scene_deleted(self, sceneId):
eventTag = AppConstants.EVENT_FAVORITED_SCENE_DELETED
eventData = {"sceneId":sceneId}
self.__broadcast_message(eventTag, eventData)
Logger.log_info("Favorited scene deleted: Id", sceneId)
示例14: __broadcast_message__favorited_scene_added
# 需要导入模块: from com.cloudMedia.theKuroBox.sdk.util.logger import Logger [as 别名]
# 或者: from com.cloudMedia.theKuroBox.sdk.util.logger.Logger import log_info [as 别名]
def __broadcast_message__favorited_scene_added(self, sceneId, prevSceneId):
eventTag = AppConstants.EVENT_FAVORITED_SCENE_ADDED
eventData = {"sceneId":sceneId, "prevSceneId":prevSceneId}
self.__broadcast_message(eventTag, eventData)
Logger.log_info("Favorited scene added/updated: Id", sceneId, "prevId:", prevSceneId)
示例15: __broadcast_message__scene_deleted
# 需要导入模块: from com.cloudMedia.theKuroBox.sdk.util.logger import Logger [as 别名]
# 或者: from com.cloudMedia.theKuroBox.sdk.util.logger.Logger import log_info [as 别名]
def __broadcast_message__scene_deleted(self, sceneId):
eventTag = AppConstants.EVENT_SCENE_DELETED
eventData = {"sceneId": sceneId}
self.__broadcast_message(eventTag, eventData)
Logger.log_info("Scene Deleted: Id -", sceneId)