def refresh( self ): #self.Bookmarks = [] auth_handler = urllib2.HTTPBasicAuthHandler() auth_handler.add_password( 'Google Search History', 'www.google.com', self.username, self.password ) opener = urllib2.build_opener( auth_handler ) bookmark_feed = opener.open( "https://www.google.com/bookmarks/?output=rss" ) for item in parse( bookmark_feed ).documentElement.getElementsByTagName( "item" ): title = item.getElementsByTagName( "title" )[0].childNodes[0].data link = item.getElementsByTagName( "link" )[0].childNodes[0].data bookmark = Bookmark( title, link ) bookmark.set_UID( bookmark.get_hash() ) self.Bookmarks.append( bookmark ) DataProvider.DataSource.refresh( self )
def refresh( self ): # sqlite3 is not thread safe, so we cannot preserve connections in this class Con = sqlite3.connect( self.FirefoxDir + self.ProfilePath + "/places.sqlite" ) try: Cur = Con.execute( "select * from moz_bookmarks" ) except: log.debug( self.SYNCERROR ) raise Exceptions.SyncronizeError( self.SYNCERROR ) for Line in Cur.fetchall(): ( bid, btype, fk, parent, position, title, keywordid, folder_type, dateadded, lastmodified ) = Line if not fk: # this bookmark has no url, that means it's a folder or something firefox specific continue else: bookmark = Bookmark( title, self.get_bookmark_url_from_fk( fk ) ) bookmark.set_UID( bookmark.get_hash() ) self.Bookmarks.append( bookmark ) Con.close() DataProvider.DataSource.refresh( self )