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


Python log.error函数代码示例

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


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

示例1: initialize_imgur_client

    def initialize_imgur_client(self, channel):
        """
        Check if imgur client id or secret are set, and if so initialize
        imgur API client
        """
        if self.imgur_client is None:
            imgur_client_id = self.registryValue("imgurClientID")
            imgur_client_secret = self.registryValue("imgurClientSecret")
            imgur_handler_enabled = self.registryValue("imgurHandlerEnabled", channel=channel)
            
            if imgur_handler_enabled and imgur_client_id and imgur_client_secret:
                log.debug("SpiffyTitles: enabling imgur handler")

                # Initialize API client
                try:
                    from imgurpython import ImgurClient
                    from imgurpython.helpers.error import ImgurClientError
                    
                    try:
                        self.imgur_client = ImgurClient(imgur_client_id, imgur_client_secret)                    
                    except ImgurClientError as e:
                        log.error("SpiffyTitles: imgur client error: %s" % (e.error_message))                    
                except ImportError as e:
                    log.error("SpiffyTitles ImportError: %s" % str(e))
            else:
                log.debug("SpiffyTitles: imgur handler disabled or empty client id/secret")
开发者ID:lunchdump,项目名称:limnoria-plugins,代码行数:26,代码来源:plugin.py

示例2: get_video_id_from_url

 def get_video_id_from_url(self, url, info):
     """
     Get YouTube video ID from URL
     """
     try:
         path = info.path
         domain = info.netloc
         video_id = ""
         
         if domain == "youtu.be":
             video_id = path.split("/")[1]
         else:
             parsed = cgi.parse_qsl(info.query)
             params = dict(parsed)
             
             if "v" in params:
                 video_id = params["v"]
         
         if video_id:
             return video_id
         else:
             log.error("SpiffyTitles: error getting video id from %s" % (url))
     
     except IndexError as e:
         log.error("SpiffyTitles: error getting video id from %s (%s)" % (url, str(e)))
开发者ID:lunchdump,项目名称:limnoria-plugins,代码行数:25,代码来源:plugin.py

示例3: watch

    def watch(self, irc, msg, args, username):
        """\"<username>\"

        Start reporting on edits for the given user."""
        baseUrl = "http://osm.org"

        if not username:
            irc.error('You forgot to give me a username.')
            return

        quoted_uname = username
        quoted_uname = urllib.quote(quoted_uname)

        try:
            xml = urllib2.urlopen('%s/user/%s/edits/feed' % (baseUrl, quoted_uname))
        except urllib2.HTTPError as e:
            response = "Username %s was not found." % (username)
            irc.reply(response.encode('utf-8'))
            return
        except Exception as e:
            irc.error("Could not parse the user's changeset feed.")
            log.error(traceback.format_exc(e))
            return

        if username in self.watch_users: 
            response = "We are already watching %s" % (username)
        else:
            self.watch_users.append(username)
            with open('watchedusers.txt', 'w') as f:
                f.write("\n".join(self.watch_users) + "\n")
            response = "We are now watching %s" % (username)

        irc.reply(response.encode('utf-8'))
开发者ID:IrlJidel,项目名称:supybot-plugin-osm,代码行数:33,代码来源:plugin.py

示例4: getPluginList

 def getPluginList(self):
     latestCommit = self._query(
                               'repos',
                               'show/%s/%s/branches' % (
                                                       self._username,
                                                       self._reponame,
                                                       )
                               )['branches']['master']
     path = [x for x in self._path.split('/') if x != '']
     treeHash = self._navigate(latestCommit, path)
     if treeHash is None:
         log.error((
                   'Cannot get plugins list from repository %s/%s '
                   'at Github'
                   ) % (self._username, self._reponame))
         return []
     nodes = self._query(
                        'tree',
                        'show/%s/%s/%s' % (
                                          self._username,
                                          self._reponame,
                                          treeHash,
                                          )
                        )['tree']
     plugins = [x['name'] for x in nodes if x['type'] == 'tree']
     return plugins
开发者ID:fbesser,项目名称:Limnoria,代码行数:26,代码来源:plugin.py

示例5: 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

示例6: __init__

 def __init__(self, irc):
     self.__parent = super(Twitter, self)
     callbacks.Plugin.__init__(self, irc)
     self._apis = {}
     self._died = False
     if world.starting:
         try:
             self._getApi().PostUpdate(_('I just woke up. :)'))
         except:
             pass
     self._runningAnnounces = []
     try:
         conf.supybot.plugins.Twitter.consumer.key.addCallback(
                 self._dropApiObjects)
         conf.supybot.plugins.Twitter.consumer.secret.addCallback(
                 self._dropApiObjects)
         conf.supybot.plugins.Twitter.accounts.channel.key.addCallback(
                 self._dropApiObjects)
         conf.supybot.plugins.Twitter.accounts.channel.secret.addCallback(
                 self._dropApiObjects)
         conf.supybot.plugins.Twitter.accounts.channel.api.addCallback(
                 self._dropApiObjects)
     except registry.NonExistentRegistryEntry:
         log.error('Your version of Supybot is not compatible with '
                   'configuration hooks. So, Twitter won\'t be able '
                   'to apply changes to the consumer key/secret '
                   'and token key/secret unless you reload it.')
     self._shortids = {}
     self._current_shortid = 0
