X-Git-Url: http://git.kaliko.me/?p=sid.git;a=blobdiff_plain;f=sid%2Ffeeds.py;h=043c784dcb23f4cf0484bee46badee0f2e370e27;hp=7291af27cc72dae9bf22644466b8c2757bc5ef92;hb=1d5d7c371bdecaf42cd6785f8c8ab152f0eaec48;hpb=8050b8698ff1f6294abceb8b022a4aecdbe8375e diff --git a/sid/feeds.py b/sid/feeds.py index 7291af2..043c784 100644 --- a/sid/feeds.py +++ b/sid/feeds.py @@ -34,7 +34,7 @@ html_escape_table = { def html_escape(text): """Produce entities within text.""" - return "".join(html_escape_table.get(c, c) for c in text) + return ''.join(html_escape_table.get(c, c) for c in text) def strtm_to_dtm(struc_time): @@ -52,8 +52,7 @@ class FeedMonitor(threading.Thread): self.thread_killed = False def send(self, message): - """simple wrapper around JabberBot().send()""" - self.bot.log.debug(self.bot.room) + """simple wrapper around bot send_message method""" self.bot.send_message(mto=self.bot.room, mbody=message[1], mhtml=message[0], @@ -65,14 +64,14 @@ class FeedMonitor(threading.Thread): # Cannot resolve address if 'status' not in parsed_feed: - self.bot.log.error(u'Error from "%s": %s.' % + self.bot.log.error('Error from "%s": %s.' % (feed, parsed_feed.bozo_exception.__repr__())) return # unusual return http code if parsed_feed.status != 200: self.bot.log.error( - u'Got code %(status)d from "%(href)s" (please update).' % + 'Got code %(status)d from "%(href)s" (please update).' % parsed_feed) return @@ -84,8 +83,8 @@ class FeedMonitor(threading.Thread): self.bot.log.debug('last check: %s' % self.last_check) return - title = u'"%s":' % parsed_feed.feed.get('title', 'n/a') - xtitle = u'%s:' % html_escape( + title = '"%s":' % parsed_feed.feed.get('title', 'n/a') + xtitle = '%s:' % html_escape( parsed_feed.feed.get('title', 'n/a')) text = [title] xhtml = [xtitle] @@ -101,12 +100,12 @@ class FeedMonitor(threading.Thread): self.seen[feed_id].append(post.id) self.bot.log.info(post.title) - body = u'%(title)s %(link)s' % post + body = '%(title)s %(link)s' % post text.append(body) xpost = dict(**post) xpost['title'] = html_escape(xpost.get('title', 'n/a')) - xbody = u'%(title)s' % xpost + xbody = '%(title)s' % xpost xhtml.append(xbody) if len(text) > 1: @@ -114,12 +113,12 @@ class FeedMonitor(threading.Thread): def run(self): while not self.thread_killed: - self.bot.log.info(u'feeds check') + self.bot.log.debug('feeds check') for feed in self.feeds_list: try: self.new_posts(feed) except Exception as err: - self.bot.log.error(u'feeds thread crashed') + self.bot.log.error('feeds thread crashed') self.bot.log.error(err) self.thread_killed = True self.last_check = datetime.datetime.utcnow() @@ -163,5 +162,5 @@ class Feeds(Plugin): !feeds : registred feeds list !feeds last : last check time""" if 'last' in args: - return u'Last feeds check: %s' % self.th_mon.last_check - return u'\n'.join(Feeds.FEEDS) + return 'Last feeds check: %s' % self.th_mon.last_check + return '\n'.join(Feeds.FEEDS)