• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python msglog.exception函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: configure

 def configure(self, config):
     Module.configure(self, config)
     if not self.version:
         self.version = m.ReadModuleName()
     # Import appropriate the ADAM module (or package).
     module = 'mpx.ion.adam.adam' + self.version
     command = compile('import ' + module,
                       'mpx.ion.adam.unknown.configure()', 'exec')
     eval(command)
     # Get the module's factory and instanciate the "real" class.
     command = module + '.factory'
     adam_factory = eval(command, globals(), locals())
     self.instance = adam_factory()
     
     # Scary stuff.  Detach this ion from our parent, configure the real
     # instance (thus attaching it to the parent) and then morph this
     # instance to behave like the real instance (in case anyone has a
     # handle to this instance).
     try:
         self.parent._del_child(self.name)
         self.instance.configure(config)
         attributes = vars(self.instance.__class__)
         attributes.update(vars(self.instance))
         for attrribute in attributes:
             setattr(self, attrribute, getattr(self.instance, attrribute))
     except:
         msglog.exception()
         # The scary stuff failed, reattach to the parent.
         try:
             self.parent._del_child(self.instance.name)
         except:
             pass
         self.parent._add_child(self)
开发者ID:mcruse,项目名称:monotone,代码行数:33,代码来源:unknown.py


示例2: set

    def set(self, newval):
        #
        newval = str(newval).split('.', 1)[0]
        if newval.isdigit():
            newval = int(newval)
        
        if not command.has_key(newval):
            msglog.log('USAP', WARN, "Object:set() with invalid command - %s" % str(newval))
            raise EInvalidValue('Invalid Command', str(newval),
                                'Valid commands are \'0:DACT\' or \'1:ACTI\'.')

        if self.value == command[newval]:
            msglog.log('USAP', INFO, "Object:set() - Current value is same as new value \'%s\', so no action required." % str(command[newval]))
            return;

        vData = string.join(['\x00\x00\x40', self.path, '.', str(command[newval])], '')
        msglog.log('USAP', INFO, "Object:set() - newval = %s, vData(%d) = %s" % (str(command[newval]), len(vData), str(vData)))
        self.req_vData_obj.setValue(vData)
        #
        res = None
	#
        self.lh.connection.drain()
        if self.unison_v1_9_0_or_prior == 1:
            try:
                self.lh.send_request_without_response(self.request_obj, 30)
                time.sleep(1)
            except Exception, e:
                msglog.log('USAP', WARN, "Object:set() - Got exception trying to send request")
                msglog.exception()
                raise ETimeout('Error sending USAP request')
开发者ID:mcruse,项目名称:monotone,代码行数:30,代码来源:usap.py


示例3: create_node

 def create_node(self, factory, nodeurl, **config):
     try:
         as_node(nodeurl)
     except KeyError:
         pass
     else:
         raise TypeError("Node exists: %s" % nodeurl)
     if isinstance(factory, str):
         module,sep,name = factory.rpartition(".")
         if name:
             exec("import %s" % module)
         factory = eval(factory)
     parent,sep,name = nodeurl.rpartition("/")
     configuration = {"name": name, "parent": parent}
     configuration.update(config)
     node = factory()
     try:
         node.configure(configuration)
     except:
         msglog.log("broadway", msglog.types.WARN, 
                    "Error prevented configuration of new node: %s" % node)
         msglog.exception(prefix="handled")
         try:
             node.prune()
         except:
             msglog.exception(prefix="handled")
         else:
             msglog.log("broadway", msglog.types.INFO, 
                        "Node successfully pruned.")
     else:
         msglog.log("broadway", msglog.types.INFO, 
                    "New node created: %s" % node)
         self.updatepdo(nodeurl, node)
         node.start()
     return node.configuration()
开发者ID:mcruse,项目名称:monotone,代码行数:35,代码来源:configurator.py


示例4: _alarm_code

 def _alarm_code(self, alarm_dict):
     result = "N/A"
     try:
         result = alarm_dict['state']
     except:
         msglog.exception()
     return result
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:ewebconnect.py


示例5: _alarm_text

 def _alarm_text(self, alarm_dict):
     result = "N/A"
     try:
         result = alarm_dict['data']
     except:
         msglog.exception()
     return result
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:ewebconnect.py


