当前位置: 首页>>代码示例>>Python>>正文


Python logger.Logger类代码示例

本文整理汇总了Python中com.cloudMedia.theKuroBox.sdk.util.logger.Logger的典型用法代码示例。如果您正苦于以下问题:Python Logger类的具体用法?Python Logger怎么用?Python Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Logger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: db_3_update

 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")
开发者ID:TheStackBox,项目名称:xuansdk,代码行数:30,代码来源:database.py

示例2: __add_scheduler

    def __add_scheduler(ruleId, kbxMethodIdentifier, second, minute, hour, dayOfMonth, month, dayOfWeek):
        '''
        second="0", minute="*", hour="*", dayOfMonth="*", month="*", dayOfWeek="*"
        '''
        try:
            uniqueName = "_".join([kbxMethodIdentifier, second, minute, hour, dayOfMonth, month, dayOfWeek])
            schedulerName = hash(uniqueName)
            
            if schedulerName not in TimerModule.SCHEDULER_ID_TRACKER:
                SchedulerService.add_cron_job(str(schedulerName),
                                              kbxTargetAppId=AppInfo.get_app_id(),
                                              kbxTargetMethod="scheduler_callback",
                                              kbxTargetModule="timer_module",
                                              second=second,
                                              minute=minute,
                                              hour=hour,
                                              dayOfMonth=dayOfMonth,
                                              month=month,
                                              dayOfWeek=dayOfWeek,
                                              kbxTargetParams={"kbxMethodIdentifier":kbxMethodIdentifier},
                                              store=False)
    
                TimerModule.SCHEDULER_ID_TRACKER[schedulerName] = [ruleId]
                TimerModule.RULE_ID_SCHEDULER_TRACKER[ruleId] = [schedulerName]
                
                Logger.log_debug("Added Timer:", schedulerName, uniqueName)
            else:
                TimerModule.SCHEDULER_ID_TRACKER[schedulerName].append(ruleId)
                TimerModule.RULE_ID_SCHEDULER_TRACKER[ruleId].append(schedulerName)

        except Exception as e:
            Logger.log_warning("Failed to add timer:", e)
开发者ID:TheStackBox,项目名称:xuansdk,代码行数:32,代码来源:timerModule.py

示例3: commit

 def commit(self):
     with self.__rlock:
         try:
             return self.__con.commit()
         except Exception as e:
             Logger.log_error("Database.commit ex:", e)
             traceback.print_exc()
开发者ID:TheStackBox,项目名称:xuansdk,代码行数:7,代码来源:database.py

示例4: __on_record_deleted

 def __on_record_deleted(self, kbxMethodId, kbxMethodEvent, kbxMethodIdentifier):
     result = self.__db.execute('SELECT COUNT(kbxMethodId) AS "total" FROM "event" WHERE "kbxMethodEvent"=?', (kbxMethodEvent,)).fetchall()
     if result[0]["total"] == 0:
         try:
             self.on_event_deleted(kbxMethodEvent)
         except Exception as e:
             Logger.log_warning("EventController.__on_record_added ex:", e, "- tag:", kbxMethodEvent)
开发者ID:TheStackBox,项目名称:xuansdk,代码行数:7,代码来源:eventController.py

示例5: rollback

 def rollback(self):
     with self.__rlock:
         try:
             return self.__con.rollback()
         except Exception as e:
             Logger.log_error("Database.rollback ex:", e)
             traceback.print_exc()
开发者ID:TheStackBox,项目名称:xuansdk,代码行数:7,代码来源:database.py

示例6: __date_time_range

 def __date_time_range(self, request):
     try:
         dtVal = request.get_value(TimerModule._PARAM_DT_RANGE.get_kbx_param_name())
         startDateTime = dtVal.get_start_date_time()
         endDateTime = dtVal.get_end_date_time()
         
         execTime = request.get_arg(AppConstants.KEY_CONDITION_TIMESTAMP)
         execTime = int(execTime)
         
         if execTime > endDateTime:
             # Allow a time delta of 59 seconds
             response = bool(abs(execTime - endDateTime) <= 59)
         else:
             response =  bool(startDateTime <= execTime <= endDateTime)
         
         if not response:
             raise AutomationException(11800)
             
         self.send_response({}, request.requestId)
     except AutomationException as ae:
         Logger.log_error("TimerModule date_time range failed on comparison:", str(ae))
         self.send_response({}, request.requestId, ae.get_error_code(), ae.get_error_message())
     except Exception as e:
         Logger.log_error("TimerModule date_time range failed on comparison (unexpected):", str(e))
         ae = AutomationException(11099, str(e))
         self.send_response({}, request.requestId, ae.get_error_code(), ae.get_error_message())
