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


Python ISLogger.Logger类代码示例

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


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

示例1: allow_cloud_ip

 def allow_cloud_ip(self):
     # This function allows the cloud ip from UFW
     # Will remove any old ips of cloud dns
     try:
             
             new_cloud_ip = socket.gethostbyname(cfg.cloud_dns_name)
             old_cloud_ip = CF.load_dictionary_object(script_path + "cloud_ip")
             
             if old_cloud_ip == None:
                 # Create a dictionary and add a new rule
                 #---------------------------------------
                 dict = {'cloud_ip':new_cloud_ip,'port':cfg.hub_opened_port, 'last_updated_date' : datetime.utcnow().isoformat()}
                 self.add_remove_ufw_rule(True, str(cfg.hub_opened_port), new_cloud_ip)
                 
                 CF.save_dictionary_object(script_path + "cloud_ip", dict)
                 
             else:
                 # update rule and update ip file
                 #-------------------------------
                 
                 if not (new_cloud_ip + str(cfg.hub_opened_port)) == (old_cloud_ip['cloud_ip'] + str(old_cloud_ip['port'])) :
                     self.add_remove_ufw_rule(False, str(old_cloud_ip['port']), old_cloud_ip['cloud_ip'])
                     self.add_remove_ufw_rule(True, str(cfg.hub_opened_port), new_cloud_ip)
                     dict = {'cloud_ip':new_cloud_ip, 'port':cfg.hub_opened_port, 'last_updated_date' : datetime.utcnow().isoformat()}
                     CF.save_dictionary_object(script_path + "cloud_ip", dict)
             
     except Exception as e:
         
         Logger.log_debug('ERROR @ Update_UFW_Rules -> update_server_rule')
         Logger.log_error(str(e))
开发者ID:shanfdo,项目名称:iSensa_v3,代码行数:30,代码来源:ufw_rules_updator.py

示例2: get_existing_rule_id

 def get_existing_rule_id(self, ip_address, port):
     
     try:
         args_list = ['sudo', 'ufw', 'status','numbered']
         ret_val = CF.execute_os_function(args_list)
         
         if not ret_val[0] == -1:
             ret_text = ret_val[1][0]
             
             lines_list = ret_text.split('\n')
             
             records = []
             if len(lines_list) > 0:
                 for line in lines_list:
                     rec = line.split()
                     records.append(rec)
                     
             for rec in records:
                 
                 if len(rec)>3:
                     
                     if rec[2] == port and rec[5] == ip_address:
                         return int(rec[1].replace(']',''))
                         
             return 0
         else:
             return 0
     except Exception as e:
         Logger.log_error(str(e))
         return 0
开发者ID:shanfdo,项目名称:iSensa_v3,代码行数:30,代码来源:ufw_rules_updator.py

示例3: __process_mq_msg

 def __process_mq_msg(self):
     try:
         msg = self.zc.zmq_recv(self.sock, 5000)
         
         if not msg == None:
             #Write to the sender Q
             msg = json.loads(msg)
             
             self.q_i_lock.acquire()
             try:
                 Logger.log_debug_1('Adding a message to MPQ to be sent to cloud')
                 self.q_input.put(msg)
             
             except Exception as ex:
                 Logger.log_debug('ERROR @ Job Scheduler -> __process_mq_msg() -> sending to Q')
                 Logger.log_error(str(ex))
             finally:
                 self.q_i_lock.release()
                 self.sock.send(json.dumps({'error': False}))
                 
     except Exception as e:
         Logger.log_debug('ERROR @ Job Notification_Sender_MQService -> __process_mq_msg()')
         Logger.log_error(str(e))
     finally:
         pass
开发者ID:shanfdo,项目名称:iSensa_v3,代码行数:25,代码来源:NotificationSenderMQService.py

示例4: __handle_RC_msgs

 def __handle_RC_msgs(self, msg_line):
     
     try:
             
             # Load the device attributes file
             device_dict = self.__load_rfd_file(msg_line.split(':')[1])
             
             if not device_dict == None:
                 msg_dict = {'notification_type' : 'SERIAL_EVENT', 'notification_dt': datetime.datetime.now().strftime("%Y%m%d %H%M%S")}
                 msg_dict.update({'devicecode': device_dict['devicecode']})
                 msg_dict.update({'hubcondeviceid': device_dict['hubcondeviceid']})
                 msg_dict.update({'cronjobid' : 0})
                 msg_dict.update({'comcode' : 'AUTO_TRIGGER'})
                 msg_dict.update({'comexecstat' : 'DONE'})
                 msg_dict.update({'comcompstat': 'SUCCESS'})
                 msg_dict.update({'comresults' : ''})
                 
                 if device_dict['devicecode'] == 'SRFDOOR':
                     msg_dict.update({'comresult' : 'OPENED'})
                     
                 CF.send_to_notifiction_queue(msg_dict)
     
     except Exception as e:
         Logger.log_debug('ERROR @ Serial_Interface -> __handle_RC_msgs()')
         Logger.log_error(str(e))
         return None
