Esempio n. 1
0
 def test_plurals(self):
     with locale_numeric_conv():
         wlw = WaitLoadWindow(None, 1234, "At %(current)d of %(total)d")
         self.failUnlessEqual(wlw._label.get_text(), "At 0 of 1,234")
         while wlw.current < 1000:
             wlw.step()
         self.failUnlessEqual(wlw._label.get_text(), "At 1,000 of 1,234")
Esempio n. 2
0
	def plugin_songs(self, songs):
		if not ConfirmAction(self.plugin_window,
			_('Set dacapo Lyric Flag'),
			_("Check {!s} files?").format(self.counter)
								  ).run():
			logging.debug("Verarbeitung abgebrochen!")
			return True
		logging.debug("Starte Verarbeitung!")
		win = WaitLoadWindow(
			self.plugin_window, len(songs),
			_("Suche nach Synchronisierten Texten.\n\n%(current)d/%(total)d Songs verarbeitet."))
		for song in songs:
			logging.debug(u'Song: %s hassynclyrics %s' % (song.list('title'), song.get('hassynclyrics')))
			if song.get("~filename", "").endswith(".flac"):
				flacFilePath = song.get("~filename", "")
				try:
					lyrics = self.getLrycs(flacFilePath)
					if(lyrics == False):
						song["hassynclyrics"] = '0'
					else:
						song["hassynclyrics"] = '1'
				except:
					return False
			if win.step():
				break
		win.destroy()
Esempio n. 3
0
 def plugin_songs(self, songs):
     if not ConfirmAction(self.plugin_window, _('Set dacapo Lyric Flag'),
                          _("Check {!s} files?").format(
                              self.counter)).run():
         logging.debug("Verarbeitung abgebrochen!")
         return True
     logging.debug("Starte Verarbeitung!")
     win = WaitLoadWindow(
         self.plugin_window, len(songs),
         _("Suche nach Synchronisierten Texten.\n\n%(current)d/%(total)d Songs verarbeitet."
           ))
     for song in songs:
         logging.debug(u'Song: %s hassynclyrics %s' %
                       (song.list('title'), song.get('hassynclyrics')))
         if song.get("~filename", "").endswith(".flac"):
             flacFilePath = song.get("~filename", "")
             try:
                 lyrics = self.getLrycs(flacFilePath)
                 if (lyrics == False):
                     song["hassynclyrics"] = '0'
                 else:
                     song["hassynclyrics"] = '1'
             except:
                 return False
         if win.step():
             break
     win.destroy()
Esempio n. 4
0
def __ParsePlaylist(name, plfilename, files, library):
    playlist = Playlist.new(PLAYLISTS, name, library=library)
    songs = []
    win = WaitLoadWindow(
        None, len(files),
        _("Importing playlist.\n\n%(current)d/%(total)d songs added."))
    for i, filename in enumerate(files):
        try: uri = URI(filename)
        except ValueError:
            # Plain filename.
            filename = os.path.realpath(os.path.join(
                os.path.dirname(plfilename), filename))
            if library and filename in library:
                songs.append(library[filename])
            else:
                songs.append(formats.MusicFile(filename))
        else:
            if uri.scheme == "file":
                # URI-encoded local filename.
                filename = os.path.realpath(os.path.join(
                    os.path.dirname(plfilename), uri.filename))
                if library and filename in library:
                    songs.append(library[filename])
                else:
                    songs.append(formats.MusicFile(filename))
            else:
                # Who knows! Hand it off to GStreamer.
                songs.append(formats.remote.RemoteFile(uri))
        if win.step(): break
    win.destroy()
    playlist.extend(filter(None, songs))
    return playlist
Esempio n. 5
0
 def test_plurals(self):
     with locale_numeric_conv():
         wlw = WaitLoadWindow(None, 1234, "At %(current)d of %(total)d")
         self.failUnlessEqual(wlw._label.get_text(), "At 0 of 1,234")
         while wlw.current < 1000:
             wlw.step()
         self.failUnlessEqual(wlw._label.get_text(), "At 1,000 of 1,234")
