def reloadList(self, sel=None, home=False): if not fileExists(config.movielist.last_videodir.value): path = defaultMoviePath() config.movielist.last_videodir.value = path config.movielist.last_videodir.save() self.current_ref = eServiceReferenceTrash(path) self["freeDiskSpace"].path = path if sel is None: sel = self.getCurrent() self["list"].reload(self.current_ref) if config.AdvancedMovieSelection.wastelist_buildtype.value == "listAllMoviesMedia": title = _("Wastebasket: %s") % ("/media") else: title = _("Wastebasket: %s") % (config.movielist.last_videodir.value) self["location"].setText(title) if not (sel and self["list"].moveTo(sel)): if home: self["list"].moveToIndex(0) self["freeDiskSpace"].update() count = Trashcan.getTrashCount() cap = Trashcan.getTrashSize() if cap <= 999: wastebasket_info = (_("Trash count: %d") % (count)) + " / " + (_("Trash size: %d MB") % cap) else: format_string = _("Trash size:") + " %%.%sf GB" % (config.AdvancedMovieSelection.filesize_digits.value) wastebasket_info = _("Trash count:") + (" %d / " % (count)) + (format_string) % (cap / 1000.0) if count == 0: self["wastetxt"].setText(_("Wastebasket is empty!")) else: self["wastetxt"].setText(wastebasket_info)
def reloadList(self, sel=None, home=False): if not fileExists(config.movielist.last_videodir.value): path = defaultMoviePath() config.movielist.last_videodir.value = path config.movielist.last_videodir.save() self.current_ref = eServiceReferenceTrash(path) self["freeDiskSpace"].path = path if sel is None: sel = self.getCurrent() self["list"].reload(self.current_ref) if config.AdvancedMovieSelection.wastelist_buildtype.value == 'listAllMoviesMedia': title = _("Wastebasket: %s") % ("/media") else: title = _("Wastebasket: %s") % ( config.movielist.last_videodir.value) self["location"].setText(title) if not (sel and self["list"].moveTo(sel)): if home: self["list"].moveToIndex(0) self["freeDiskSpace"].update() count = Trashcan.getTrashCount() cap = Trashcan.getTrashSize() if cap <= 999: wastebasket_info = (_("Trash count: %d") % (count)) + ' / ' + (_("Trash size: %d MB") % cap) else: format_string = _("Trash size:") + " %%.%sf GB" % ( config.AdvancedMovieSelection.filesize_digits.value) wastebasket_info = _("Trash count:") + ( " %d / " % (count)) + (format_string) % (cap / 1000.0) if count == 0: self["wastetxt"].setText(_("Wastebasket is empty!")) else: self["wastetxt"].setText(wastebasket_info)
def autoDeleteAllMovies(self): from Source.Remote.Client import isAnyRecording remote_recordings = isAnyRecording() retryvalue = "%s minutes" % int( config.AdvancedMovieSelection.next_empty_check.value) if self.recTimer.isActive(): self.recTimer.stop() if remote_recordings: print "[AdvancedMovieSelection] Start automated deleting all movies but remote recordings activ, retry at", retryvalue self.recTimer.start( config.AdvancedMovieSelection.next_empty_check.value * 60000) return if not Screens.Standby.inStandby: print "[AdvancedMovieSelection] Start automated deleting all movies but box not in standby, retry in", retryvalue self.recTimer.start( config.AdvancedMovieSelection.next_empty_check.value * 60000) else: recordings = self.session.nav.getRecordings() next_rec_time = -1 if not recordings: next_rec_time = self.session.nav.RecordTimer.getNextRecordingTime( ) if config.movielist.last_videodir.value == "/hdd/movie/" and recordings or ( next_rec_time > 0 and (next_rec_time - time()) < 360): print "[AdvancedMovieSelection] Start automated deleting all movies but recordings activ, retry at", retryvalue self.recTimer.start( config.AdvancedMovieSelection.next_empty_check.value * 60000) else: if self.recTimer.isActive(): self.recTimer.stop() self.list = [] path = config.movielist.last_videodir.value if not fileExists(path): path = defaultMoviePath() config.movielist.last_videodir.value = path config.movielist.last_videodir.save() if config.AdvancedMovieSelection.wastelist_buildtype.value == 'listMovies': trash = Trashcan.listMovies(path) elif config.AdvancedMovieSelection.wastelist_buildtype.value == 'listAllMovies': trash = Trashcan.listAllMovies(path) else: trash = Trashcan.listAllMovies("/media") print "[AdvancedMovieSelection] Start automated deleting all movies in trash list" Trashcan.deleteAsynch(trash) config.AdvancedMovieSelection.last_auto_empty_wastebasket.value = int( time()) config.AdvancedMovieSelection.last_auto_empty_wastebasket.save( ) self.configChange()
def restoreAll(self): try: print "Start restoring all movies" for x in self.list.list[:]: service = x[0] self["list"].removeService(service) Trashcan.restore(service.getPath()) except Exception, e: print e self.session.open(MessageBox, _("Restore failed!"), MessageBox.TYPE_ERROR)
def deleteAll(self, confirmed): if not confirmed: return self["list"].hide() trash = [] for x in self.list.list: service = x[0] trash.append(service) Trashcan.deleteAsynch(trash) self.close()
def delete(self, confirmed): if not confirmed: return try: self["list"].removeService(self.service) Trashcan.delete(self.service.getPath()) except Exception, e: print e self.session.open(MessageBox, _("Delete failed!"), MessageBox.TYPE_ERROR) return
def restore(self): try: service = self.getCurrent() if not service: return self["list"].removeService(service) Trashcan.restore(service.getPath()) except Exception, e: print e self.session.open(MessageBox, _("Restore failed!"), MessageBox.TYPE_ERROR) return
def delete(self, confirmed): if not confirmed: return try: self["list"].removeService(self.service) Trashcan.delete(self.service.getPath()) except Exception as e: print(str(e)) self.session.open(MessageBox, _("Delete failed!"), MessageBox.TYPE_ERROR) return self.delayTimer.start(0, 1)
def load(self, root): self.list = [] if not root or Trashcan.isCurrentlyDeleting(): return if config.AdvancedMovieSelection.wastelist_buildtype.value == 'listMovies': trash = Trashcan.listMovies(root.getPath()) if config.AdvancedMovieSelection.wastelist_buildtype.value == 'listAllMovies': trash = Trashcan.listAllMovies(root.getPath()) if config.AdvancedMovieSelection.wastelist_buildtype.value == 'listAllMoviesMedia': trash = Trashcan.listAllMovies("/media") for service in trash: self.list.append((service, None, -1, -1))
def autoDeleteAllMovies(self): from Source.Remote.Client import isAnyRecording remote_recordings = isAnyRecording() retryvalue = "%s minutes" % int(config.AdvancedMovieSelection.next_empty_check.value) if self.recTimer.isActive(): self.recTimer.stop() if remote_recordings: print "[AdvancedMovieSelection] Start automated deleting all movies but remote recordings activ, retry at", retryvalue self.recTimer.start(config.AdvancedMovieSelection.next_empty_check.value * 60000) return if not Screens.Standby.inStandby: print "[AdvancedMovieSelection] Start automated deleting all movies but box not in standby, retry in", retryvalue self.recTimer.start(config.AdvancedMovieSelection.next_empty_check.value * 60000) else: recordings = self.session.nav.getRecordings() next_rec_time = -1 if not recordings: next_rec_time = self.session.nav.RecordTimer.getNextRecordingTime() if ( config.movielist.last_videodir.value == "/hdd/movie/" and recordings or (next_rec_time > 0 and (next_rec_time - time()) < 360) ): print "[AdvancedMovieSelection] Start automated deleting all movies but recordings activ, retry at", retryvalue self.recTimer.start(config.AdvancedMovieSelection.next_empty_check.value * 60000) else: if self.recTimer.isActive(): self.recTimer.stop() self.list = [] path = config.movielist.last_videodir.value if not fileExists(path): path = defaultMoviePath() config.movielist.last_videodir.value = path config.movielist.last_videodir.save() if config.AdvancedMovieSelection.wastelist_buildtype.value == "listMovies": trash = Trashcan.listMovies(path) elif config.AdvancedMovieSelection.wastelist_buildtype.value == "listAllMovies": trash = Trashcan.listAllMovies(path) else: trash = Trashcan.listAllMovies("/media") print "[AdvancedMovieSelection] Start automated deleting all movies in trash list" Trashcan.deleteAsynch(trash) config.AdvancedMovieSelection.last_auto_empty_wastebasket.value = int(time()) config.AdvancedMovieSelection.last_auto_empty_wastebasket.save() self.configChange()
def load(self, root): self.list = [] if not root or Trashcan.isCurrentlyDeleting(): return if config.AdvancedMovieSelection.wastelist_buildtype.value == "listMovies": trash = Trashcan.listMovies(root.getPath()) if config.AdvancedMovieSelection.wastelist_buildtype.value == "listAllMovies": trash = Trashcan.listAllMovies(root.getPath()) if config.AdvancedMovieSelection.wastelist_buildtype.value == "listAllMoviesMedia": trash = Trashcan.listAllMovies("/media") for service in trash: self.list.append((service, None, -1, -1))
def delete(self, service): from Source.Trashcan import Trashcan if config.AdvancedMovieSelection.use_wastebasket.value: Trashcan.trash(service.getPath()) else: Trashcan.delete(service.getPath())