import urllib2
from BeautifulSoup import BeautifulSoup
from urlparse import urljoin
+import logging
+logger = logging.getLogger(__name__)
#CONFIGDIR="/home/user/.feedingit/"
f.close()
outf.close()
except:
- print "Could not download " + url
+ logger.error("Could not download " + url)
else:
#open(filename,"a").close() # "Touch" the file
file = open(filename,"a")
img['src']=filename
tmpEntry["images"].append(filename)
except:
- print "Error downloading image %s" % img
+ logger.error("Error downloading image %s" % img)
tmpEntry["contentLink"] = configdir+self.uniqueId+".d/"+id+".html"
file = open(tmpEntry["contentLink"], "w")
file.write(soup.prettify())
tmpEntries[entryId] = self.entries[entryId]
tmpIds.append(entryId)
except:
- print "Error purging old articles %s" % entryId
+ logger.error("Error purging old articles %s" % entryId)
self.removeEntry(entryId)
self.entries = tmpEntries
#
except OSError:
#
- print 'Could not remove', file
+ logger.error('Could not remove %s' % file)
def extractContent(self, entry):
try:
remove(entry["contentLink"]) #os.remove
except:
- print "File not found for deletion: %s" % entry["contentLink"]
+ logger.error("File not found for deletion: %s"
+ % entry["contentLink"])
del self.entries[id]
else:
- print "Entries has no %s key" % id
+ logger.error("Entries has no %s key" % id)
if id in self.ids:
self.ids.remove(id)
else:
- print "Ids has no %s key" % id
+ logger.error("Ids has no %s key" % id)
if self.readItems.has_key(id):
if self.readItems[id]==False:
self.countUnread = self.countUnread - 1
del self.readItems[id]
else:
- print "ReadItems has no %s key" % id
+ logger.error("ReadItems has no %s key" % id)
#except:
# print "Error removing entry %s" %id
except:
# If the feed file gets corrupted, we need to reset the feed.
import traceback
- traceback.print_exc()
+ logger.error("getFeed: %s" % traceback.format_exc())
import dbus
bus = dbus.SessionBus()
remote_object = bus.get_object("org.freedesktop.Notifications", # Connection name