• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python log.info函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中supybot.log.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: flevel

    def flevel(self, irc, msg, args, level):
        """
        Change your level
        """
        dungeon = self.SpiffyWorld.get_dungeon_by_channel(GAME_CHANNEL)

        if dungeon is not None:
            user_id = self._get_user_id(irc, msg.prefix)
            unit = dungeon.get_unit_by_user_id(user_id)

            if unit is not None:
                int_level = int(level)
                xp_for_level = self.unit_level.get_xp_for_level(int_level) + 1

                log.info("SpiffyRPG: setting xp for %s to %s (level %s)" %
                         (unit.get_name(), xp_for_level, int_level))

                unit.experience = xp_for_level
                unit.level = self.unit_level.get_level_by_xp(unit.experience)
                unit.on_unit_level()

                dungeon.announcer.unit_info(unit=unit,
                                            dungeon=dungeon,
                                            irc=irc)
        else:
            log.error("SpiffyRPG: could not find dungeon %s" % msg.args[0])
开发者ID:butterscotchstallion,项目名称:SpiffyRPG,代码行数:26,代码来源:plugin.py


示例2: _init_world

    def _init_world(self):
        """
        We need the nicks in the channel in order to initialize
        the world.
        """
        db_path = conf.supybot.directories.data.dirize(SQLITE_DB_FILENAME)

        if self.db is None:
            database = Database(path=db_path, log=log)
            self.db = database.get_connection()

        assert self.db is not None

        if self.SpiffyWorld is None:
            log.info("Initializing world.")

            worldbuilder = Worldbuilder(db=self.db,
                                        irc=self.irc,
                                        ircmsgs=ircmsgs,
                                        ircutils=ircutils,
                                        log=log)
            spiffy_world = worldbuilder.build_world()

            self.SpiffyWorld = spiffy_world

            self._add_players_from_channel(new_player_nick=None)

        assert self.SpiffyWorld is not None
开发者ID:butterscotchstallion,项目名称:SpiffyRPG,代码行数:28,代码来源:plugin.py


示例3: _topic_callback

    def _topic_callback(self):
        self.topic_lock.acquire()

        sections = {
            lambda: len(TestingRCBugs().get_bugs()): 'RC bug count:',
            NewQueue().get_size: 'NEW queue:',
            RmQueue().get_size: 'RM queue:',
        }

        try:
            values = {}
            for callback, prefix in sections.iteritems():
                values[callback] = callback()

            for channel in self.irc.state.channels:
                new_topic = topic = self.irc.state.getTopic(channel)

                for callback, prefix in sections.iteritems():
                    if values[callback]:
                        new_topic = rewrite_topic(new_topic, prefix, values[callback])

                if topic != new_topic:
                    log.info("Queueing change of topic in #%s to '%s'" % (channel, new_topic))
                    self.queued_topics[channel] = new_topic

                    event_name = '%s_topic' % channel
                    try:
                        schedule.removeEvent(event_name)
                    except KeyError:
                        pass
                    schedule.addEvent(lambda channel=channel: self._update_topic(channel),
                        time.time() + 60, event_name)
        finally:
            self.topic_lock.release()
开发者ID:rhonda,项目名称:debian-devel-changes-bot,代码行数:34,代码来源:plugin.py


示例4: addAlias

 def addAlias(self, irc, msg, origuser, user, alias, config):
     if not config.has_section('Users'):
         config.add_section('Users')
     atest = self.aliasExists(alias, config)
     if atest and atest != user.name.lower():
         if atest == alias:
             irc.reply("You can not have an alias that is the name of a user.")
             return False
         irc.reply("%s already owns %s" % (atest,alias))
         return False
     elif atest:
         if atest == alias:
             irc.reply("Why are you trying to have an alias that is your name?")
             return False
         # irc.reply("Error: You already own that alias")
         irc.reply("Your aliases: %s" % ", ".join(aliases))
         return False
     aliases = config.get('Users', user.name).split(" ")
     if alias in aliases:
          # We should never reach here
         return False
     config.set('Users', user.name, " ".join(aliases) + " " + alias)
     aliases = aliases[1:]
     aliases.append(alias)
     log.info(str(aliases))
     if origuser.name == user.name:
         irc.reply("Your aliases: %s" % ", ".join(aliases))
     else:
         irc.reply("%s's aliases: %s" % (user.name, ", ".join(aliases)))
     return config
开发者ID:perfectsearch,项目名称:supybot-plugins,代码行数:30,代码来源:plugin.py


