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


Python log.info函数代码示例

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


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


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