示例6: get

 def get(self, manager, **keywords):
     if debug: print 'Start of Batch:%s' % (self.properties)
     now = time.time()
     self.last_get_time = now
     callback = None
     if keywords.has_key('callback'):
         keywords['callback'].callback(self.rpm_callback)
     try:
         #print 'Calling read property multiple'   
         rars = rpm(self.device, self.properties, self.timeout, **keywords)
         if isinstance(rars, Callback):
             return rars #if we are in callback mode
         #print 'RPM TIME:%s' % (time.time()-now,)
     except BACnetException, e:
         if len(self.ids) == 1: #single propety rpms throw exceptions at this level
             return {self.ids[0]: e} #simply return exception as the result
         self.total_rpm_error_counter += 1
         if self.total_rpm_error_counter > 0: #catch run away thrashing
             for id in self.ids:
                 nr = self.map[id]
                 nr.set_batch_manager(None) #none of these points can batch
             raise EBadBatch('bacnet', self, 'error threshold exceeded')
         #at this point this is a multiple property read that failed
         msglog.exception()
         if debug: print 'rpm failed, trying rp', str(self.properties)
         answer = {}
         for id in self.ids:
             nr = self.map[id]
             result = nr.get_result()
             answer[id] = result
             if isinstance(result.value.value, BACnetError):
                 nr.set_batch_manager(None) #turn off rpm for the offending property
                 msglog.log('bacnet', nr.as_node_url(), 'cannot get multiple')
                 if debug: msglog.exception()
         raise EBadBatch('bacnet', self, 'rpm failed')
开发者ID:mcruse,项目名称:monotone,代码行数:35,代码来源:batch_manager.py


示例7: scan_nodes_for_changes

 def scan_nodes_for_changes(self):
     sub_dict = SM.poll_all(self.sid)
     self.node_values=sub_dict
     print 'scan_nodes_for_changes sm:', sub_dict
     if sub_dict: #if there have been any changes
         #look at the value in the sheet and send it if there is a difference
         for row_index in sub_dict.keys():
             try:
                 url, mode, value = self.sheet[row_index]
                 new_value = sub_dict[row_index]['value']
                 if mode < 3: #not write only
                     update = 0
                     print "compare: ", str(new_value), value
                     if str(new_value) != value:
                         update = 1
                         try:
                             if new_value == eval(value): #check numeric comparison
                                 update = 0
                         except:
                             pass #text words won't eval
                     if update:
                         print 'scan_nodes_for_changes set_cell:', row_index
                         self.set_cell(row_index, 3, new_value) 
             except:
                 msglog.exception()
开发者ID:mcruse,项目名称:monotone,代码行数:25,代码来源:spreadsheet.py


示例8: save_trends

    def save_trends(self, trend_list):
        # Traverse through _pdo.items and check if new domain is either subset
        # of any configured or superset. 
        # If subset return with msg already covered and dont save this
        # If superset then configure new ones and delete subset from 
        # _pdo.items
        '''Adding and saving trends'''
        for point in reversed(trend_list):
            point_period = point['frequency']
            point_domain = point['domain']
            for  saved_domain,saved_period in tuple(self._pdo.trends.items()):
                if saved_domain == point_domain:
                    if saved_period != point_period:
                        self.delete_trend_configuration(saved_domain)
                        break
            if not self._pdo.trends.has_key(point_domain):
                # add this trend
                try:
                    domain_node = as_node(point_domain)
		    if isinstance(domain_node,EnergywiseSwitch) or isinstance(domain_node,EnergywiseDomain):
                         self.add_trend_configuration(point_period, point_domain)
                         domain_node.new_trend(point_period)
                except Exception:
                    msglog.exception()
                    msglog.log(
                        "Energywise",msglog.types.ERR,
                        "Failed to create trend for %r every %r seconds" 
                        %(point_domain,point_period)
                        )
        return
开发者ID:mcruse,项目名称:monotone,代码行数:30,代码来源:energywise_manager.py


示例9: _inform_garbage_collector

def _inform_garbage_collector(list):
    try:
        gc = as_internal_node('/services/garbage_collector')
        gc.set_faillist(list)
    except:
        msglog.exception(msglog.types.INFO)
    return
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:system.py