Esempio n. 6
0
def _do_trash_songs(parent, songs, librarian):
    dialog = TrashDialog.for_songs(parent, songs)
    resp = dialog.run()
    if resp != TrashDialog.RESPONSE_TRASH:
        return

    window_title = _("Moving %(current)d/%(total)d.")

    w = WaitLoadWindow(parent, len(songs), window_title)
    w.show()

    ok = []
    failed = []
    for song in songs:
        filename = song("~filename")
        try:
            trash.trash(filename)
        except trash.TrashError as e:
            print_w("Couldn't trash file (%s)" % e)
            failed.append(song)
        else:
            ok.append(song)
        w.step()
    w.destroy()

    if failed:
        ErrorMessage(parent, _("Unable to move to trash"),
                     _("Moving one or more files to the trash failed.")).run()

    if ok:
        librarian.remove(ok)
Esempio n. 7
0
def _do_trash_files(parent, paths):
    dialog = TrashDialog.for_files(parent, paths)
    resp = dialog.run()
    if resp != TrashDialog.RESPONSE_TRASH:
        return

    window_title = _("Moving %(current)d/%(total)d.")
    w = WaitLoadWindow(parent, len(paths), window_title)
    w.show()

    ok = []
    failed = []
    for path in paths:
        try:
            trash.trash(path)
        except trash.TrashError:
            failed.append(path)
        else:
            ok.append(path)
        w.step()
    w.destroy()

    if failed:
        ErrorMessage(parent, _("Unable to move to trash"),
                     _("Moving one or more files to the trash failed.")).run()
Esempio n. 8
0
def _do_delete_songs(parent, songs, librarian):
    dialog = DeleteDialog.for_songs(parent, songs)
    resp = dialog.run()
    if resp != DeleteDialog.RESPONSE_DELETE:
        return

    window_title = _("Deleting %(current)d/%(total)d.")

    w = WaitLoadWindow(parent, len(songs), window_title)
    w.show()

    ok = []
    failed = []
    for song in songs:
        filename = song("~filename")
        try:
            os.unlink(filename)
        except EnvironmentError:
            failed.append(song)
        else:
            ok.append(song)
        w.step()
    w.destroy()

    if failed:
        ErrorMessage(parent, _("Unable to delete files"),
                     _("Deleting one or more files failed.")).run()

    if ok:
        librarian.remove(ok)
Esempio n. 9
0
def _do_delete_files(parent, paths):
    dialog = DeleteDialog.for_files(parent, paths)
    resp = dialog.run()
    if resp != DeleteDialog.RESPONSE_DELETE:
        return

    window_title = _("Deleting %(current)d/%(total)d.")

    w = WaitLoadWindow(parent, len(paths), window_title)
    w.show()

    ok = []
    failed = []
    for path in paths:
        try:
            os.unlink(path)
        except EnvironmentError:
            failed.append(path)
        else:
            ok.append(path)
        w.step()
    w.destroy()

    if failed:
        ErrorMessage(parent, _("Unable to delete files"),
                     _("Deleting one or more files failed.")).run()
Esempio n. 10
0
class TWaitLoadWindow(TestCase):

    class DummyConnector(Gtk.Window):
        count = 0

        def connect(self, *args):
            self.count += 1

        def disconnect(self, *args):
            self.count -= 1

        class Eater:
            def set_cursor(*args):
                pass

        window = Eater()

    def setUp(self):
        self.parent = self.DummyConnector()
        self.wlw = WaitLoadWindow(self.parent, 5, "a test")

    def test_none(self):
        wlw = WaitLoadWindow(None, 5, "a test")
        wlw.step()
        wlw.destroy()

    def test_plurals(self):
        with locale_numeric_conv():
            wlw = WaitLoadWindow(None, 1234, "At %(current)d of %(total)d")
            self.failUnlessEqual(wlw._label.get_text(), "At 0 of 1,234")
            while wlw.current < 1000:
                wlw.step()
            self.failUnlessEqual(wlw._label.get_text(), "At 1,000 of 1,234")

    def test_connect(self):
        self.failUnlessEqual(2, self.parent.count)
        self.wlw.destroy()
        self.failUnlessEqual(0, self.parent.count)

    def test_start(self):
        self.failUnlessEqual(0, self.wlw.current)
        self.failUnlessEqual(5, self.wlw.count)

    def test_step(self):
        self.failIf(self.wlw.step())
        self.failUnlessEqual(1, self.wlw.current)
        self.failIf(self.wlw.step())
        self.failIf(self.wlw.step())
        self.failUnlessEqual(3, self.wlw.current)

    def test_destroy(self):
        self.wlw.destroy()
        self.failUnlessEqual(0, self.parent.count)

    def tearDown(self):
        self.wlw.destroy()
