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


Python utils.timeElapsed函数代码示例

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


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

示例1: _seen

 def _seen(self, irc, channel, name, any=False):
     if any:
         db = self.anydb
     else:
         db = self.db
     try:
         results = []
         if '*' in name:
             results = db.seenWildcard(channel, name)
         else:
             results = [[name, db.seen(channel, name)]]
         if len(results) == 1:
             (nick, info) = results[0]
             (when, said) = info
             irc.reply(format('%s was last seen in %s %s ago: %s',
                              nick, channel,
                              utils.timeElapsed(time.time()-when), said))
         elif len(results) > 1:
             L = []
             for (nick, info) in results:
                 (when, said) = info
                 L.append(format('%s (%s ago)', nick,
                                 utils.timeElapsed(time.time()-when)))
             irc.reply(format('%s could be %L', name, (L, 'or')))
         else:
             irc.reply(format('I haven\'t seen anyone matching %s.', name))
     except KeyError:
         irc.reply(format('I have not seen %s.', name))
开发者ID:bnrubin,项目名称:supybot_fixes,代码行数:28,代码来源:plugin.py

示例2: _seen

 def _seen(self, irc, channel, name, any=False):
     if any:
         db = self.anydb
     else:
         db = self.db
     try:
         results = []
         if '*' in name:
             if (len(name.replace('*', '')) <
                     self.registryValue('minimumNonWildcard', channel)):
                 irc.error(_('Not enough non-wildcard characters.'),
                         Raise=True)
             results = db.seenWildcard(channel, name)
         else:
             results = [[name, db.seen(channel, name)]]
         if len(results) == 1:
             (nick, info) = results[0]
             (when, said) = info
             irc.reply(format(_('%s was last seen in %s %s ago: %s'),
                              nick, channel,
                              utils.timeElapsed(time.time()-when), said))
         elif len(results) > 1:
             L = []
             for (nick, info) in results:
                 (when, said) = info
                 L.append(format(_('%s (%s ago)'), nick,
                                 utils.timeElapsed(time.time()-when)))
             irc.reply(format(_('%s could be %L'), name, (L, _('or'))))
         else:
             irc.reply(format(_('I haven\'t seen anyone matching %s.'), name))
     except KeyError:
         irc.reply(format(_('I have not seen %s.'), name))
开发者ID:Erika-Mustermann,项目名称:Limnoria,代码行数:32,代码来源:plugin.py

示例3: bcstats

 def bcstats(self, irc, msg, args):
     """takes no arguments
     
     Shows a number of statistics about the state of the block chain.
     """
     blocks = self._blocks()
     diff = self._diff()
     try:
         estimate = self._nethashsincelast() * 139.696254564
     except:
         estimate = None
     try:
         diffchange = round((estimate/float(diff) - 1)  * 100, 5)
     except:
         diffchange = None
     nextretarget = self._nextretarget()
     try:
         blockstoretarget = int(nextretarget) - int(blocks)
     except:
         blockstoretarget = None
     try:
         timetonext = utils.timeElapsed(self._timetonext())
     except:
         timetonext = None        
     
     irc.reply("Current Blocks: %s | Current Difficulty: %s | "
             "Next Difficulty At Block: %s | "
             "Next Difficulty In: %s blocks | "
             "Next Difficulty In About: %s | "
             "Next Difficulty Estimate: %s | "
             "Estimated Percent Change: %s" % (blocks, diff, 
                     nextretarget, blockstoretarget, timetonext, 
                     estimate, diffchange))
开发者ID:Mwako,项目名称:supybot-bitcoin-marketmonitor,代码行数:33,代码来源:plugin.py