开发者ID:ArtRichards,项目名称:Supybot-plugins,代码行数:29,代码来源:plugin.py

示例7: raisedead

    def raisedead(self, irc, msg, args, user, target):
        """
        Attempts to raise your target from the dead
        """
        user_id = self._get_user_id(irc, msg.prefix)
        dungeon = self.SpiffyWorld.get_dungeon_by_channel(GAME_CHANNEL)

        if dungeon is not None:
            player = dungeon.get_unit_by_user_id(user_id)
            unit = dungeon.get_dead_unit_by_name(target)

            if unit is not None:
                undead_effect = self.SpiffyWorld.effects_collection.get_effect_undead()

                unit.apply_effect(undead_effect)

                dungeon.announcer.effect_raise_dead(player=player,
                                                    unit=unit)

                dungeon.announcer.unit_info(unit=unit,
                                            dungeon=dungeon,
                                            irc=irc)

                player.add_raised_unit(unit=unit)
            else:
                irc.error(
                    "You attempt to perform the ritual, but something seems amiss.")
        else:
            log.error("Trying to raise dead but there is no dungeon")
开发者ID:butterscotchstallion,项目名称:SpiffyRPG,代码行数:29,代码来源:plugin.py

示例8: _createPrivmsg

        def _createPrivmsg(self, channel, payload, commit, hidden=None):
            bold = ircutils.bold
            url = commit['url']

            try:
                data = urlencode({'url': url})
                if sys.version_info[0] >= 3:
                    data = data.encode()
                    f = utils.web.getUrlFd('http://git.io/', data=data)
                    url = list(filter(lambda x:x[0] == 'Location',
                        f.headers._headers))[0][1].strip()
                else:
                    f = utils.web.getUrlFd('http://git.io/', data=data)
                    url = filter(lambda x:x.startswith('Location: '),
                            f.headers.headers)[0].split(': ', 1)[1].strip()
            except Exception as e:
                log.error('Cannot connect to git.io: %s' % e)

            s = _('%s/%s (in %s): %s committed %s %s') % \
                    (payload['repository']['owner']['name'],
                     bold(payload['repository']['name']),
                     bold(payload['ref'].split('/')[-1]),
                     commit['author']['name'],
                     bold(commit['message'].split('\n')[0]),
                     url)
            if hidden is not None:
                s += _(' (+ %i hidden commits)') % hidden
            if sys.version_info[0] < 3:
                s = s.encode('utf-8')
            return ircmsgs.privmsg(channel, s)
开发者ID:descoai,项目名称:Supybot-plugins,代码行数:30,代码来源:plugin.py

示例9: _translateQuery

    def _translateQuery(self, function, parameters={}):
        
        if (self.registryValue('appId') == ''):
              log.error('Translate: Set your appId and restart the plugin')
              return
        log.debug('Translate.query: %s' % (repr(parameters)))

        if (self.registryValue('httpProxy') != ''):
            opener = urllib2.build_opener(
                urllib2.ProxyHandler({'http': self.registryValue('httpProxy')}))
        else:
            opener = urllib2.build_opener()

        response = opener.open(self.registryValue('queryURL') + function + '?'+
            'appId=' + self.registryValue('appId') + '&' +
            urllib.urlencode(parameters))
            
        try:
            data = json.loads(json.dumps(response.read()))
            data = json.loads(data[1:])
            log.debug('Translate.reply: %s' % repr(data))
            return(data)
        except:
            log.error('Translate.query error')
            return(None)
开发者ID:krautchan,项目名称:erica,代码行数:25,代码来源:plugin.py

示例10: update

 def update(self, irc, msg, args):
     """Update the namecheap pricing information."""
     irc.reply("This could take a second....")
     response = self.namecheap('namecheap.users.getPricing', {'ProductType': 'DOMAIN'})
     if response.get('Status') == "ERROR":
         for error in response[0]:
             log.error(error.text)
             irc.reply("Error! %s" % error.text)
     results = response.find("./{http://api.namecheap.com/xml.response}CommandResponse/{http://api.namecheap.com/xml.response}UserGetPricingResult")
     db = dataset.connect("sqlite:///%s" % self.dbfile)
     pricing_table = db['pricing']
     pricing_table.delete(provider="Namecheap")
     categories = {}
     if results is not None:
         for product_type in results:
             for category in product_type:
                 categories[category.attrib['Name']] = 0
                 for product in category:
                     for duration in product:
                         pricing_table.insert(dict(tld=product.attrib['Name'],
                                                   years=duration.attrib['Duration'],
                                                   category=category.attrib['Name'],
                                                   price=duration.attrib['Price'],
                                                   currency=duration.attrib['Currency'],
                                                   provider="Namecheap"))
                         categories[category.attrib['Name']] += 1
                 irc.reply("Loaded category %s (%s bits of pricing infoz)" % (
                          category.attrib['Name'], categories[category.attrib['Name']]))
         irc.reply("Done! Results: ")
