本文整理汇总了Python中mpx.lib.msglog.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:triggered_exporter.py
示例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)
开发者ID:mcruse,项目名称:monotone,代码行数:28,代码来源:usap.py
示例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()
开发者ID:mcruse,项目名称:monotone,代码行数:26,代码来源:request_handler.py
示例4: 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
示例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
开发者ID:mcruse,项目名称:monotone,代码行数:27,代码来源:kwh2kw.py
示例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
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:energywise_manager.py
示例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
开发者ID:mcruse,项目名称:monotone,代码行数:35,代码来源:__init__.py
示例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
开发者ID:mcruse,项目名称:monotone,代码行数:29,代码来源:energywise_manager.py
示例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
开发者ID:mcruse,项目名称:monotone,代码行数:30,代码来源:energywise_manager.py
示例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
开发者ID:mcruse,项目名称:monotone,代码行数:31,代码来源:session_data_formatter.py
示例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
开发者ID:mcruse,项目名称:monotone,代码行数:28,代码来源:psp_handler.py
示例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.')
开发者ID:mcruse,项目名称:monotone,代码行数:29,代码来源:host.py
示例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)
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:asynchronous.py
示例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
开发者ID:mcruse,项目名称:monotone,代码行数:31,代码来源:__init__.py
示例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()
开发者ID:mcruse,项目名称:monotone,代码行数:26,代码来源:dallasbus.py
示例16: 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
示例17: updateMeetingSpaceDetail
def updateMeetingSpaceDetail(self, meetingInfoLine):
#Fetch information from meetingInfoLine and store it in child nodes
#updating Dephi Meeting Event Name
self.eventName.event = meetingInfoLine[EVENT_NAME_OFFSET:EVENT_NAME_OFFSET+EVENT_NAME_LEN].strip()
#updating startDateTime and startEpochTime
eventStartTime = meetingInfoLine[START_TIME_OFFSET:START_TIME_OFFSET+START_TIME_LEN]
time_tuple = (date.today().year, date.today().month, date.today().day, int(eventStartTime[0:2]), \
int(eventStartTime[2:4]), 0, 0, 0, -1)
self.startEpochTime.sec = time.mktime( time_tuple )
self.startDateTime.time = time.ctime( self.startEpochTime.sec )
#updating endDateTime and endEpochTime
eventEndTime = meetingInfoLine[END_TIME_OFFSET:END_TIME_OFFSET+END_TIME_LEN]
time_tuple = (date.today().year, date.today().month, date.today().day, int(eventEndTime[0:2]), \
int(eventEndTime[2:4]), 0, 0, 0, -1)
self.endEpochTime.sec = time.mktime( time_tuple )
self.endDateTime.time = time.ctime( self.endEpochTime.sec )
#updating Agreed Attendance
self.agreedAttd.count = int(meetingInfoLine[AGREED_ATTD_OFFSET:AGREED_ATTD_OFFSET+AGREED_ATTD_LEN].strip())
self.updateMeetingStatus('update')
if self.parent.parent.parent.debug:
msglog.log('Delphi', INFO, "%s, EventName - %s, StartTime - %s, StartEpochTime - %f, EndTime - %s, EndEpochTime - %f, AgrAtd - %d" \
%(self.name, self.eventName.event, self.startDateTime.time, self.startEpochTime.sec, self.endDateTime.time, self.endEpochTime.sec, \
self.agreedAttd.count))
开发者ID:mcruse,项目名称:monotone,代码行数:29,代码来源:delphi.py
示例18: 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
示例19: 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
示例20: _stop
def _stop(self):
while self.state is self.PENDING:
pause(.1)
if self.state is not self.STOPPED:
self.state = self.HALTING
msg = 'RNA service stopping on %s.'
msglog.log('broadway', msglog.types.INFO, msg % self.transport)
try:
# Hack to wake up the tread...
t = self.transportClass(**self.configuration())
# TODO: THIS CANNOT WORK. Neither SimpleTcpService nor
# SrnaService has a connect() method:
t.connect()
i = mpx.lib.rna._InvokeCommand("BOGUS")
i.pack(ProtocolCommand('/','no_such_method_i_hope',()))
i.totransport(t.send)
# TODO: THIS CANNOT WORK. Neither SimpleTcpService nor
# SrnaService has a disconnect() method:
t.disconnect()
while self.state is not self.STOPPED:
pause(.1)
return 1
except:
msglog.exception()
return 0
开发者ID:mcruse,项目名称:monotone,代码行数:25,代码来源:rna.py
注:本文中的mpx.lib.msglog.log函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论