示例4: invalidCommand

 def invalidCommand(self, irc, msg, tokens):
     assert not msg.repliedTo, 'repliedTo msg in Misc.invalidCommand.'
     assert self is irc.callbacks[-1], 'Misc isn\'t last callback.'
     self.log.debug('Misc.invalidCommand called (tokens %s)', tokens)
     channel = msg.args[0]
     # Only bother with the invaildCommand flood handling if it's actually
     # enabled
     if conf.supybot.abuse.flood.command.invalid():
         # First, we check for invalidCommand floods.  This is rightfully done
         # here since this will be the last invalidCommand called, and thus it
         # will only be called if this is *truly* an invalid command.
         maximum = conf.supybot.abuse.flood.command.invalid.maximum()
         banmasker = conf.supybot.protocols.irc.banmask.makeBanmask
         self.invalidCommands.enqueue(msg)
         if self.invalidCommands.len(msg) > maximum and \
            not ircdb.checkCapability(msg.prefix, 'owner'):
             penalty = conf.supybot.abuse.flood.command.invalid.punishment()
             banmask = banmasker(msg.prefix)
             self.log.info('Ignoring %s for %s seconds due to an apparent '
                           'invalid command flood.', banmask, penalty)
             if tokens and tokens[0] == 'Error:':
                 self.log.warning('Apparent error loop with another Supybot '
                                  'observed.  Consider ignoring this bot '
                                  'permanently.')
             ircdb.ignores.add(banmask, time.time() + penalty)
             if conf.supybot.abuse.flood.command.invalid.notify():
                 irc.reply('You\'ve given me %s invalid commands within '
                           'the last minute; I\'m now ignoring you for %s.' %
                           (maximum,
                            utils.timeElapsed(penalty, seconds=False)))
             return
     # Now, for normal handling.
     if conf.get(conf.supybot.reply.whenNotCommand, channel):
         if len(tokens) >= 2:
             cb = irc.getCallback(tokens[0])
             if cb:
                 plugin = cb.name()
                 irc.error(format('The %q plugin is loaded, but there is '
                                  'no command named %q in it.  Try "list '
                                  '%s" to see the commands in the %q '
                                  'plugin.', plugin, tokens[1],
                                  plugin, plugin))
             else:
                 irc.errorInvalid('command', tokens[0], repr=False)
         else:
             command = tokens and tokens[0] or ''
             irc.errorInvalid('command', command, repr=False)
     else:
         if tokens:
             # echo [] will get us an empty token set, but there's no need
             # to log this in that case anyway, it being a nested command.
             self.log.info('Not replying to %s, not a command.', tokens[0])
         if irc.nested:
             bracketConfig = conf.supybot.commands.nested.brackets
             brackets = conf.get(bracketConfig, channel)
             if brackets:
                 (left, right) = brackets
                 irc.reply(left + ' '.join(tokens) + right)
             else:
                 pass # Let's just do nothing, I can't think of better.
开发者ID:Chalks,项目名称:Supybot,代码行数:60,代码来源:plugin.py

示例5: info

    def info(self, irc, msg, args, url):
        """<url|feed>

        Returns information from the given RSS feed, namely the title,
        URL, description, and last update date, if available.
        """
        try:
            url = self.registryValue('feeds.%s' % url)
        except registry.NonExistentRegistryEntry:
            pass
        feed = self.get_feed(url)
        if not feed:
            feed = Feed(url, url, True)
        self.update_feed_if_needed(feed)
        info = feed.data
        if not info:
            irc.error(_('I couldn\'t retrieve that RSS feed.'))
            return
        # check the 'modified_parsed' key, if it's there, convert it here first
        if 'modified' in info:
            seconds = time.mktime(info['modified_parsed'])
            now = time.mktime(time.gmtime())
            when = utils.timeElapsed(now - seconds) + ' ago'
        else:
            when = _('time unavailable')
        title = info.get('title', _('unavailable'))
        desc = info.get('description', _('unavailable'))
        link = info.get('link', _('unavailable'))
        # The rest of the entries are all available in the channel key
        response = format(_('Title: %s;  URL: %u;  '
                          'Description: %s;  Last updated: %s.'),
                          title, link, desc, when)
        irc.reply(utils.str.normalizeWhitespace(response))
开发者ID:nW44b,项目名称:Limnoria,代码行数:33,代码来源:plugin.py

示例6: _timestamp

 def _timestamp(self, when):
     # format = conf.supybot.reply.format.time()
     diff = time.time() - when
     try:
         return _("%s ago") % utils.timeElapsed(diff, seconds=False)
     except ValueError:
         return _("just now")
开发者ID:resistivecorpse,项目名称:Limnoria,代码行数:7,代码来源:plugin.py

示例7: elapsed

    def elapsed(self, irc, msg, args, seconds):
        """<seconds>

        Returns a pretty string that is the amount of time represented by
        <seconds>.
        """
        irc.reply(utils.timeElapsed(seconds))
开发者ID:Athemis,项目名称:Limnoria,代码行数:7,代码来源:plugin.py

示例8: info

    def info(self, irc, msg, args, url):
        """<url|feed>

        Returns information from the given RSS feed, namely the title,
        URL, description, and last update date, if available.
        """
        try:
            url = self.registryValue("feeds.%s" % url)
        except registry.NonExistentRegistryEntry:
            pass
        feed = self.getFeed(url)
        conv = self._getConverter(feed)
        info = feed.get("feed")
        if not info:
            irc.error("I couldn't retrieve that RSS feed.")
            return
        # check the 'modified_parsed' key, if it's there, convert it here first
        if "modified" in info:
            seconds = time.mktime(info["modified_parsed"])
            now = time.mktime(time.gmtime())
            when = utils.timeElapsed(now - seconds) + " ago"
        else:
            when = "time unavailable"
        title = conv(info.get("title", "unavailable"))
        desc = conv(info.get("description", "unavailable"))
        link = conv(info.get("link", "unavailable"))
        # The rest of the entries are all available in the channel key
        response = format("Title: %s;  URL: %u;  " "Description: %s;  Last updated: %s.", title, link, desc, when)
        irc.reply(utils.str.normalizeWhitespace(response))
