예제 #1
0
 def refresh(self):
     DataProvider.TwoWay.refresh(self)
     self.notes = []
     if self._connect_to_tomboy():
         self.notes = [str(i) for i in self.remoteTomboy.ListAllNotes()]
     else:
         raise Exceptions.RefreshError("Tomboy not available")
예제 #2
0
 def refresh(self):
     Image.ImageTwoWay.refresh(self)
     self.photos = []
     if self._connect_to_fspot():
         self.photos = self.photo_remote.Query(self.enabledTags)
     else:
         raise Exceptions.RefreshError("FSpot not available")
예제 #3
0
    def refresh(self):
        DataProvider.DataSource.refresh(self)
        #only work if Banshee is installed
        if not os.path.exists(BansheeSource.MUSIC_DB):
            raise Exceptions.RefreshError("Banshee is not installed")

        #Stupid pysqlite thread stuff.
        #Connection must be made in the same thread
        #as any execute statements
        con = sqlite.connect(BansheeSource.MUSIC_DB)
        cur = con.cursor()

        for playlistid in self.playlists:
            if BANSHEE_VERSION_1:
                cur.execute(
                    "select Uri from CoreTracks INNER JOIN CorePlaylistEntries ON CorePlaylistEntries.TrackID=CoreTracks.TrackID where PlaylistID=%s"
                    % (playlistid))
            else:
                cur.execute(
                    "select Uri from Tracks INNER JOIN PlaylistEntries ON PlaylistEntries.TrackID=Tracks.TrackID where PlaylistID=%s"
                    % (playlistid))
            for Uri in cur:
                self.tracks.append(self._get_full_uri(Uri[0]))

        for playlistid in self.smart_playlists + self.video_playlists:
            cur.execute(
                "select Uri from CoreTracks INNER JOIN CoreSmartPlaylistEntries ON CoreSmartPlaylistEntries.TrackID where PlaylistID=%s"
                % (playlistid))
            for Uri in cur:
                self.tracks.append(self._get_full_uri(Uri[0]))
        con.close()
예제 #4
0
 def refresh(self):
     d = File.File(URI=self.folder)
     if not d.exists():
         try:
             d.make_directory_and_parents()
         except:
             raise Exceptions.RefreshError("Error Creating Directory")
     FileDataProvider.FolderTwoWay.refresh(self)
예제 #5
0
    def _get_all_albums(self):
        #only work if picasa has been configured to use a CSV DB
        #http://www.zmarties.com/picasa/
        dbfile = os.path.join(PICASA_DIR, 'drive_c', 'Program Files',
                              'Picasa2', 'db', 'dirscanner.csv')
        if not os.path.exists(dbfile):
            raise Exceptions.RefreshError(
                "Picasa Not Configured to use CSV Database")

        pals = []
        #Open the CSV file and find all entries with Type = 19 (albums)
        f = open(dbfile, 'rt')
        try:
            reader = csv.DictReader(f)
            for row in reader:
                if row['Type'] == '19':
                    #wine picasa stores all pal files (that describes an album)
                    #in the following base dir
                    parts = [
                        PICASA_DIR, 'drive_c', 'Documents and Settings',
                        os.getlogin(), 'Local Settings'
                    ]
                    #and then as given in the csv file
                    #but first change the windows path to a linux one
                    parts += row['Name'].split("\\")
                    path = os.path.abspath(os.sep.join(parts))
                    pals.append(path)
        finally:
            f.close()

        #parse each pal file to get album info
        albums = []
        for pal in pals:
            log.debug("Parsing album file %s" % pal)
            doc = xml.dom.minidom.parse(pal)
            #album name
            for prop in doc.getElementsByTagName('property'):
                if prop.hasAttribute("name") and prop.getAttribute(
                        "name") == "name":
                    name = prop.getAttribute("value")
            #image filenames
            photos = []
            for f in doc.getElementsByTagName('filename'):
                filename = self._fix_picasa_image_filename(f.firstChild.data)
                if filename != None:
                    photos.append(filename)

            albums.append((
                pal,  #FILENAME_IDX
                name,  #DISPLAYNAME_IDX 
                photos))  #PHOTOS_IDX

        return albums
예제 #6
0
    def refresh(self):
        Image.ImageTwoWay.refresh(self)

        try:
            self.zapi = MyZotoAPI(self.username, self.password)
            albums = self.zapi.get_albums()
            if not albums.has_key(self.albumName):
                self.albumId = self.zapi.create_album(self.albumName)
            else:
                self.albumId = albums[self.albumName]

            self.sphotos = self.zapi.get_photos_album(self.albumId)
        except xmlrpclib.Fault, e:
            log.debug("Error refreshing: %s" % e.faultString)
            raise Exceptions.RefreshError(e.faultString)
예제 #7
0
 def refresh(self):
     DataProvider.DataSource.refresh(self)
     try:
         self.allPlaylists = self._get_playlists()
     except DBusClosedConnectionError:
         raise Exceptions.RefreshError("Could not connect to Rhythmbox")