Esempio n. 11
0
def __parse_playlist(name, plfilename, files, library):
    playlist = Playlist.new(PLAYLISTS, name, library=library)
    songs = []
    win = WaitLoadWindow(
        None, len(files),
        _("Importing playlist.\n\n%(current)d/%(total)d songs added."))
    win.show()
    for i, filename in enumerate(files):
        try:
            uri = URI(filename)
        except ValueError:
            # Plain filename.
            filename = os.path.realpath(
                os.path.join(os.path.dirname(plfilename), filename))
            if library and filename in library:
                songs.append(library[filename])
            else:
                songs.append(formats.MusicFile(filename))
        else:
            if uri.scheme == "file":
                # URI-encoded local filename.
                filename = os.path.realpath(
                    os.path.join(os.path.dirname(plfilename), uri.filename))
                if library and filename in library:
                    songs.append(library[filename])
                else:
                    songs.append(formats.MusicFile(filename))
            else:
                # Who knows! Hand it off to GStreamer.
                songs.append(formats.remote.RemoteFile(uri))
        if win.step():
            break
    win.destroy()
    playlist.extend(filter(None, songs))
    return playlist
Esempio n. 12
0
    def plugin_songs(self, songs):

        if (songs is None) or (len(songs) <= 0):
            return True

        if (len(songs) > 1) and not ConfirmAction(
                self.plugin_window, _(self.PLUGIN_NAME),
                _("Open {!s} files in QtSyncLyrics?").format(
                    len(songs))).run():
            return True

        win = WaitLoadWindow(
            self.plugin_window, len(songs),
            _("Checking...\n\n%(current)d/%(total)d Songs done."))
        for song in songs:
            if song.get("~filename", "").endswith(".flac"):
                try:
                    program = 'QtSyncLyrics'
                    subprocess.call([program, song.get("~filename", "")])
                except:
                    win.destroy()
                    self.printError()
                    return False
            if win.step():
                break
        win.destroy()
Esempio n. 13
0
def _do_delete_songs(parent, songs, librarian):
    dialog = DeleteDialog.for_songs(parent, songs)
    resp = dialog.run()
    if resp != DeleteDialog.RESPONSE_DELETE:
        return

    window_title = _("Deleting %(current)d/%(total)d.")

    w = WaitLoadWindow(parent, len(songs), window_title)
    w.show()

    ok = []
    failed = []
    for song in songs:
        filename = song("~filename")
        try:
            os.unlink(filename)
        except EnvironmentError:
            failed.append(song)
        else:
            ok.append(song)
        w.step()
    w.destroy()

    if failed:
        ErrorMessage(parent,
            _("Unable to delete files"),
            _("Deleting one or more files failed.")
        ).run()

    if ok:
        librarian.remove(ok)
Esempio n. 14
0
def __create_playlist(name, source_dir, files, library):
    playlist = FileBackedPlaylist.new(PLAYLISTS, name, library=library)
    print_d("Created playlist %s" % playlist)
    songs = []
    win = WaitLoadWindow(
        None, len(files),
        _("Importing playlist.\n\n%(current)d/%(total)d songs added."))
    win.show()
    for i, filename in enumerate(files):
        if not uri_is_valid(filename):
            # Plain filename.
            songs.append(_af_for(filename, library, source_dir))
        else:
            try:
                filename = uri2fsn(filename)
            except ValueError:
                # Who knows! Hand it off to GStreamer.
                songs.append(formats.remote.RemoteFile(filename))
            else:
                # URI-encoded local filename.
                songs.append(_af_for(filename, library, source_dir))
        if win.step():
            break
    win.destroy()
    playlist.extend(list(filter(None, songs)))
    return playlist
Esempio n. 15
0
def _do_delete_files(parent, paths):
    dialog = DeleteDialog.for_files(parent, paths)
    resp = dialog.run()
    if resp != DeleteDialog.RESPONSE_DELETE:
        return

    window_title = _("Deleting %(current)d/%(total)d.")

    w = WaitLoadWindow(parent, len(paths), window_title)
    w.show()

    ok = []
    failed = []
    for path in paths:
        try:
            os.unlink(path)
        except EnvironmentError:
            failed.append(path)
        else:
            ok.append(path)
        w.step()
    w.destroy()

    if failed:
        ErrorMessage(parent,
            _("Unable to delete files"),
            _("Deleting one or more files failed.")
        ).run()