示例5: racers

    def racers(self, irc, msg, args):
        """takes no arguments

        Lists all users currently in sessions (not just races)
        """

        logger.info("Command sent by " + str(msg.nick))

        self.iRacingData.grabData()
        onlineDrivers = self.iRacingData.onlineDrivers()
        onlineDriverNames = []

        for driver in onlineDrivers:
            name = driver.nameForPrinting()

            if driver.currentSession is not None:
                name += ' (%s)' % (driver.currentSession.sessionDescription)

            onlineDriverNames.append(name)

        if len(onlineDriverNames) == 0:
            response = self.NO_ONE_ONLINE_RESPONSE
        else:
            response = 'Online racers: %s' % utils.str.commaAndify(onlineDriverNames)

        irc.reply(response)
开发者ID:jasonn85,项目名称:Racebot,代码行数:26,代码来源:plugin.py


示例6: grabData

    def grabData(self, onlineOnly=True):
        """Refreshes data from iRacing JSON API."""

        # Have we loaded the car/track/season data recently?
        timeSinceSeasonDataFetch = sys.maxint if self.lastSeasonDataFetchTime is None else time.time() - self.lastSeasonDataFetchTime
        shouldFetchSeasonData = timeSinceSeasonDataFetch >= self.SECONDS_BETWEEN_CACHING_SEASON_DATA

        # TODO: Check if a new season has started more recently than the past 12 hours.

        if shouldFetchSeasonData:
            logTime = 'forever' if self.lastSeasonDataFetchTime is None else '%s seconds' % timeSinceSeasonDataFetch
            logger.info('Fetching iRacing main page season data since it has been %s since we\'ve done so.', logTime)
            self.grabSeasonData()

        json = self.iRacingConnection.fetchDriverStatusJSON(onlineOnly=onlineOnly)

        if json is None:
            # This is already logged in fetchDriverStatusJSON
            return

        # Populate drivers and sessions dictionaries
        for racerJSON in json['fsRacers']:
            driverID = Driver.driverIDWithJson(racerJSON)

            # Check if we already have data for this driver to update
            if driverID in self.driversByID:
                driver = self.driversByID[driverID]
                """@type driver: Driver"""
                driver.updateWithJSON(racerJSON)
            else:
                # This is the first time we've seen this driver
                driver = Driver(racerJSON, self.db, self)
                self.driversByID[driver.id] = driver
开发者ID:jasonn85,项目名称:Racebot,代码行数:33,代码来源:plugin.py


示例7: grabSeasonData

    def grabSeasonData(self):
        """Refreshes season/car/track data from the iRacing main page Javascript"""
        rawMainPageHTML = self.iRacingConnection.fetchMainPageRawHTML()

        if rawMainPageHTML is None:
            logger.warning('Unable to fetch iRacing homepage data.')
            return

        self.lastSeasonDataFetchTime = time.time()

        try:
            trackJSON = re.search("var TrackListing\\s*=\\s*extractJSON\\('(.*)'\\);", rawMainPageHTML).group(1)
            carJSON = re.search("var CarListing\\s*=\\s*extractJSON\\('(.*)'\\);", rawMainPageHTML).group(1)
            carClassJSON = re.search("var CarClassListing\\s*=\\s*extractJSON\\('(.*)'\\);", rawMainPageHTML).group(1)
            seasonJSON = re.search("var SeasonListing\\s*=\\s*extractJSON\\('(.*)'\\);", rawMainPageHTML).group(1)

            tracks = json.loads(trackJSON)
            cars = json.loads(carJSON)
            carClasses = json.loads(carClassJSON)
            seasons = json.loads(seasonJSON)

            for track in tracks:
                self.tracksByID[track['id']] = track
            for car in cars:
                self.carsByID[car['id']] = car
            for carClass in carClasses:
                self.carClassesByID[carClass['id']] = carClass
            for season in seasons:
                self.seasonsByID[season['seriesid']] = season

            logger.info('Loaded data for %i tracks, %i cars, %i car classes, and %i seasons.', len(self.tracksByID), len(self.carsByID), len(self.carClassesByID), len(self.seasonsByID))

        except AttributeError:
            logger.info('Unable to match track/car/season (one or more) listing regex in iRacing main page data.  It is possible that iRacing changed the JavaScript structure of their main page!  Oh no!')
开发者ID:jasonn85,项目名称:Racebot,代码行数:34,代码来源:plugin.py