开发者ID:shanfdo,项目名称:iSensa_v3,代码行数:26,代码来源:SerialInterface.py

示例5: print_jobs

 def print_jobs(self):
     try:
         self.__scheduler.print_jobs()
     
     except Exception as e:
         Logger.log_debug("ERROR @ print_jobs")
         Logger.log_error(str(e))
开发者ID:shanfdo,项目名称:iSensa_v3,代码行数:7,代码来源:JobScheduler.py

示例6: add_remove_ufw_rule

 def add_remove_ufw_rule(self, add_rule = True, port = "0", ip_address = ""):
     
     try:
         if int(port) > 0 and len(ip_address)>0:
             
             if add_rule:
                 if self.get_existing_rule_id(ip_address, port) <= 0:
                     #args_list = ['echo', 'y', '|', 'sudo','ufw','allow', 'from', ip_address, 'to', 'any', 'port', port]
                     #return CF.execute_os_function(args_list)
                     result = os.system('echo y | sudo ufw allow from %s to any port %s' % (ip_address, port))
                     
                     return (0,result)
                 else:
                     return (0, '')
             else:
                
                 id = self.get_existing_rule_id(ip_address, port)
                 print 'id is ' + str(id)
                 if id>0:
                     #args_list = ['echo', 'y','|', 'sudo', 'ufw', 'delete', str(id)]
                     result = os.system('echo y | sudo ufw delete %s' % (id))
                     #return CF.execute_os_function(args_list)
                     return (0, result)
                 else:
                     return(0,'')
         else:
             return (0,'')
         
     except Exception as e:
         Logger.log_debug('ERROR @ add_remove_ufw_rule')
         Logger.log_error(str(e))
         return (0,'')
开发者ID:shanfdo,项目名称:iSensa_v3,代码行数:32,代码来源:ufw_rules_updator.py

示例7: __start_sender_mp

 def __start_sender_mp(self):
     try:
         
         p = NSTC('ntsc', self.q_input, self.q_i_lock, os.getpid())
         p.start()
         
     except Exception as e:
         Logger.log_debug('ERROR @ Notification_Sender_MQService -> __start_sender_mp()')
         Logger.log_error(str(e))
开发者ID:shanfdo,项目名称:iSensa_v3,代码行数:9,代码来源:NotificationSenderMQService.py

示例8: __init_mq_server

 def __init_mq_server(self):
     try:
         context = zmq.Context()
         self.sock = context.socket(zmq.REP)
         self.sock.setsockopt(zmq.LINGER, 15000)
         self.sock.bind('tcp://%s:%s' % (cfg.msg_proc_ip, cfg.msg_proc_port))
     except Exception as e:
         Logger.log_debug('ERROR @ Message_Processor -> __init_mq_server')
         Logger.log_error(str(e))
开发者ID:shanfdo,项目名称:iSensa_v3,代码行数:9,代码来源:MessageProcessor.py

示例9: __start_si_mp

 def __start_si_mp(self):
     try:
         
         p = SI('si', self.q_input, self.q_i_lock, os.getpid())
         p.start()
         
     except Exception as e:
         Logger.log_debug('ERROR @ SI_MQ_Service -> __start_si_mp()')
         Logger.log_error(str(e))
开发者ID:shanfdo,项目名称:iSensa_v3,代码行数:9,代码来源:SIMQService.py

示例10: __save_sent_failed_notification

 def __save_sent_failed_notification(self, msg_dict):
     try:
         
         msg_dict.update({'last_sent_failed_dt': datetime.datetime.now().isoformat()})
         path = cfg.SENT_FAILED_NOTIFICATIONS_FILE_PATH
         file_name = '{}{}.{}'.format(path, datetime.datetime.now().strftime('%Y%m%d%H%M%S%f'), 'sfn')
         CF.save_dictionary_object(file_name, msg_dict)
     except Exception as e:
         Logger.log_debug('ERROR @ Notification_Sender_To_Cloud -> __save_sent_failed_notification()')
         Logger.log_error(str(e))
开发者ID:shanfdo,项目名称:iSensa_v3,代码行数:10,代码来源:NotificationSenderToCloud.py

示例11: run

 def run(self):
     
     try:
         
         while True:
             self.allow_cloud_ip()
             time.sleep(30)
             
     except Exception as e:
         Logger.log_debug('ERRRO @ Update_UFW_Rules -> run()')
         Logger.log_error(str(e))
开发者ID:shanfdo,项目名称:iSensa_v3,代码行数:11,代码来源:ufw_rules_updator.py

示例12: __read_q_msg

 def __read_q_msg(self):
     self.q_i_lock.acquire()
     try:
         if not self.q_input.empty():
             return self.q_input.get() 
     
     except Exception as e:
         Logger.log_debug('ERROR @ Serial_Interface -> __read_q_msg()')
         Logger.log_error(str(e))
         return None
     finally:
         self.q_i_lock.release()