开发者ID:TheStackBox,项目名称:xuansdk,代码行数:26,代码来源:timerModule.py

示例7: list_all_rules

    def list_all_rules():
        offset = 0
        limit = 50

        totalCount = 1
        allRules = deque()
        while(offset < totalCount):
            try:
                result = StorageManagerService.get_data(group=Storage.STORAGE_RULE, limit=limit, offset=offset)

                result = ValueParser.get_dict(result)

                rules = ValueParser.get_list(result["data"])
                totalCount = int(result["totalRecord"])
                offset += limit

                if rules:
                    for rule in rules:
                        rule = ValueParser.get_dict(rule.get("appDataValue"))
                        allRules.append(rule)

            except Exception as e:
                Logger.log_debug("Storage.list_all_rules err: " + str(e))
                break
        return allRules
开发者ID:TheStackBox,项目名称:xuansdk,代码行数:25,代码来源:storage.py

示例8: __update_rule

 def __update_rule(rule):
     try:
         # Fire rule update start event
         ruleId = rule["ruleId"]
         
         # Add methods to subscribe list
         methodIds = [kbxMethod["kbxMethodId"] for kbxMethod in rule["condition"] + rule["execution"]]
         self.__methodController.add(methodIds)
         
         # Update "rule" base table
         self.__ruleController.update(rule)
         self.__ruleController.commit()
     
     except Exception as e:
         self.__ruleController.rollback()
         self.__broadcast_message__rule_update_failed(ruleId, ruleName)
         Logger.log_error("RuleService __update_rule failed:", e, "-- rolledback")
     else:
         self.__triggerController.register_listener(ruleId, rule["trigger"])
         
         # Process for Timer Module
         TimerModule.delete_scheduler(ruleId)
         
         timerModuleHandlers = {TimerModule.METHOD_ID_DATE_TIME_RANGE:TimerModule.handle_date_time_range,
                                TimerModule.METHOD_ID_DAY_OF_WEEK:TimerModule.handle_dow,
                                TimerModule.METHOD_ID_TIME_RANGE:TimerModule.handle_time_range}
         
         for kbxMethod in rule["condition"]:
             kbxMethodId = kbxMethod["kbxMethodId"]
             timerModuleHandler = timerModuleHandlers.get(kbxMethodId, None)
             if timerModuleHandler is not None:
                 timerModuleHandler(ruleId, kbxMethod["kbxMethodParams"])
             
         # Broadcast message: completed updating a rule
         self.__broadcast_message__rule_updated(ruleId)
开发者ID:TheStackBox,项目名称:xuansdk,代码行数:35,代码来源:ruleService.py

示例9: delete_favorited_scene

 def delete_favorited_scene(self, sceneId):
     '''
     sceneId - must be a favorited scene.
     '''
     with self.__fav_lock:
         try:
             favSort = self.__sceneController.get_favsort_of(sceneId)
         except Exception as e:
             raise AutomationException(11092, "prevSceneId does not belongs to any scene - " + \
                                             "prevSceneId provided: " + str(sceneId) + ", error: " + str(e))
         else:
             if favSort is None:
                 raise AutomationException(13000, "sceneId does not belongs to any favorited scene - " + \
                                                 "sceneId provided: " + str(sceneId))
         
         # This method raise error and rollback automatically if failed, or commit once succeed.
         try:
             self.__sceneController.delete_favorited_scene(sceneId)
             self.__sceneController.commit()
         except Exception as e:
             self.__sceneController.rollback()
             Logger.log_error("SceneService.delete_favorited_scene failed to delete favorited scene, ex:", str(e))
             raise AutomationException(13002, "unexpected error: " + str(e))
         
         #Broadcast event
         self.__broadcast_message__scene_updated(sceneId)
         self.__broadcast_message__favorited_scene_deleted(sceneId)
开发者ID:TheStackBox,项目名称:xuansdk,代码行数:27,代码来源:sceneService.py