示例8: clone

    def clone(self, irc, msg, args, optlist, vmname):
        """<vm> [--{mem, cpu, tmpl, pool, dnsdomain, vcenter}]
        option details:
            mem = 1024 (MB) - RAM
            cpu = 1 (int) - CPUs
            tmpl = centos6 (str) - template to use
            pool = DEV (str) - resource pool
            dnsdomain = domain.local (str) - dns domain search
            vcenter = vcenter1.domain.local - vcenter server

        Creates a vm from a template
        Returns the status of clone
        """

        opts = dict(optlist)

        conf = {}
        conf['mem'] = opts.get('mem', 1024)
        conf['cpu'] = opts.get('cpu', 1)
        conf['tmpl'] = opts.get('tmpl', self.template)
        conf['pool'] = opts.get('pool', self.pool)
        conf['dnsdomain'] = opts.get('dnsdomain', self.vm_dnsdomain)
        conf['vcenter'] = opts.get('vcenter', self.vcenter)
        conf['name'] = vmname.lower()

        username = self.user
        password = self.password
        vm_username = self.vm_username
        vm_password = self.vm_password

        try:
            si = SmartConnect(host=conf['vcenter'], user=username, pwd=password, port=443)
        except IOError, e:
            log.info('Error connecting to {0}'.format(conf['vcenter']))
            return
开发者ID:sijis,项目名称:supybot-plugins,代码行数:35,代码来源:plugin.py


示例9: _topic_callback

    def _topic_callback(self):
        sections = {
            self.testing_rc_bugs.get_number_bugs: 'RC bug count',
            self.stable_rc_bugs.get_number_bugs: 'Stable RC bug count',
            self.new_queue.get_size: 'NEW queue',
            RmQueue().get_size: 'RM queue',
        }

        with self.topic_lock:
            values = {}
            for callback, prefix in sections.iteritems():
                values[callback] = callback()

            for channel in self.irc.state.channels:
                new_topic = topic = self.irc.state.getTopic(channel)

                for callback, prefix in sections.iteritems():
                    if values[callback]:
                        new_topic = rewrite_topic(new_topic, prefix, values[callback])

                if topic != new_topic:
                    log.info("Queueing change of topic in #%s to '%s'" % (channel, new_topic))
                    self.queued_topics[channel] = new_topic

                    event_name = '%s_topic' % channel
                    try:
                        schedule.removeEvent(event_name)
                    except KeyError:
                        pass
                    schedule.addEvent(lambda channel=channel: self._update_topic(channel),
                        time.time() + 60, event_name)
开发者ID:xtaran,项目名称:debian-devel-changes-bot,代码行数:31,代码来源:plugin.py


示例10: toGBP

def toGBP(raw):
    urlPattern = 'http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=%sGBP=X'
    currency, value = raw.split(' ')
    log.info("Getting currency for %s" % currency)
    if not exchangeRateCache.has_key(currency):
        exchangeRateCache[currency] = float(urllib2.urlopen(urlPattern % currency).read().split(',')[1].replace(',', ''))
    return float(value.replace(',', '')) * exchangeRateCache[currency]
开发者ID:Gnonthgol,项目名称:supybot-plugin-osm,代码行数:7,代码来源:plugin.py


示例11: doNick

    def doNick(self, irc, msg):
        """
        Update player's nick if they change it
        """
        old_nick = msg.prefix.split('!')[0]
        new_nick = msg.args[0]

        user_id = None

        try:
            hostmask = irc.state.nickToHostmask(new_nick)
            user_id = ircdb.users.getUserId(hostmask)
        except KeyError:
            log.info("SpiffyRPG: error getting hostmask for %s" % new_nick)

        if user_id is not None:
            dungeon = self.SpiffyWorld.get_dungeon_by_channel(GAME_CHANNEL)

            if dungeon is not None:
                unit = dungeon.get_player_by_user_id(user_id)

                if unit is not None:
                    unit.nick = new_nick

                    log.info("SpiffyRPG: nick change: %s is now known as %s, updating unit %s" %
                             (old_nick, new_nick, unit.get_name()))
开发者ID:butterscotchstallion,项目名称:SpiffyRPG,代码行数:26,代码来源:plugin.py