开发者ID:shanfdo,项目名称:iSensa_v3,代码行数:12,代码来源:SerialInterface.py

示例13: __process_mq_msg

 def __process_mq_msg(self):
     try:
         msg = self.zc.zmq_recv(self.sock, 5000)
         if not msg == None:
             payload = json.loads(msg)
             
             #There can be two types of records
             # 1. Schedule a job
             # 2. Remove an already scheduled job
             comtype = payload['comtype']
             
             ret_val = False
             if comtype == 'SAE':
                 #change the comtype to EVE before save
                 payload['comtype'] = 'EVE'
                 cron_job_id = str(payload['cronjobid'])
                 m = payload['cronminute']
                 h = payload['cronhour']
                 dow = payload['crondateofweek']
                 
                 ret_val = self.scheduler.schedule_a_job(cron_job_id, m, h, dow, payload)
                 
                 err_msg = ''
                 if ret_val == False:
                     err_msg = 'scheduling failed'
                     
                 ret_dict  = {'error' : False if ret_val else True, 'error_msg': err_msg}
                 self.sock.send(json.dumps(ret_dict))
                 return 
             
             elif comtype == 'DSR':
                 cron_job_id = str(payload['cronjobid'])
                 ret_val = self.scheduler.remove_a_scheduled_job(cron_job_id)
                     
                 ret_dict  = {'error' : False if ret_val[0] else True, 'error_msg': ret_val[1]}
                 self.sock.send(json.dumps(ret_dict))
                 
             else:
                 ret_dict  = {'error' : True, 'error_msg' : 'unknown command type'}
                 self.sock.send(json.dumps(ret_dict))
                 return 
              
             
         else:
             return None
     except Exception as e:
         Logger.log_debug('ERROR @ Job JS_MQ_Service -> __process_mq_msg')
         Logger.log_error(str(e))
         #ret_dict  = {'error' : True}
         #self.sock.send(json.dumps(ret_dict))
         return None
开发者ID:shanfdo,项目名称:iSensa_v3,代码行数:51,代码来源:JSMQService.py

示例14: __send_invalid_com_ack

 def __send_invalid_com_ack(self, payload):
     
     try:
         Logger.log_debug_1('Invalid command type')
         
         ack = cfg.ack_dict.copy()
         ack.update({'comid': payload['comid'], 'comexecstat': 'DONE', 'comcompstat': 'FAILED', 'comresult':'Invalid com type'})
         ack.update({'ack_dt': datetime.datetime.utcnow().isoformat(), 'error': True})
         jack = json.dumps(ack)
         self.sock.send(jack)
         
     
     except Exception as e:
          Logger.log_error(str(e))
开发者ID:shanfdo,项目名称:iSensa_v3,代码行数:14,代码来源:MessageProcessor.py

示例15: process_msg

def process_msg():
    
    ack = cfg.ack_dict.copy()
    try:
        
        payload = json.loads(request.json)
        
        if not payload == None:
            
            if not __validate_msg_time(payload['rec_dt']):
                # IP address should be black listed
                #----------------------------------
                ack.update({'comid': payload['comid'], 'comexecstat': 'DONE', 'comcompstat': 'FAILED', 'comresult':'Invalid payload'})
                ack.update({'ack_dt': datetime.utcnow().isoformat(), 'error': True})
                return jsonify(ack)
            
            context = zmq.Context()
            sock = context.socket(zmq.REQ)
            sock.setsockopt(zmq.LINGER, 15000)
            sock.connect('tcp://%s:%s' % (cfg.msg_proc_ip, cfg.msg_proc_port))
            time.sleep(0.5)
            sock.send(json.dumps(payload), zmq.NOBLOCK)

            
            #Wait for the ack
            #----------------
            response = __recv(sock, 15000)
            
            if response == None:
                ack.update({'comid': payload['comid'], 'comexecstat': 'DONE', 'comcompstat': 'FAILED', 'comresult':'No response from MP'})
                ack.update({'ack_dt': datetime.utcnow().isoformat(), 'error': True})
            else:
                response = json.loads(response)
                sock.close()
                del sock
                return jsonify(response)
                
        else:
            ack.update({'comid': payload['comid'], 'comexecstat': 'DONE', 'comcompstat': 'FAILED', 'comresult':'Invalid payload'})
            ack.update({'ack_dt': datetime.utcnow().isoformat(), 'error': True})
            
        
        return jsonify(ack)
    
    except Exception as e:
        Logger.log_debug('ERROR @ FlaskApp -> process_msg')
        Logger.log_error(str(e))

        response_payload = {'error' : True, 'error_msg':'failed at hub gateway'}
        return jsonify(response_payload)
开发者ID:shanfdo,项目名称:iSensa_v3,代码行数:50,代码来源:FlaskApp.py


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