示例10: list_groups

    def list_groups(self, language, section, parentId=None):
        try:
            def sort_group_list(value):
                name = value.get("kbxGroupLabel")
                if name is None:
                    return ""
                else:
                    return str(name).lower()
                
            
            unknownGroupDict = {}
            unknownGroupId = self.__get_group_ids()
                
            parentId = AppConstants.GROUP_ID_AUTOMATION if parentId is None else parentId

            result = SharedMethod.list_shared_method_groups(kbxGroupParentId=parentId, kbxMethodTag=section,
                                                            enableTagCount=True, language=language)
            
            groupList = result["groupList"]
            
            # Level 1 groups which contain of SERVICES and LOCATIONS.
            if parentId == AppConstants.GROUP_ID_AUTOMATION:
                services = deque()
                groups =  deque()
                
                for groupDict in groupList:
                    kbxGroupId = groupDict["kbxGroupId"]
                    
                    # Add indicator for UI
                    groupDict["kbxGroupHasChild"] = True

                    # Reordering
                    if kbxGroupId == AppConstants.GROUP_ID_NOTIFICATION:
                        groupDict["kbxGroupDesc"] = KBXLang("group_notification_" + section)
                        services.appendleft(groupDict)
                    elif kbxGroupId == AppConstants.GROUP_ID_SERVICE:
                        groupDict["kbxGroupDesc"] = KBXLang("group_service_" + section)
                        services.append(groupDict)
                    elif kbxGroupId == unknownGroupId:
                        #append the group dict
                        unknownGroupDict = groupDict
                    else:
                        groups.append(groupDict)
                groups = sorted(groups, key=sort_group_list)
                if len(unknownGroupDict) > 0:
                    groups.append(unknownGroupDict)
                services.extend(groups)
                groupList = services
                parentGroup = None
                
            # Level 2 groups which are DEVICES or SERVICES.
            else:
                parentGroup = SharedMethod.get_shared_method_group_by_id(kbxGroupId=parentId, language=language)

            return parentGroup, groupList

        except Exception as e:
            Logger.log_error("APIService.list_groups ex:", e)
            raise AutomationException(11601, "Unexpected error - " + str(e))
开发者ID:TheStackBox,项目名称:xuansdk,代码行数:59,代码来源:apiService.py

示例11: kbx_method_after_delete

 def kbx_method_after_delete(self, kbxMethodId, kbxGroupId):
     if Util.is_empty(kbxGroupId):
         return
     self.__delete_kbx_group_if_necessary(kbxGroupId)
     
     try:
         Database.KBX_METHOD_AFTER_DELETE(kbxMethodId)
     except Exception as e:
         Logger.log_warning("Database.KBX_METHOD_AFTER_DELETE raised error:", e)
开发者ID:TheStackBox,项目名称:xuansdk,代码行数:9,代码来源:database.py

示例12: on_method_status_change

                def on_method_status_change(*args, **kwargs):
                    
                    with self.__lock___method_status_change: 

                        for callback in self.__method_status_change_callbacks:
                            try:
                                callback(*args, **kwargs)
                            except Exception as e:
                                Logger.log_warning("MethodController.listen_to_method_status_change.on_method_status_change callback ex:", e)
开发者ID:TheStackBox,项目名称:xuansdk,代码行数:9,代码来源:methodController.py

示例13: on_group_icon_change

                def on_group_icon_change(*args, **kwargs):
                    
                    with self.__lock___group_icon_change: 

                        for callback in self.__group_icon_change_callbacks:
                            try:
                                callback(*args, **kwargs)
                            except Exception as e:
                                Logger.log_warning("GroupController.listen_to_group_icon_change.on_group_icon_change callback ex:", e)
开发者ID:TheStackBox,项目名称:xuansdk,代码行数:9,代码来源:groupController.py

示例14: post_system_connected

    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...")
开发者ID:TheStackBox,项目名称:xuansdk,代码行数:10,代码来源:automationApp.py

示例15: __on_shared_method_updated

 def __on_shared_method_updated(self, eventObject):
     '''
     Triggered based on event broadcasted by system app.
     '''
     try:
         kbxMethod = json.loads(eventObject["eventData"]) # eventData = kbxMethod
         self.update(kbxMethod)
     except Exception as e:
         Logger.log_error("MethodController.__on_shared_method_updated ex:", e)
         traceback.print_exc()
开发者ID:TheStackBox,项目名称:xuansdk,代码行数:10,代码来源:methodController.py


注:本文中的com.cloudMedia.theKuroBox.sdk.util.logger.Logger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。