本文整理汇总了Python中mpx.lib.msglog.exception函数的典型用法代码示例。如果您正苦于以下问题:Python exception函数的具体用法?Python exception怎么用?Python exception使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exception函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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')
示例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()
示例4: _alarm_code
def _alarm_code(self, alarm_dict):
result = "N/A"
try:
result = alarm_dict['state']
except:
msglog.exception()
return result
示例5: _alarm_text
def _alarm_text(self, alarm_dict):
result = "N/A"
try:
result = alarm_dict['data']
except:
msglog.exception()
return result
示例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')
示例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()
示例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
示例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
示例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
示例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()
示例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
示例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
示例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()
示例15: completion_handler
def completion_handler(self, cb):
try:
if self._callback:
self._callback(self)
except:
msglog.exception(prefix = 'Handled')
return