示例10: login

 def login(self): #send the initial series of packets to get started
     if self.debug: print 'start login'
     try:
         self.drain_socket()
         if self.debug: print 'write device list request'
         self.write(DeviceListRequest())
         self._device_list = DeviceListResponse(self.read())
         self.device_number = self._device_list.units()[self.device_name]
         if self.debug: print 'write login request'
         self.write(LoginRequest(self.device_number, self.user, self.password))
         self._login_response = LoginResponse(self.read())
         if self.debug: print 'write request 3'
         self.write(Request3(self.device_number))
         self._response3 = Response3(self.read())
         if self.debug: print 'write request 4'
         self.write(Request4(self.device_number))
         self._response4 = Response4(self.read())
         if self.debug: print 'write request 5'
         self.write(Request5(self.device_number))
         self._response5 = self.poll_for_incomming_packets() #Response5(self.read()) #may get first screen update before response
         if self.debug: print 'login successful'
         for i in range(10): #get the first screen complete before moving on to new pages
             self.poll_for_incomming_packets()
         self.send_key('f9')
         for i in range(10): #get the first screen complete before moving on to new pages
             self.poll_for_incomming_packets()
         return 1
     except:
         print 'CPC login failed'
         msglog.exception()
     return 0
开发者ID:mcruse,项目名称:monotone,代码行数:31,代码来源:cpc.py


示例11: logout

 def logout(self):
     try:
         buffer = str(SignOffRequest1(self.device_number)) + str(SignOffRequest2(self.device_number, self.user)) #combine two pkts into one
         self.write(buffer)
         self._device_list = SignOffResponse(self.read())
     except:
         msglog.exception()
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:cpc.py


示例12: start

 def start(self):
     RequestHandler.start(self)
     self.WEB_ROOT = properties.HTTP_ROOT
     if self.parent.server_type == 'HTTPS':
         self.WEB_ROOT = properties.HTTPS_ROOT
     for handler in self.parent.children_nodes():
         if isinstance(handler, FileSpace):
             self.filespace = handler
             break
     err_message = 'PSP handler not running in secured mode because \
                   no %s was found.  Config parameter "secured" \
                   being overriden to False'
     if self.secured and self.filespace:
         try: sm = as_node('/services/Security Manager')
         except KeyError:
             msglog.log('broadway', msglog.types.WARN,
                        err_message % 'Security Manager')
             msglog.exception(prefix = 'Handled')
             self.provides_security = self._secured = False
         else:
             self.security_manager = sm
             self.provides_security = self._secured = True
     else:
         if self.secured:
             # not secured because we could not locate filespace object.
             msglog.log('broadway', msglog.types.WARN,
                        err_message % 'FileSpace manager')
         self.provides_security = self._secured = False
开发者ID:mcruse,项目名称:monotone,代码行数:28,代码来源:psp_handler.py


示例13: handle_request

    def handle_request(self, request):
        print 'handle_request'
        if not self.running:
            return request.error(503) #service unavailable
        try:
            self.data = data = request.get_data().read_all()
            if not data:
                raise EProtocol('could not get DATA parameter from posted data')
            ## process xmlrpc, getting the name of the method
            ## and parameters
            params, method = xmlrpclib.loads(data)
            return

            object_alias = ''
            method_name = ''
            ## get the name of the object
            ## and the name of method
            ## They are delimited by a colon.

        except:
            msglog.exception()
            raise MpxException('Error occurred while processing Brivo XMLRPC command')
        # XML-RPC Call was successful.
        # Send back the XML result to client
        reply = Response(request)
        reply.set_header('Content-Length', len(response))
        reply.set_header('Content-Type', 'text/xml')
        reply.send(response)
        return
开发者ID:mcruse,项目名称:monotone,代码行数:29,代码来源:dispatcher.py


示例14: handle_error

 def handle_error(self):
     try:
         msglog.warn("%s handling error. Please check whether the peer is up and supports the %s protocol" % (self, self.protocol))
         msglog.exception(prefix="handled")
         msglog.inform("%s closing due to error." % self)
     finally:
         self.close()
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:manager.py


示例15: completion_handler

 def completion_handler(self, cb):
     try:
         if self._callback:
             self._callback(self)
     except:
         msglog.exception(prefix = 'Handled')
     return
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:http_client.py


示例16: _configure

def _configure(filename=properties.CONFIGURATION_FILE):
    faillist = []
    try:
        if megatron:
            megatron.setConfiguring()
        
        if os.path.exists('/home/mpxadmin/.db_config'):
            #from mpx.lib.configure import db_config
            _configure_from_db(filename, faillist)
        else:
            _configure_file(filename, faillist)
    except:
        print '***** Exception during  _configure_file', sys.exc_info()
        msglog.exception(msglog.types.ERR)

    # Ensure that the system has the minimum functional requirements.
    print '*** Performing minimal configuration ***'
    ensure_minimal_configuration()

    configuration_file = filename
    root = mpx.lib.node.as_internal_node('/')

    # Start all nodes, top down, breadth first.
    if megatron:
        megatron.setStarting()
    root.start(stage=6)

    # Inform the garbage_collector of any nodes which failed
    _inform_garbage_collector(faillist)
    
    if megatron:
        megatron.setRunning()
    return root
