本文整理汇总了Python中mpx.lib.msglog.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_trigger
def _setup_trigger(self):
try:
self._sid = SM.create_delivered(self, {1:as_node(self.trigger)})
except ENotStarted, ENoSuchNode:
msg = 'TriggeredExporter trigger: %s does not exist - could be nascent' % self._trigger
msglog.log('broadway',msglog.types.WARN,msg)
scheduler.seconds_from_now_do(60, self._setup_trigger)
示例2: start
def start(self):
if self.parent.room == 1:
msglog.log('USAP', INFO, 'Object:start() - %s --> %s --> %s' % (self.parent.parent.name, self.parent.name, self.name))
self.path = string.join([self.parent.name, self.name], '.')
self.lh = self.parent.parent.lh
self.request_obj = self.parent.parent.request_obj
self.response_obj = self.parent.parent.response_obj
self.unison_v1_9_0_or_prior = self.parent.parent.unison_v1_9_0_or_prior
else:
msglog.log('USAP', INFO, 'Object:start() - %s --> %s --> %s --> %s' % (self.parent.parent.parent.name, self.parent.parent.name, self.parent.name, self.name))
self.path = string.join([self.parent.parent.name, \
self.parent.name, self.name], '.')
self.lh = self.parent.parent.parent.lh
self.request_obj = self.parent.parent.parent.request_obj
self.response_obj = self.parent.parent.parent.response_obj
self.unison_v1_9_0_or_prior = self.parent.parent.parent.unison_v1_9_0_or_prior
# Find the relevant protocol child objects ahead of time to
# be more efficient.
self.req_startCode_obj = self.request_obj.findChildByName("startCode")
self.req_vData_obj = self.request_obj.findChildByName("vData")
self.req_crc_obj = self.request_obj.findChildByName("crc")
#
self.resp_startCode_obj = self.response_obj.findChildByName("startCode")
self.resp_vData_obj = self.response_obj.findChildByName("vData")
self.resp_crc_obj = self.response_obj.findChildByName("crc")
#
CompositeNode.start(self)
示例3: start
def start(self):
filename = '%s (%s)' % (self.name, 'triggers')
self.manager = self.nodespace.as_node(self.manager)
self._pdo_lock.acquire()
try:
if self._triggers is None:
self._triggers = PersistentDictionary(
filename, encode=None, decode=None)
if not self._triggers:
pdodata = PersistentDataObject(self, dmtype=GC_NEVER)
if os.path.exists(pdodata.filename()):
msglog.log('broadway', msglog.types.INFO,
"Migrating previous trigger data.")
pdodata.triggers = {}
pdodata.load()
self._triggers.update(pdodata.triggers)
pdodata.destroy()
del(pdodata)
self._loadtriggers()
if self.secured:
self.security_manager = self.as_node("/services/Security Manager")
else:
self.security_manager = None
finally:
self._pdo_lock.release()
return super(TriggersConfigurator, self).start()
示例4: cancel
def cancel(self):
msglog.log('broadway', WARN, '%r closing channel' % self)
try:
self.channel.close()
except:
msglog.exception(prefix = 'Handled')
return
示例5: 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
示例6: configure
def configure(self,config):
if self.debug:
msglog.log('EnergywiseManager:', msglog.types.INFO,
'Inside configure' )
CompositeNode.configure(self, config)
set_attribute(self, 'debug', 0, config, int)
return
示例7: set_permissions
def set_permissions(self, role, *permissions):
##
# Permissions parameter can be one of three things:
# - A single list or tuple object, whose items will
# replace the permissions tuple.
# - A variable number of permission strings.
# - A single callable object which will be called
# and whose return value will be returned anytime
# the permissions for this role are queried.
if not isinstance(role, str):
role = role.name
if len(permissions) == 1:
if type(permissions[0]) in (list, tuple):
permissions = permissions[0][:]
elif callable(permissions[0]):
permissions = permissions[0]
if not self.parent.parent.role_manager.has_role(role):
raise ValueError('Role "%s" does not exist.' % role)
if isinstance(permissions, (list, tuple)):
defined = self.parent.get_permissions()
for permission in permissions:
if permission not in defined:
raise ValueError('Permission "%s" not defined.' % permission)
self.__lock.acquire()
try:
inherent = self.rolemap.callable_subset()
self.rolemap[role] = permissions
self.rolemap.update(inherent)
finally: self.__lock.release()
if inherent.has_key(role):
message = 'Permissions for role "%s" in policy "%s" '
message += 'cannot be changed. An attempt has been ignored.'
message = message % (role, self.name)
msglog.log('broadway', msglog.types.WARN, message)
return
示例8: start
def start(self):
if self.__running:
return
if self.debug:
msglog.log('EnergywiseManager :', msglog.types.INFO, 'Inside start' )
CompositeNode.start(self)
# start_node = as_node('/services/EnergywiseManager/')
# self.configure_trend_in_switches(start_node, 60)
self.__running = True
self._pdo_lock.acquire()
self._pdo = PersistentDataObject(self, dmtype=GC_NEVER)
self._pdo.trends = {}
self._pdo.load()
self._pdo_lock.release()
if self.has_child('trends'):
self.trends = self.get_child('trends')
else:
self.trends = CompositeNode()
self.trends.configure({'parent':self, 'name':'trends'})
self.trends.start()
# start trending for saved domains
for domain,freq in self._pdo.trends.items():
try:
start_node = as_node(domain)
# self.configure_trend_in_switches( start_node,freq )
start_node.new_trend(freq)
except:
self.delete_trend_configuration(domain)
return
示例9: 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
示例10: output_callback
def output_callback(self, stream):
ws_dicts = stream.get_meta_value('data')
index = stream.get_meta_value('index')
formatter = stream.get_meta_value('formatter')
remaining = stream.get_meta_value('remaining')
if remaining:
remaining = remaining[stream.write(remaining):]
stream.set_meta('remaining',remaining)
if remaining:
return None
for i in range(index, index + 10):
try:
ws_dict = ws_dicts[i]
except IndexError:
formatter.close_tag('workout-sessions')
stream.write(formatter.output())
stream.close()
msglog.log('mpx',msglog.types.INFO,'Sent %u workout sessions to InSite server.' \
% len(ws_dicts))
return None
if not ws_dict.has_key('timestamp'):
raise EIncompatiableFormat()
ws = _xml.WorkoutSession(ws_dict)
ws.get_xml(formatter)
output = formatter.output()
count = stream.write(output)
stream.set_meta('index', i + 1)
if count != len(output):
stream.set_meta('remaining',output[count:])
return None
return None
示例11: 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
示例12: cleanup_modem_configuration
def cleanup_modem_configuration(self):
if not self.modem_map :
cf=properties.MPXINIT_CONF_FILE
if not os.access(cf, os.F_OK):
return
if os.access(cf, os.R_OK|os.W_OK):
f=open(cf, 'r')
cp = ConfigParser.ConfigParser()
cp.readfp(f)
f.close()
else:
if not os.access(cf, os.R_OK):
raise EPermission(reason = 'Cannot read file %s' % cf)
elif not os.access(cf, os.W_OK):
raise EPermission(reason = 'Cannot write file %s' % cf)
write_file = False
if cp.has_section('dialin'):
cp.remove_section('dialin')
write_file = True
if cp.has_section('dialout'):
cp.remove_section('dialout')
write_file = True
if write_file == True:
f=open(properties.MPXINIT_CONF_FILE, 'w')
cp.write(f)
f.close()
msglog.log('broadway', INFO, 'Writting Modem info to mpxinit conf.')
else:
msglog.log('broadway', INFO, 'Not Writting modem info to mpxinit conf.')
示例13: handle_error
def handle_error(self):
warning = msglog.types.WARN
msglog.log('broadway', warning,
'Transaction handling error: %r' % self)
if not self.is_complete() and self.manager:
msglog.log('broadway', warning, 'Incomplete, will notify manager')
self.manager.handle_failed_transaction(self)
示例14: get_context_policies
def get_context_policies(self, context, ascending = True):
if not self.__started:
self.start()
if not isinstance(context, str):
context = ISecurityContext(context).url
active = []
children = self.children_nodes()
ranked = []
for child in children:
try:
ranked.append((child.rank_match(context), child))
except ENotRunning:
# Only log once for consecutive failures.
if (child.__ENotRunning_logged % 1000) == 0:
msglog.log('broadway', msglog.types.WARN,
'Policy "%s" not running.' % child.name)
child.__ENotRunning_logged += 1
else:
child.__ENotRunning_logged = 0
ranked.sort()
ranked.reverse()
for rank, child in ranked:
if rank:
active.insert(0, child)
else:
break
if not child.acquires:
break
if not ascending:
active.reverse()
return active
示例15: start
def start(self):
AVRNode.start(self)
self._start_called = 1
self.devices, self.device_addresses = self.findall()
if self.running:
raise EAlreadyRunning()
# Inform in msglog the number of devices on the dallas bus and their addresses (CSCtl81599)
if(self.devices == None ):
no_of_devices=0
else:
no_of_devices=len(self.device_addresses)
msglog.log('broadway',msglog.types.INFO,'There are %d devices found on "%s" bus' %(no_of_devices, self.name))
if no_of_devices:
addr_str=''
for addr in self.device_addresses:
dallas_bus_addr=address_to_asciihex(addr)
addr_str=addr_str+' '+dallas_bus_addr
msglog.log('broadway',msglog.types.INFO,'The device addresses on "%s" bus : %s\n' %(self.name,addr_str))
# Start the thread to read the dallas bus irrespective for whether the devices are
# present or not (CSCtl81599)
self.running = 1
thread = Thread(name=self.name,target=self._queue_thread,args=())
self.request(self._convert_temperature_sensor_list)
thread.start()