Esempio n. 16
0
def _do_trash_songs(parent, songs, librarian):
    dialog = TrashDialog.for_songs(parent, songs)
    resp = dialog.run()
    if resp != TrashDialog.RESPONSE_TRASH:
        return

    window_title = _("Moving %(current)d/%(total)d.")

    w = WaitLoadWindow(parent, len(songs), window_title)
    w.show()

    ok = []
    failed = []
    for song in songs:
        filename = song("~filename")
        try:
            trash.trash(filename)
        except trash.TrashError:
            failed.append(song)
        else:
            ok.append(song)
        w.step()
    w.destroy()

    if failed:
        ErrorMessage(parent,
            _("Unable to move to trash"),
            _("Moving one or more files to the trash failed.")
        ).run()

    if ok:
        librarian.remove(ok)
Esempio n. 17
0
def _do_trash_files(parent, paths):
    dialog = TrashDialog.for_files(parent, paths)
    resp = dialog.run()
    if resp != TrashDialog.RESPONSE_TRASH:
        return

    window_title = _("Moving %(current)d/%(total)d.")
    w = WaitLoadWindow(parent, len(paths), window_title)
    w.show()

    ok = []
    failed = []
    for path in paths:
        try:
            trash.trash(path)
        except trash.TrashError:
            failed.append(path)
        else:
            ok.append(path)
        w.step()
    w.destroy()

    if failed:
        ErrorMessage(parent,
            _("Unable to move to trash"),
            _("Moving one or more files to the trash failed.")
        ).run()
Esempio n. 18
0
    def run(self):
        resp = super(DeleteDialog, self).run()
        if self.__askonly:
            self.destroy()
            return resp

        if resp == 1 or resp == gtk.RESPONSE_DELETE_EVENT: return []
        elif resp == 0: s = _("Moving %(current)d/%(total)d.")
        elif resp == 2: s = _("Deleting %(current)d/%(total)d.")
        else: return []
        files = self.__files
        w = WaitLoadWindow(self, len(files), s)
        removed = []

        if resp == 0:
            for filename in files:
                try:
                    trash.trash(filename)
                except trash.TrashError:
                    fn = util.escape(util.fsdecode(util.unexpand(filename)))
                    ErrorMessage(self, _("Unable to move to trash"),
                        (_("Moving <b>%s</b> to the trash failed.") %
                        fn)).run()
                    break
                removed.append(filename)
                w.step()
        else:
            for filename in files:
                try:
                    os.unlink(filename)
                except EnvironmentError, s:
                    try: s = unicode(s.strerror, const.ENCODING, 'replace')
                    except TypeError:
                        s = unicode(s.strerror[1], const.ENCODING, 'replace')
                    s = "\n\n" + s
                    fn = util.escape(util.fsdecode(util.unexpand(filename)))
                    ErrorMessage(
                        self, _("Unable to delete file"),
                        (_("Deleting <b>%s</b> failed.") % fn) + s).run()
                    break
                removed.append(filename)
                w.step()
Esempio n. 19
0
	def plugin_songs(self, songs):

		if (songs is None) or (len(songs) <= 0):
			return True

		self.shuffle = False
		if (len(songs) > 1) and not ConfirmAction(self.plugin_window,
			_(self.PLUGIN_NAME),
			_("Open {!s} files in dacapo?").format(len(songs)),
			parent=self
		).run():
			return True

		win = WaitLoadWindow(
			self.plugin_window, len(songs),
			_("Checking...\n\n%(current)d/%(total)d Songs done."))
		args = []
		if self.shuffle:
			args.append("-s")
		if (len(songs) > 1):
			args.append("-pl")
			f = tempfile.NamedTemporaryFile(delete=False)
			for song in songs:
				if song.get("~filename", "").endswith(".flac"):
					f.writelines(song.get("~filename", "")+"\n")
			f.close()
			args.append(f.name)
		else:
			for song in songs:
				if song.get("~filename", "").endswith(".flac"):
					args.append(song.get("~filename", ""))

		try:
			program = 'dacapo'
			print program,args
			subprocess.call([program]+args)
		except:
			win.destroy()
			self.printError()
			return False
		win.destroy()
