Ejemplo n.º 1
0
 def remove_tracks_callback(tracks):
     title = _('Delete podcasts from device?')
     message = _('Do you really want to remove these episodes from your device? Episodes in your library will not be deleted.')
     if tracks and self.show_confirmation(message, title):
         gPodderSyncProgress(self.parent_window, device=device)
         def cleanup_thread_func():
             device.remove_tracks(tracks)
             if not device.close():
                 title = _('Error closing device')
                 message = _('There has been an error closing your device.')
                 self.notification(message, title, important=True)
         threading.Thread(target=cleanup_thread_func).start()
Ejemplo n.º 2
0
            def remove_tracks_callback(tracks):
                title = _('Delete podcasts from device?')
                message = _(
                    'Do you really want to remove these episodes from your device? Episodes in your library will not be deleted.'
                )
                if tracks and self.show_confirmation(message, title):
                    gPodderSyncProgress(self.parent_window, device=device)

                    def cleanup_thread_func():
                        device.remove_tracks(tracks)
                        if not device.close():
                            title = _('Error closing device')
                            message = _(
                                'There has been an error closing your device.')
                            self.notification(message, title, important=True)

                    threading.Thread(target=cleanup_thread_func).start()
Ejemplo n.º 3
0
        def check_free_space():
            # "Will we add this episode to the device?"
            def will_add(episode):
                # If already on-device, it won't take up any space
                if device.episode_on_device(episode):
                    return False

                # Might not be synced if it's played already
                if not force_played and \
                        self._config.only_sync_not_played and \
                        episode.is_played:
                    return False

                # In all other cases, we expect the episode to be
                # synchronized to the device, so "answer" positive
                return True

            # "What is the file size of this episode?"
            def file_size(episode):
                filename = episode.local_filename(create=False)
                if filename is None:
                    return 0
                return util.calculate_size(str(filename))

            # Calculate total size of sync and free space on device
            total_size = sum(file_size(e) for e in episodes if will_add(e))
            free_space = max(device.get_free_space(), 0)

            if total_size > free_space:
                title = _('Not enough space left on device')
                message = _('You need to free up %s.\nDo you want to continue?') \
                                % (util.format_filesize(total_size-free_space),)
                if not self.show_confirmation(message, title):
                    device.cancel()
                    device.close()
                    return

            # Finally start the synchronization process
            gPodderSyncProgress(self.parent_window, device=device)

            def sync_thread_func():
                device.add_tracks(episodes, force_played=force_played)
                device.close()

            threading.Thread(target=sync_thread_func).start()
Ejemplo n.º 4
0
        def check_free_space():
            # "Will we add this episode to the device?"
            def will_add(episode):
                # If already on-device, it won't take up any space
                if device.episode_on_device(episode):
                    return False

                # Might not be synced if it's played already
                if not force_played and \
                        self._config.only_sync_not_played and \
                        episode.is_played:
                    return False

                # In all other cases, we expect the episode to be
                # synchronized to the device, so "answer" positive
                return True

            # "What is the file size of this episode?"
            def file_size(episode):
                filename = episode.local_filename(create=False)
                if filename is None:
                    return 0
                return util.calculate_size(str(filename))

            # Calculate total size of sync and free space on device
            total_size = sum(file_size(e) for e in episodes if will_add(e))
            free_space = max(device.get_free_space(), 0)

            if total_size > free_space:
                title = _('Not enough space left on device')
                message = _('You need to free up %s.\nDo you want to continue?') \
                                % (util.format_filesize(total_size-free_space),)
                if not self.show_confirmation(message, title):
                    device.cancel()
                    device.close()
                    return

            # Finally start the synchronization process
            gPodderSyncProgress(self.parent_window, device=device)
            def sync_thread_func():
                device.add_tracks(episodes, force_played=force_played)
                device.close()
            threading.Thread(target=sync_thread_func).start()