示例12: onPayload

 def onPayload(self, payload):
     repo = '%s/%s' % (payload['repository']['owner']['name'],
                       payload['repository']['name'])
     announces = self._load()
     if repo not in announces:
         log.info('Commit for repo %s not announced anywhere' % repo)
         return
     for channel in announces[repo]:
         for irc in world.ircs:
             if channel in irc.state.channels:
                 break
         commits = payload['commits']
         if channel not in irc.state.channels:
             log.info('Cannot announce commit for repo %s on %s' %
                      (repo, channel))
         elif len(commits) == 0:
             log.warning('GitHub callback called without any commit.')
         else:
             hidden = None
             last_commit = commits[-1]
             if last_commit['message'].startswith('Merge ') and \
                     len(commits) > 5:
                 hidden = len(commits) + 1
                 payload['commits'] = [last_commit]
             for commit in payload['commits']:
                 msg = self._createPrivmsg(channel, payload, commit,
                         hidden)
                 irc.queueMsg(msg)
开发者ID:Albnetwork,项目名称:Supybot-plugins,代码行数:28,代码来源:plugin.py


示例13: _poll

 def _poll(self):
     try:
         tochannel = self.registryValue('postChannel')
         if tochannel:
             irc = self.irc
             server = self.xmlrpc
             lastseen = self.lastseen
             if tochannel in irc.state.channels:
                 for rcgthread in self.registryValue('watchedThreads').split():
                     response = server.get_thread(rcgthread, 0, 0)
                     lastpost = response.get('total_post_num')
                     if rcgthread in lastseen:
                         if lastpost > lastseen[rcgthread]:
                             log.info("New posts in %s" % (rcgthread))
                             response = server.get_thread(rcgthread, lastseen[rcgthread], lastpost)
                             for post in response.get('posts'):
                                 log.info("Posting about %s:%s on %s" % (rcgthread, post.get('post_id'), tochannel))
                                 message = "New post in '%s' by %s: %sp=%s" % (response.get('topic_title').data, post.get('post_author_name').data, POSTURL, post.get('post_id'))
                                 irc.queueMsg(ircmsgs.privmsg(tochannel, message))
                             lastseen[rcgthread] = lastpost
                     else:
                         lastseen[rcgthread] = lastpost
     except:
         pass
     self._schedule_next_event()
开发者ID:kh4,项目名称:RCGroups,代码行数:25,代码来源:plugin.py


示例14: onPayload

 def onPayload(self, headers, payload):
     if "full_name" in payload["repository"]:
         repo = payload["repository"]["full_name"]
     elif "name" in payload["repository"]["owner"]:
         repo = "%s/%s" % (payload["repository"]["owner"]["name"], payload["repository"]["name"])
     else:
         repo = "%s/%s" % (payload["repository"]["owner"]["login"], payload["repository"]["name"])
     event = headers["X-GitHub-Event"]
     announces = self._load()
     if repo not in announces:
         log.info("Commit for repo %s not announced anywhere" % repo)
         return
     for channel in announces[repo]:
         for irc in world.ircs:
             if channel in irc.state.channels:
                 break
         if event == "push":
             commits = payload["commits"]
             if channel not in irc.state.channels:
                 log.info("Cannot announce commit for repo %s on %s" % (repo, channel))
             elif len(commits) == 0:
                 log.warning("GitHub push hook called without any commit.")
             else:
                 hidden = None
                 last_commit = commits[-1]
                 if last_commit["message"].startswith("Merge ") and len(commits) > 5:
                     hidden = len(commits) + 1
                     commits = [last_commit]
                 payload2 = dict(payload)
                 for commit in commits:
                     payload2["__commit"] = commit
                     self._createPrivmsg(irc, channel, payload2, "push", hidden)
         else:
             self._createPrivmsg(irc, channel, payload, event)
开发者ID:CiaranG,项目名称:Supybot-plugins,代码行数:34,代码来源:plugin.py


示例15: reboot

    def reboot(self, irc, msg, args, vmname):
        """<vm>
        Reboots the vm
        Returns the status of migration
        """
        username = self.user
        password = self.password
        vcenter = self.vcenter

        try:
            si = SmartConnect(host=vcenter, user=username, pwd=password, port=443)
        except:
            err_text = 'Error connecting to {0}'.format(vcenter)
            log.info(err_text)
            irc.reply(err_text)
            return

        # Finding source VM
        try:
            vm = vmutils.get_vm_by_name(si, vmname)
        except:
            irc.reply('{0} not found.'.format(vmname))
            return

        try:
            vm.RebootGuest()
        except:
            vm.ResetVM_Task()

        irc.reply('Rebooting {0}'.format(vmname))
        Disconnect(si)
开发者ID:sijis,项目名称:supybot-plugins,代码行数:31,代码来源:plugin.py