开发者ID:MrTiggr,项目名称:supybot_fixes,代码行数:29,代码来源:plugin.py

示例9: _timestamp

 def _timestamp(self, when):
     #format = conf.supybot.reply.format.time()
     diff = when - time.time()
     try:
         return utils.timeElapsed(diff, seconds=False)
     except ValueError:
         return _('just now')
开发者ID:carriercomm,项目名称:Limnoria,代码行数:7,代码来源:plugin.py

示例10: doPrivmsg

 def doPrivmsg(self, irc, msg):
     assert self is irc.callbacks[0], \
            'Owner isn\'t first callback: %r' % irc.callbacks
     if ircmsgs.isCtcp(msg):
         return
     s = callbacks.addressed(irc.nick, msg)
     if s:
         ignored = ircdb.checkIgnored(msg.prefix)
         if ignored:
             self.log.info('Ignoring command from %s.', msg.prefix)
             return
         maximum = conf.supybot.abuse.flood.command.maximum()
         self.commands.enqueue(msg)
         if conf.supybot.abuse.flood.command() \
            and self.commands.len(msg) > maximum \
            and not ircdb.checkCapability(msg.prefix, 'trusted'):
             punishment = conf.supybot.abuse.flood.command.punishment()
             banmask = ircutils.banmask(msg.prefix)
             self.log.info('Ignoring %s for %s seconds due to an apparent '
                           'command flood.', banmask, punishment)
             ircdb.ignores.add(banmask, time.time() + punishment)
             irc.reply('You\'ve given me %s commands within the last '
                       'minute; I\'m now ignoring you for %s.' %
                       (maximum,
                        utils.timeElapsed(punishment, seconds=False)))
             return
         try:
             tokens = callbacks.tokenize(s, channel=msg.args[0])
             self.Proxy(irc, msg, tokens)
         except SyntaxError, e:
             irc.queueMsg(callbacks.error(msg, str(e)))
开发者ID:boamaod,项目名称:Limnoria,代码行数:31,代码来源:plugin.py

示例11: uptime

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

        Returns the amount of time the bot has been running.
        """
        response = _("I have been running for %s.") % utils.timeElapsed(time.time() - world.startedAt)
        irc.reply(response)
开发者ID:ki113d,项目名称:Limnoria,代码行数:7,代码来源:plugin.py

示例12: net

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

        Returns some interesting network-related statistics.
        """
        try:
            elapsed = time.time() - self.connected[irc.getRealIrc()]
            timeElapsed = utils.timeElapsed(elapsed)
        except KeyError:
            timeElapsed = _("an indeterminate amount of time")
        irc.reply(
            format(
                _(
                    "I have received %s messages for a total of %S.  "
                    "I have sent %s messages for a total of %S.  "
                    "I have been connected to %s for %s."
                ),
                self.recvdMsgs,
                self.recvdBytes,
                self.sentMsgs,
                self.sentBytes,
                irc.server,
                timeElapsed,
            )
        )
开发者ID:ki113d,项目名称:Limnoria,代码行数:25,代码来源:plugin.py

示例13: tblb

 def tblb(self, irc, msg, args, interval):
     """<interval>
     
     Calculate the expected time between blocks which take at least
     <interval> seconds to create.
     To provide the <interval> argument, a nested 'seconds' command may be helpful.
     """
     try:
         difficulty = float(self._diff())
         nh = float(self._nethash3d())
         gp = self._genprob(nh*1000, interval, difficulty)
     except:
         irc.error("Problem retrieving data. Try again later.")
         return
     sblb = (difficulty * 2**48 / 65535) / (nh * 1e9) / (1 - gp)
     irc.reply("The expected time between blocks taking %s to generate is %s" % \
             (utils.timeElapsed(interval), utils.timeElapsed(sblb),))
开发者ID:Mwako,项目名称:supybot-bitcoin-marketmonitor,代码行数:17,代码来源:plugin.py

示例14: uptime

 def uptime(self, irc, msg, args, otherIrc):
     """[<network>]
     
     Returns the time duration since the connection was established.
     """
     network = otherIrc.network
     now = time.time()
     started = otherIrc.startedAt
     irc.reply(_("I've been connected to %s for %s.") % (network, utils.timeElapsed(now - started)))
开发者ID:carriercomm,项目名称:Limnoria,代码行数:9,代码来源:plugin.py

示例15: _formatNote

 def _formatNote(self, note, to):
     elapsed = utils.timeElapsed(time.time() - note.at)
     if note.to == to:
         author = plugins.getUserName(note.frm)
         return format("#%i: %s (Sent by %s %s ago)", note.id, note.text, author, elapsed)
     else:
         assert note.frm == to, "Odd, userid isn't frm either."
         recipient = plugins.getUserName(note.to)
         return format("#%i: %s (Sent to %s %s ago)", note.id, note.text, recipient, elapsed)
开发者ID:the1glorfindel,项目名称:PoohBot,代码行数:9,代码来源:plugin.py


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