本文整理汇总了Python中log.LOG类的典型用法代码示例。如果您正苦于以下问题:Python LOG类的具体用法?Python LOG怎么用?Python LOG使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LOG类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: commandReceived
def commandReceived(self, cmd):
if cmd.commandid in const.command_names.keys():
LOG.debug("got command: %d(%s) from company %d: '%s'" % (cmd.cmd, const.command_names[cmd.commandid].__str__(), cmd.company + 1, cmd.text))
ctime = time.time()
companystr = self.client.getCompanyString(cmd.company)
if cmd.company in self.companyIdling and cmd.company != const.PLAYER_SPECTATOR:
# remove from that list
idx = self.companyIdling.index(cmd.company)
del self.companyIdling[idx]
timediff = ctime - self.companyLastAction[cmd.company]
if timediff > self.idletime:
# we were here already, check if we got back from idling
Broadcast("%s is back from idling after %s" % (companystr, self.timeFormat(timediff)), parentclient=self.client)
self.companyLastAction[cmd.company] = ctime
if cmd.commandid == const.commands['CMD_PLACE_SIGN'] and cmd.text != '':
Broadcast("%s placed a sign: '%s'" % (companystr, cmd.text), parentclient=self.client)
elif cmd.commandid == const.commands['CMD_RENAME_SIGN'] and cmd.text != '':
Broadcast("%s renames a sign: '%s'" % (companystr, cmd.text), parentclient=self.client)
elif cmd.commandid == const.commands['CMD_SET_COMPANY_COLOUR']:
Broadcast("%s changed their color" % companystr, parentclient=self.client)
elif cmd.commandid == const.commands['CMD_RENAME_COMPANY']:
Broadcast("%s changed their company name to '%s'"%(companystr, cmd.text), parentclient=self.client)
elif cmd.commandid == const.commands['CMD_SET_COMPANY_MANAGER_FACE']:
Broadcast("%s changed their company face"%(companystr), parentclient=self.client)
elif cmd.commandid == const.commands['CMD_RENAME_PRESIDENT']:
Broadcast("%s changed their presidents name to '%s'"%(companystr, cmd.text), parentclient=self.client)
elif cmd.commandid == const.commands['CMD_BUILD_INDUSTRY']:
Broadcast("%s built a new industry"%(companystr), parentclient=self.client)
elif cmd.commandid == const.commands['CMD_BUILD_COMPANY_HQ']:
Broadcast("%s built or relocated their HQ"%(companystr), parentclient=self.client)
示例2: throwRandomData
def throwRandomData(self):
rsize = 128
rand = str(random.getrandbits(rsize))
res = struct.pack("%ds"%rsize, rand)
LOG.debug(" fuzzing with %d bytes: '%s'" % (rsize, rand))
for i in range(0,127):
self.sendMsg_UDP(i, res)
示例3: __add_router_interface
def __add_router_interface(self):
# and pick the first in the list - the list should be non empty and
# contain only 1 subnet since it is supposed to be a private network
# But first check that the router does not already have this subnet
# so retrieve the list of all ports, then check if there is one port
# - matches the subnet
# - and is attached to the router
# Assumed that both management networks are created together so checking for one of them
ports = self.neutron_client.list_ports()['ports']
for port in ports:
# Skip the check on stale ports
if port['fixed_ips']:
port_ip = port['fixed_ips'][0]
if (port['device_id'] == self.ext_router['id']) and \
(port_ip['subnet_id'] == self.vm_int_net[0]['subnets'][0]):
LOG.info('Ext router already associated to the internal network.')
return
for int_net in self.vm_int_net:
body = {
'subnet_id': int_net['subnets'][0]
}
self.neutron_client.add_interface_router(self.ext_router['id'], body)
LOG.debug('Ext router associated to ' + int_net['name'])
# If ipv6 is enabled than add second subnet
if self.ipv6_enabled:
body = {
'subnet_id': int_net['subnets'][1]
}
self.neutron_client.add_interface_router(self.ext_router['id'], body)
示例4: get_controller_info
def get_controller_info(ssh_access, net, res_col, retry_count):
if not ssh_access:
return
LOG.info('Fetching OpenStack deployment details...')
sshcon = sshutils.SSH(ssh_access, connect_retry_count=retry_count)
if sshcon is None:
LOG.error('Cannot connect to the controller node')
return
res = {}
res['distro'] = sshcon.get_host_os_version()
res['openstack_version'] = sshcon.check_openstack_version()
res['cpu_info'] = sshcon.get_cpu_info()
if net:
l2type = res_col.get_result('l2agent_type')
encap = res_col.get_result('encapsulation')
if l2type:
if encap:
res['nic_name'] = sshcon.get_nic_name(l2type, encap,
net.internal_iface_dict)
res['l2agent_version'] = sshcon.get_l2agent_version(l2type)
# print results
CONLOG.info(res_col.ppr.pformat(res))
FILELOG.info(json.dumps(res, sort_keys=True))
res_col.add_properties(res)
示例5: savestatstofile
def savestatstofile(filename="serverstats.bin", servers=[]):
if not config.getboolean("serverstats", "savehistory"):
return
t = time.time()
try:
try:
import cPickle as pickle
except:
import pickle
except ImportError:
LOG.error("error while loading the pickle module...")
return
try:
f = open(filename, 'rb')
oldstats = pickle.load(f)
f.close()
except IOError:
oldstats = {}
oldstats[t] = servers
try:
f = open(filename, 'wb')
pickle.dump(oldstats, f)
f.close()
except IoError:
LOG.error("error while saving history file!")
示例6: measure_flow
def measure_flow(self, label, target_ip):
label = self.add_location(label)
FlowPrinter.print_desc(label)
# results for this flow as a dict
perf_output = self.client.run_client(label, target_ip,
self.server,
bandwidth=self.config.vm_bandwidth,
az_to=self.server.az)
if self.config.keep_first_flow_and_exit:
CONLOG.info(self.rescol.ppr.pformat(perf_output))
FILELOG.info(json.dumps(perf_output, sort_keys=True))
LOG.info('Stopping execution after first flow, cleanup all VMs/networks manually')
sys.exit(0)
if self.config.stop_on_error:
# check if there is any error in the results
results_list = perf_output['results']
for res_dict in results_list:
if 'error' in res_dict:
LOG.error('Stopping execution on error, cleanup all VMs/networks manually')
CONLOG.info(self.rescol.ppr.pformat(perf_output))
FILELOG.info(json.dumps(perf_output, sort_keys=True))
sys.exit(2)
self.rescol.add_flow_result(perf_output)
CONLOG.info(self.rescol.ppr.pformat(perf_output))
FILELOG.info(json.dumps(perf_output, sort_keys=True))
示例7: stopWebserver
def stopWebserver(self, event, command):
if self.webserverthread is None or (config.getboolean("main", "productive") and not event.isByOp()):
return
LOG.debug("stopping webserver ...")
self.webserverthread.stop()
self.webserverthread = None
Broadcast("webserver stopped", parentclient=self.client, parent=event)
示例8: place_block
def place_block(self, block, pos, ignore_top=True):
"""
Updates the board by placing `block` at the position `pos`.
"""
LOG.debug("Placing %s at %s" % (block, pos))
solid_squares = block.get_solid_squares()
heighest_columns = [0] * self.width
for (x,y) in solid_squares:
final_x, final_y = pos[0]+x, pos[1]+y
if ignore_top and final_y >= self.height:
continue
assert self.valid_position(final_x, final_y, ignore_top), \
"Trying to place %s outside the board limits! (%s)" % (block, pos)
if self.board[final_y][final_x] != None:
LOG.critical("Writing on (%d,%d), a position of the" % (final_x, final_y) + \
"board already filled, something wrong happend!")
self.board[final_y][final_x] = block
if final_y >= heighest_columns[final_x]:
heighest_columns[final_x] = final_y + 1
for (x, _) in solid_squares:
final_x = pos[0]+x
if heighest_columns[final_x] > self._column_heights[final_x]:
self._column_heights[final_x] = heighest_columns[final_x]
示例9: parse_config
def parse_config(filename):
"""
Fnord
"""
# {{{
filename = expanduser(expandvars(filename))
LOG.debug("Parsing configuration in file '%s'",filename)
CONFIG.read(filename)
示例10: get_bdw_kbps
def get_bdw_kbps(bdw, bdw_unit):
if not bdw_unit:
# bits/sec
return bdw / 1000
if bdw_unit in MULTIPLIERS:
return int(bdw * MULTIPLIERS[bdw_unit])
LOG.error('Error: unknown multiplier: ' + bdw_unit)
return bdw
示例11: clearStats
def clearStats(self):
if not config.getboolean('stats', 'enable'): return
fn = config.get("stats", "cachefilename")
try:
os.remove(fn)
LOG.debug("stats cleared")
except:
pass
示例12: sendToLog
def sendToLog(self):
"""
Dispatcher to LOG
@rtype: boolean
@returns: True
"""
LOG.info("EVENT: %s" % (self.msg))
return True
示例13: delete
def delete(self, obj_typ, id=None, obj=None):
if not (id or obj):
LOG.error('Give either net_id or net_obj')
if obj:
id = obj.get('id')
return self.sendjson('delete', '%(obj_typ)s/%(id)s' %
{'obj_typ': obj_typ,
'id': id})
示例14: startWebserver
def startWebserver(self, event, command):
if config.getboolean("main", "productive") and not event.isByOp():
return
if not config.getboolean("webserver", "enable") or not self.webserverthread is None:
return
LOG.debug("starting webserver ...")
self.webserverthread = WebserverThread(self.client)
self.webserverthread.start()
Broadcast("webserver started on port %d"% self.webserverthread.port, parentclient=self.client, parent=event)
示例15: init
def init(self):
LOG.debug("PlayerInfoPlugin started")
self.updateConfig()
self.enabled = config.getboolean('playerinfos', 'enable')
self.idletime = config.getint ('playerinfos', 'idletime')
self.registerCallback("on_receive_command", self.commandReceived)
self.registerCallback("on_mainloop", self.onMainLoop)
self.registerChatCommand("stopinfo", self.stopInfo)
self.registerChatCommand("idleinfo", self.idleInfo)