Esempio n. 20
0
	def plugin_songs(self, songs):

		if (songs is None) or (len(songs) <= 0):
			return True

		if not ConfirmAction(self.plugin_window,
			_(self.PLUGIN_NAME),
			_("Check {!s} files?").format(len(songs))
								  ).run():
			return True

		win = WaitLoadWindow(
			self.plugin_window, len(songs),
			_("Counting pictures.\n\n%(current)d/%(total)d Songs done."))
		for song in songs:
			if song.get("~filename", "").endswith(".flac"):
				flacFilePath = song.get("~filename", "")
				try:
					self.countImages(song)
				except:
					win.destroy()
					self.printError()
					return False
			if win.step():
				break
		win.destroy()
Esempio n. 21
0
def __create_playlist(name, source_dir, files, library):
    playlist = FileBackedPlaylist.new(PLAYLISTS, name, library=library)
    print_d("Created playlist %s" % playlist)
    songs = []
    win = WaitLoadWindow(
        None, len(files),
        _("Importing playlist.\n\n%(current)d/%(total)d songs added."))
    win.show()
    for i, filename in enumerate(files):
        if not uri_is_valid(filename):
            # Plain filename.
            songs.append(_af_for(filename, library, source_dir))
        else:
            try:
                filename = uri2fsn(filename)
            except ValueError:
                # Who knows! Hand it off to GStreamer.
                songs.append(formats.remote.RemoteFile(filename))
            else:
                # URI-encoded local filename.
                songs.append(_af_for(filename, library, source_dir))
        if win.step():
            break
    win.destroy()
    playlist.extend(list(filter(None, songs)))
    return playlist
Esempio n. 22
0
class TWaitLoadWindow(TestCase):

    class DummyConnector(Gtk.Window):
        count = 0

        def connect(self, *args):
            self.count += 1

        def disconnect(self, *args):
            self.count -= 1

        class Eater:
            def set_cursor(*args):
                pass

        window = Eater()

    def setUp(self):
        self.parent = self.DummyConnector()
        self.wlw = WaitLoadWindow(self.parent, 5, "a test")

    def test_none(self):
        wlw = WaitLoadWindow(None, 5, "a test")
        wlw.step()
        wlw.destroy()

    def test_connect(self):
        self.failUnlessEqual(2, self.parent.count)
        self.wlw.destroy()
        self.failUnlessEqual(0, self.parent.count)

    def test_start(self):
        self.failUnlessEqual(0, self.wlw.current)
        self.failUnlessEqual(5, self.wlw.count)

    def test_step(self):
        self.failIf(self.wlw.step())
        self.failUnlessEqual(1, self.wlw.current)
        self.failIf(self.wlw.step())
        self.failIf(self.wlw.step())
        self.failUnlessEqual(3, self.wlw.current)

    def test_destroy(self):
        self.wlw.destroy()
        self.failUnlessEqual(0, self.parent.count)

    def tearDown(self):
        self.wlw.destroy()
Esempio n. 23
0
class TWaitLoadWindow(TestCase):

    class DummyConnector(Gtk.Window):
        count = 0

        def connect(self, *args):
            self.count += 1

        def disconnect(self, *args):
            self.count -= 1

        class Eater:
            def set_cursor(*args):
                pass

        window = Eater()

    def setUp(self):
        self.parent = self.DummyConnector()
        self.wlw = WaitLoadWindow(self.parent, 5, "a test")

    def test_none(self):
        wlw = WaitLoadWindow(None, 5, "a test")
        wlw.step()
        wlw.destroy()

    def test_connect(self):
        self.failUnlessEqual(2, self.parent.count)
        self.wlw.destroy()
        self.failUnlessEqual(0, self.parent.count)

    def test_start(self):
        self.failUnlessEqual(0, self.wlw.current)
        self.failUnlessEqual(5, self.wlw.count)

    def test_step(self):
        self.failIf(self.wlw.step())
        self.failUnlessEqual(1, self.wlw.current)
        self.failIf(self.wlw.step())
        self.failIf(self.wlw.step())
        self.failUnlessEqual(3, self.wlw.current)

    def test_destroy(self):
        self.wlw.destroy()
        self.failUnlessEqual(0, self.parent.count)

    def tearDown(self):
        self.wlw.destroy()