示例16: sendEmail

 def sendEmail(self, irc, suser, duser, message):
     config = ConfigParser.ConfigParser()
     config.read(os.path.join(conf.supybot.directories.conf(), 'xmpp.conf'))
     # log.info(str(user))
     if not config.has_section('Users'):
         config.add_section('Users')
     alias = self.aliasExists(duser, config)
     # log.info('Alias %s exists. Owner: %s' % (duser,alias))
     if alias:
         email = config.get('Users', alias)
     else:
         email = None
     if email is not None:
         email = email.split(' ')[0]
         #subprocess.Popen(['python', '/.private/xmppScript/xmpp.py', '-t', email, '-m', message])
         # REPLACE - xmpp email id
         jid = xmpp.protocol.JID(self.registryValue('auth.username'))
         cl = xmpp.Client(jid.getDomain(), debug=[])
         connection = cl.connect(("talk.google.com", 5222))
         if connection:
             # REPLACE - xmpp password
             auth = cl.auth(jid.getNode(), self.registryValue('auth.password'), resource=jid.getResource())
             if auth:
                 id = cl.send(xmpp.protocol.Message(email, message))
                 cl.disconnect()
                 log.info('%s successfully sent a message to %s: %s' % (suser, duser, message))
                 return 0
             else:
                 log.error('XMPP: failed auth')
                 return 3
         else:
             log.error('XMPP: could not connect')
             return 2
     else:
         return 1
开发者ID:perfectsearch,项目名称:supybot-plugins,代码行数:35,代码来源:plugin.py


示例17: doPost

 def doPost(self, handler, path, form):
     if not handler.address_string().endswith('.rs.github.com') and \
             not handler.address_string().endswith('.cloud-ips.com') and \
             not handler.address_string() == 'localhost' and \
             not handler.address_string().startswith('127.0.0.') and \
             not handler.address_string().startswith('192.30.252.') and \
             not handler.address_string().startswith('204.232.175.'):
         log.warning("""'%s' tried to act as a web hook for Github,
         but is not GitHub.""" % handler.address_string())
         self.send_response(403)
         self.send_header('Content-type', 'text/plain')
         self.end_headers()
         self.wfile.write(b('Error: you are not a GitHub server.'))
     else:
         headers = dict(self.headers)
         try:
             self.send_response(200)
             self.send_header('Content-type', 'text/plain')
             self.end_headers()
             self.wfile.write(b('Thanks.'))
         except socket.error:
             pass
         if 'X-GitHub-Event' in headers:
             event = headers['X-GitHub-Event']
         else:
             # WTF?
             event = headers['x-github-event']
         if event == 'ping':
             log.info('Got ping event from GitHub.')
             self.send_response(200)
             self.send_header('Content-type', 'text/plain')
             self.end_headers()
             self.wfile.write(b('Thanks.'))
             return
         self.plugin.announce.onPayload(headers, json.loads(form['payload'].value))
开发者ID:joulez,项目名称:Supybot-plugins,代码行数:35,代码来源:plugin.py


示例18: stopServer

def stopServer():
    """Stops the HTTP server. Should be run only from this module or from
    when the bot is dying (ie. from supybot.world)"""
    global httpServer
    if httpServer is not None:
        log.info('Stopping HTTP server.')
        httpServer.shutdown()
        httpServer = None
开发者ID:fbesser,项目名称:Limnoria,代码行数:8,代码来源:httpserver.py


示例19: startServer

def startServer():
    """Starts the HTTP server. Shouldn't be called from other modules.
    The callback should be an instance of a child of SupyHTTPServerCallback."""
    global httpServer
    log.info('Starting HTTP server.')
    address = (configGroup.host(), configGroup.port())
    httpServer = SupyHTTPServer(address, SupyHTTPRequestHandler)
    Thread(target=httpServer.serve_forever, name='HTTP Server').start()
开发者ID:fbesser,项目名称:Limnoria,代码行数:8,代码来源:httpserver.py


示例20: stopServer

def stopServer():
    """Stops the HTTP server. Should be run only from this module or from
    when the bot is dying (ie. from supybot.world)"""
    global http_servers
    for server in http_servers:
        log.info('Stopping HTTP server: %s' % str(server))
        server.shutdown()
        server = None
开发者ID:Athemis,项目名称:Limnoria,代码行数:8,代码来源:httpserver.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python log.warning函数代码示例发布时间:2022-05-27
下一篇:
Python log.exception函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap