当前位置: 首页>>代码示例>>Python>>正文


Python log.LOG类代码示例

本文整理汇总了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)
开发者ID:bridgeduan,项目名称:openttd-python,代码行数:34,代码来源:playerinfo.py

示例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)
开发者ID:bridgeduan,项目名称:openttd-python,代码行数:7,代码来源:client.py

示例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)
开发者ID:sebrandon1,项目名称:vmtp,代码行数:32,代码来源:network.py

示例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)
开发者ID:sebrandon1,项目名称:vmtp,代码行数:25,代码来源:vmtp.py

示例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!")
开发者ID:bridgeduan,项目名称:openttd-python,代码行数:25,代码来源:ottd-serverstats.py

示例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))
开发者ID:sebrandon1,项目名称:vmtp,代码行数:28,代码来源:vmtp.py

示例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)
开发者ID:bridgeduan,项目名称:openttd-python,代码行数:7,代码来源:webserver.py

示例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]
开发者ID:abranches,项目名称:pythonista-tetris-bot,代码行数:32,代码来源:board.py

示例9: parse_config

def parse_config(filename):
    """
    Fnord
    """
    # {{{
    filename = expanduser(expandvars(filename))
    LOG.debug("Parsing configuration in file '%s'",filename)
    CONFIG.read(filename)
开发者ID:turbofish,项目名称:mcverify,代码行数:8,代码来源:main.py

示例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
开发者ID:sebrandon1,项目名称:vmtp,代码行数:8,代码来源:iperf_tool.py

示例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
开发者ID:bridgeduan,项目名称:openttd-python,代码行数:8,代码来源:webserver.py

示例12: sendToLog

 def sendToLog(self):
     """
     Dispatcher to LOG
     @rtype: boolean
     @returns: True
     """
     LOG.info("EVENT: %s" % (self.msg))
     return True
开发者ID:bridgeduan,项目名称:openttd-python,代码行数:8,代码来源:ottd_client_event.py

示例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})
开发者ID:openstack,项目名称:gluon,代码行数:8,代码来源:odlc.py

示例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)
开发者ID:bridgeduan,项目名称:openttd-python,代码行数:9,代码来源:webserver.py

示例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)
开发者ID:bridgeduan,项目名称:openttd-python,代码行数:9,代码来源:playerinfo.py


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