Esempio n. 24
0
    def plugin_songs(self, songs):
        if os.system("ifp typestring"):
            qltk.ErrorMessage(
                None, _("No iFP device found"),
                _("Unable to contact your iFP device. Check "
                  "that the device is powered on and plugged "
                  "in, and that you have ifp-line "
                  "(http://ifp-driver.sf.net) installed.")).run()
            return True
        self.__madedir = []

        w = WaitLoadWindow(
            None, len(songs), _("Uploading %(current)d/%(total)d"))
        w.show()

        for i, song in enumerate(songs):
            if self.__upload(song) or w.step():
                w.destroy()
                return True
        else:
            w.destroy()
Esempio n. 25
0
	def plugin_songs(self, songs):
		for song in songs:
			if song.get("~filename", "").endswith(".flac"):
				flacFilePath = os.path.dirname(os.path.abspath(song.get("~filename", "")));
				break

		choose = AddImageFileChooser(self.plugin_window, flacFilePath)
		files = choose.run()
		desc = choose.get_description()
		choose.destroy()

		if (files == None) or (len(files) <= 0):
			return True

		for file in files:
			contentType = mimetypes.guess_type(file) # get Mimetype
			mimeType = contentType[0]
			if (mimeType in self.JPG_MIMES) or (mimeType in self.PNG_MIMES):
				img = get_image_size(file)
				img.mime = mimeType
				img.type = choose.imgType
				if (len(desc) <= 0):
					img.desc = ntpath.basename(file)
				else:
					img.desc = desc
				self.imgFiles.append(img)

		if not ConfirmAction(self.plugin_window,
			_(self.PLUGIN_NAME),
			_("Add {!s} images as type \n\n<b>&gt;&gt; {!s} &lt;&lt;</b>\n\nto {!s} files?").format(
					len(files), choose.TYPE[choose.imgType], self.counter)
								  ).run():
			return True

		win = WaitLoadWindow(
			self.plugin_window, len(songs),
			_("Adding Image.\n\n%(current)d/%(total)d Songs done."))
		for song in songs:
			if song.get("~filename", "").endswith(".flac"):
				flacFilePath = song.get("~filename", "")
				try:
					self.setImage(song)
				except:
					win.destroy()
					printError()
					return False
			if win.step():
				break
		win.destroy()
Esempio n. 26
0
    def plugin_songs(self, songs):
        if os.system("ifp typestring"):
            qltk.ErrorMessage(
                None, _("No iFP device found"),
                _("Unable to contact your iFP device. Check "
                  "that the device is powered on and plugged "
                  "in, and that you have ifp-line "
                  "(http://ifp-driver.sf.net) installed.")).run()
            return True
        self.__madedir = []

        w = WaitLoadWindow(
            None, len(songs), _("Uploading %(current)d/%(total)d"))
        w.show()

        for i, song in enumerate(songs):
            if self.__upload(song) or w.step():
                w.destroy()
                return True
        else:
            w.destroy()
Esempio n. 27
0
def __create_playlist(name, source_dir, files, songs_lib, pl_lib):
    songs = []
    win = WaitLoadWindow(
        None, len(files),
        _("Importing playlist.\n\n%(current)d/%(total)d songs added."))
    win.show()
    for i, filename in enumerate(files):
        song = None
        if not uri_is_valid(filename):
            # Plain filename.
            song = _af_for(filename, songs_lib, source_dir)
        else:
            try:
                filename = uri2fsn(filename)
            except ValueError:
                # Who knows! Hand it off to GStreamer.
                song = formats.remote.RemoteFile(filename)
            else:
                # URI-encoded local filename.
                song = _af_for(filename, songs_lib, source_dir)

        # Only add existing (not None) files to the playlist.
        # Otherwise multiple errors are thrown when the files are accessed
        # to update the displayed track infos.
        if song is not None:
            songs.append(song)
        elif (os.path.exists(filename)
              or os.path.exists(os.path.join(source_dir, filename))):
            print_w("Can't add file to playlist:"
                    f" Unsupported file format. '{filename}'")
        else:
            print_w(
                f"Can't add file to playlist: File not found. '{filename}'")

        if win.step():
            break
    win.destroy()
    return pl_lib.create_from_songs(songs)
Esempio n. 28
0
def __create_playlist(name, source_dir, files, songs_lib, pl_lib):
    songs = []
    win = WaitLoadWindow(
        None, len(files),
        _("Importing playlist.\n\n%(current)d/%(total)d songs added."))
    win.show()
    for i, filename in enumerate(files):
        if not uri_is_valid(filename):
            # Plain filename.
            songs.append(_af_for(filename, songs_lib, source_dir))
        else:
            try:
                filename = uri2fsn(filename)
            except ValueError:
                # Who knows! Hand it off to GStreamer.
                songs.append(formats.remote.RemoteFile(filename))
            else:
                # URI-encoded local filename.
                songs.append(_af_for(filename, songs_lib, source_dir))
        if win.step():
            break
    win.destroy()
    return pl_lib.create_from_songs(songs)
Esempio n. 29
0
    def plugin_songs(self, songs):

        if (songs is None) or (len(songs) <= 0):
            return True

        if not ConfirmAction(self.plugin_window, _(self.PLUGIN_NAME),
                             _("Check {!s} files?").format(len(songs))).run():
            return True

        win = WaitLoadWindow(
            self.plugin_window, len(songs),
            _("Checking...\n\n%(current)d/%(total)d Songs done."))
        for song in songs:
            if song.get("~filename", "").endswith(".flac"):
                try:
                    self.setImage(song)
                except:
                    win.destroy()
                    self.printError()
                    return False
            if win.step():
                break
        win.destroy()
Esempio n. 30
0
def __parse_playlist(name, plfilename, files, library):
    playlist = FileBackedPlaylist.new(PLAYLISTS, name, library=library)
    songs = []
    win = WaitLoadWindow(
        None, len(files),
        _("Importing playlist.\n\n%(current)d/%(total)d songs added."))
    win.show()
    for i, filename in enumerate(files):
        if not uri_is_valid(filename):
            if os.name == "nt":
                filename = filename.decode("utf-8", "replace")
            # Plain filename.
            filename = os.path.realpath(os.path.join(
                os.path.dirname(plfilename), filename))
            if library and filename in library:
                songs.append(library[filename])
            else:
                songs.append(formats.MusicFile(filename))
        else:
            try:
                filename = uri_to_path(filename)
            except ValueError:
                # Who knows! Hand it off to GStreamer.
                songs.append(formats.remote.RemoteFile(filename))
            else:
                # URI-encoded local filename.
                filename = os.path.realpath(os.path.join(
                    os.path.dirname(plfilename), filename))
                if library and filename in library:
                    songs.append(library[filename])
                else:
                    songs.append(formats.MusicFile(filename))
        if win.step():
            break
    win.destroy()
    playlist.extend(filter(None, songs))
    return playlist
Esempio n. 31
0
	def plugin_songs(self, songs):

		choose = RemoveImageFileChooser(self.plugin_window, _(self.PLUGIN_NAME), _("Which image should be removed?"))
		if not choose.run():
			return True
		self.desc = choose.get_description()
		self.type = choose.get_type()
		choose.destroy()

		win = WaitLoadWindow(
			self.plugin_window, len(songs),
			_("Removing Image.\n\n%(current)d/%(total)d Songs done."))
		for song in songs:
			if song.get("~filename", "").endswith(".flac"):
				flacFilePath = song.get("~filename", "")
				try:
					self.removeImage(song)
				except:
					win.destroy()
					self.printError()
					return False
			if win.step():
				break
		win.destroy()
Esempio n. 32
0
 def test_none(self):
     wlw = WaitLoadWindow(None, 5, "a test")
     wlw.step()
     wlw.destroy()
Esempio n. 33
0
 def setUp(self):
     self.parent = self.DummyConnector()
     self.wlw = WaitLoadWindow(self.parent, 5, "a test")
Esempio n. 34
0
 def setUp(self):
     self.parent = self.DummyConnector()
     self.wlw = WaitLoadWindow(self.parent, 5, "a test")
Esempio n. 35
0
 def test_none(self):
     wlw = WaitLoadWindow(None, 5, "a test")
     wlw.step()
     wlw.destroy()