开发者ID:thefinn93,项目名称:Supybot-DomainChecker,代码行数:29,代码来源:plugin.py

示例11: 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

示例12: peak

    def peak(self, irc, msg, args):
        """

        Return the global listener peak of RfK
        """

        try:
            listener_peak = self._query('listener_peak')['data']['listener_peak']

            if listener_peak:
                peak_value = listener_peak['peak_value']
                peak_time = listener_peak['peak_time']
                peak_time_tz = pytz.timezone(self.registryValue('timezone'))
                peak_time_format = dateutil.parser.parse(peak_time).astimezone(peak_time_tz).strftime('%d.%m.%Y %H:%M %Z')
                peak_time_delta = self._format_timedelta(peak_time)

                if 'peak_show' in listener_peak:
                    reply = u'RfK listener peak: %s concurrent listener (reached during "%s" with %s on %s -- %s ago)' % (
                        peak_value, listener_peak['peak_show']['show_name'], self._format_djs(listener_peak['peak_show']), peak_time_format, peak_time_delta)
                else:
                    reply = u'RfK listener peak: %s concurrent listener (reached on %s -- %s ago)' % (
                        peak_value, peak_time_format, peak_time_delta)

        except Exception, e:
            log.error('RfK.peak: %s' % repr(e))
            reply = self.reply_error
开发者ID:buckket,项目名称:supybot-rfk,代码行数:26,代码来源:plugin.py

示例13: traffic

    def traffic(self, irc, msg, args):
        """

        Return traffic information on all active relays
        """

        try:
            active_relays = self._query('active_relays')['data']['active_relays']

            if active_relays:
                slaves = []

                for relay in active_relays['relays']:
                    # type 0 -> Master
                    # type 1 -> Slave
                    if relay['relay_type'] == 0:
                        master = 'master: %d kB/s' % (relay['relay_current_bandwidth'] / 8)
                    elif relay['relay_type'] == 1:
                        slaves.append('relay #%d: %d kB/s' % (relay['relay_id'], relay['relay_current_bandwidth'] / 8))

                reply = u'%d kB/s ( %s | %s )' % (active_relays['total_bandwidth'] / 8, master, ' | '.join(slaves))

            else:
                reply = u'No active relays found'

        except Exception, e:
            log.error('RfK.traffic: %s' % repr(e))
            reply = self.reply_error
开发者ID:buckket,项目名称:supybot-rfk,代码行数:28,代码来源:plugin.py

示例14: domian

    def domian(self, irc, msg, args):
        """

        Returns information about the next episode of Domian
        """
        now = datetime.now()
        feed = feedparser.parse('http://nachtlager.de/go/de/feed/week')
        nextshow = None
        
        for show in feed.entries:
            showStart = datetime.fromtimestamp(mktime(show.published_parsed)).replace(hour=1)
            showEnd = datetime.fromtimestamp(mktime(show.published_parsed)).replace(hour=2)
            show['showstart'] = showStart
            
            if showStart < now and showEnd > now:
                nextshow = show
                nextshow['onair'] = True
            else:
                if showStart > now:
                    if nextshow is None:
                        nextshow = show
                        nextshow['onair'] = False
                    else:
                        if showStart < nextshow['showstart']:
                            nextshow = show
                            nextshow['onair'] = False
        try:
            if nextshow['onair']:
                reply = u'Domian läuft gerade. (%s) - http://www.wdr.de/wdrlive/media/einslive.m3u' % nextshow.description
            else:
                starts_in = formatTimespan(int(mktime(nextshow['showstart'].timetuple()) - time()))
                reply = u'Nächste Sendung am %s (%s) - in %s' % (nextshow['showstart'].strftime('%d.%m.%Y um %H:%M'), nextshow.description, starts_in)
        except Exception, e:
            log.error('Domian: %s' % repr(e))
            reply = u'Noch keine Daten vorhanden!'
开发者ID:Znuff,项目名称:erica,代码行数:35,代码来源:plugin.py

示例15: _query

    def _query(self, function, **params):

        # filter out empty params
        params = {key: value for key, value in params.iteritems() if value}

        log.debug('RfK._query: %s' % repr(params))

        if self.registryValue('httpProxy'):
            opener = urllib2.build_opener(
                urllib2.ProxyHandler({'http': self.registryValue('httpProxy')}))
        else:
            opener = urllib2.build_opener()

        request_url = '%s%s?key=%s&%s' % (
            self.registryValue('queryURL'),
            function,
            self.registryValue('queryPass'),
            urllib.urlencode(params)
        )

        try:
            response = opener.open(request_url)
        except IOError, e:
            log.error('RfK._query: %s' % repr(e))
            return None
开发者ID:buckket,项目名称:supybot-rfk,代码行数:25,代码来源:plugin.py


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