开发者ID:mcruse,项目名称:monotone,代码行数:33,代码来源:system.py


示例17: cancel

 def cancel(self):
     msglog.log('broadway', WARN, '%r closing channel' % self)
     try: 
         self.channel.close()
     except:
         msglog.exception(prefix = 'Handled')
     return
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:http_client.py


示例18: start

    def start(self):
        msglog.log('Delphi', INFO, "Property Start")
        if self.parent.enabled:

            self.local_file_path = '/tmp/'+self.name+'_EVENTS.NSS'
           
            # Lets remove if there is any stale file 
            if exists(self.local_file_path):
                remove(self.local_file_path)
            if exists(self.local_file_path+'_bak'):
                remove(self.local_file_path+'_bak')
            if exists(self.local_file_path+'_prevday'):
                remove(self.local_file_path+'_prevday')

            for child in self.children_nodes():
                if child.identity == 'status':
                    self.downloadStatus = child
                    break 

            if self.interface_pc_addr == None or self.event_file_location == None:
                msglog.log('Delphi', WARN, "Check interface pc address and event file location configurations")
            else:
                protocol=self.communication_interface+'://'
                if self.interface_pc_addr[:len(protocol)] == protocol:
                    self.interface_pc_addr = self.interface_pc_addr[len(protocol):]

                if not self.scheduler.is_started():
                    try:
                        self.scheduler.start()
                        self.schedulePollAfterInterval( 5 )#start scheduler in 5 second
                    except:
                      msglog.exception()

            super(Property, self).start()
开发者ID:mcruse,项目名称:monotone,代码行数:34,代码来源:delphi.py


示例19: update

 def update(self):
     try:
         value = ts = None
         result = SM.poll_all(self._sid)
         if result is not None:
             value = result[self._nid]['value']
             ts = result[self._nid]['timestamp']
         self._history_lock.acquire()
         try:
             if value is None or isinstance(value, MpxException):
                 # there were problems collecting during this period, 
                 # our calculation should not proceed
                 self._history.clear()
                 if not self._poll_failure:
                     # log the failure, but don't spam the msglog
                     self._poll_failure = True
                     msglog.log('Kwh2Kw', msglog.types.WARN, 
                                'Failed to retrieve data from %s' % self.link)
             else:
                 self._poll_failure = False
                 self._history.add(value, ts)
         finally:
             self._history_lock.release()
     except:
         msglog.exception()
     self._scheduled = scheduler.seconds_from_now_do(self.sample_period, self.run_update)
     return
开发者ID:mcruse,项目名称:monotone,代码行数:27,代码来源:kwh2kw.py


示例20: handle_update_password

 def handle_update_password(self, request):
     parameters = request.get_query_dictionary()
     parameters.update(request.get_post_data())
     
     # POST value for destination overrides query-string if both provided.
     username = parameters.get("username", "")
     password = parameters.get("password", "")
     newpwd = parameters.get("newpwd", "")
     confirm_newpwd = parameters.get("confirm_newpwd", "")
     
     try:
         if Properties.get_boolean('PAM_ENABLE'):
             user = self.manager.user_from_pam(username, password)
         else:
             user = self.manager.user_from_cleartext(username, password)
     except (PAMError, EAuthenticationFailed):
         msglog.exception(prefix="Handled")
         msg = "Invalid old password. Enter correct old password for authentication."
         self.handle_form(request, "update_password", "Authentication Failed", msg)
     else:
         if newpwd == confirm_newpwd:
             try:
                 user.set_password(newpwd)
             except EInvalidValue, e:
                 msglog.exception(prefix="Handled")
                 msg = "".join(e[1].splitlines())
                 self.handle_form(request, "update_password", 
                                  "Invalid new password. Please try again", msg)
             else:
                 msg = "Password updated successfully for %s." % (username)
                 msglog.log("broadway", msglog.types.INFO, msg)
                 self.handle_form(request, "information", msg)
         else:
开发者ID:mcruse,项目名称:monotone,代码行数:33,代码来源:authentication.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python msglog.log函数代码示例发布时间:2022-05-27
下一篇:
Python configure.set_attribute函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap