def checkJobs(self): file_name = "" progress = 0 if self.file_op == FILE_OP_LOAD: jobs, file_name, file_op, progress = FileManager.getInstance().getProgress() else: jobs, file_name, file_op, progress = FileManager.getInstance().getJobsProgress() logger.debug("jobs: %d, file_name: %s, file_op: %d, progress: %d", jobs, file_name, file_op, progress) return jobs, file_name, file_op, progress
def getDirSelectionList(self, adir): logger.info("adir: %s", adir) file_list = FileManager.getInstance().getFileList([adir]) for afile in file_list: self.selection_list.append(afile[FILE_IDX_PATH]) dir_list = FileManager.getInstance().getDirList([adir]) for adirfile in dir_list: if adirfile[FILE_IDX_FILENAME] != "..": self.getDirSelection(adirfile[FILE_IDX_PATH]) logger.debug("selection_list: %s", self.selection_list)
def archiveFiles(self): archive_source_dir = config.plugins.cachecockpit.archive_source_dir.value archive_target_dir = config.plugins.cachecockpit.archive_target_dir.value logger.debug("archive_source_dir: %s, archive_target_dir: %s", archive_source_dir, archive_target_dir) if os.path.exists(archive_source_dir) and os.path.exists( archive_target_dir): FileManager.getInstance().archive(self.execFileManagerOpCallback) self.showFileManagerProgress() else: self.session.open( MessageBox, _("Archive source and/or target directory does not exist, please configure directories in setup." ), MessageBox.TYPE_INFO)
def onDialogShow(self): logger.info("self.return_path: %s", self.return_path) logger.debug("self[\"mini_tv\"].instance: %s", self["mini_tv"].instance.size().width()) self.enable_mini_tv = self["mini_tv"].instance.size().width() > -1 self.last_service = self.session.nav.getCurrentlyPlayingServiceReference( ) logger.info( "self.last_service: %s", self.last_service.toString() if self.last_service else None) self.loading.start() FileManager.getInstance().onDatabaseLoaded(self.loadList) FileManager.getInstance().onDatabaseChanged( boundFunction(self.movie_list.loadList, self.return_dir, self.return_path))
def __init__(self, service): self.path = service.getPath() logger.debug("path: %s", self.path) self.file_type, self.name, self.short_description, self.extended_description, self.service_reference, self.cuts, self.tags = "", "", "", "", "", "", "" self.size = self.length = self.event_start_time = self.recording_start_time = 0 if self.path: afile = FileManager.getInstance().getFile("recordings", self.path) if afile: self.file_type = afile[FILE_IDX_TYPE] self.event_start_time = afile[FILE_IDX_EVENT_START_TIME] self.recording_start_time = afile[ FILE_IDX_RECORDING_START_TIME] self.name = afile[FILE_IDX_NAME] if afile[ FILE_IDX_NAME] != "trashcan" else _("trashcan") self.short_description = afile[FILE_IDX_DESCRIPTION] self.extended_description = afile[ FILE_IDX_EXTENDED_DESCRIPTION] self.length = afile[FILE_IDX_LENGTH] if afile[ FILE_IDX_TYPE] == FILE_TYPE_FILE else None self.service_reference = afile[FILE_IDX_SERVICE_REFERENCE] self.size = afile[FILE_IDX_SIZE] self.tags = afile[FILE_IDX_TAGS] self.cut_list = unpackCutList(afile[FILE_IDX_CUTS]) else: info = eServiceCenter.getInstance().info(service) self.length = info.getLength( service) if self.length < 86400 else 0 if os.path.isfile(self.path): self.event_start_time = self.recording_start_time = int( os.stat(self.path).st_ctime) else: self.event_start_time = self.recording_start_time = 0
def getSize(self): logger.debug("...") size = 0 if self.file_type == FILE_TYPE_FILE: size = self.size elif os.path.basename(self.path) != "..": _count, size = FileManager.getInstance().getCountSize(self.path) return size
def readCutList(self, path): cut_list = [] afile = FileManager.getInstance().getFile("recordings", path) if afile: data = afile[FILE_IDX_CUTS] cut_list = unpackCutList(data) logger.info("cut_list: %s", cut_list) return cut_list
def loadList(self, load_dir=None, selection_path=None): logger.info("load_dir: %s, selection_path: %s", load_dir, selection_path) if load_dir is None: load_dir = self.getCurrentDir() if selection_path is None: selection_path = self.getCurrentPath() logger.info("load_dir: %s, selection_path: %s", load_dir, selection_path) self.lock_list = FileManager.getInstance().getLockList() self.selection_list = [] header_list = [] file_list = [] dir_list = [] if load_dir in MountCockpit.getInstance().getMountedBookmarks(ID): if config.plugins.moviecockpit.trashcan_enable.value and config.plugins.moviecockpit.trashcan_show.value: trashcan_dir = os.path.join(load_dir, "trashcan") trashcan = FileManager.getInstance().newDirData(trashcan_dir) header_list.append(trashcan) else: up_dir = os.path.join(load_dir, "..") up = FileManager.getInstance().newDirData(up_dir) header_list.append(up) all_load_dirs = MountCockpit.getInstance().getVirtualDirs( ID, [load_dir]) if config.plugins.moviecockpit.directories_show.value: dir_list = FileManager.getInstance().getDirList(all_load_dirs) file_list = FileManager.getInstance().getFileList(all_load_dirs) sort_mode, sort_order = sort_modes[self.current_sort_mode][0] self.file_list = header_list + self.sortList(file_list, dir_list, sort_mode, sort_order) self.file_list_index = {} for index, afile in enumerate(self.file_list): if afile: self.file_list_index[afile[FILE_IDX_PATH]] = index self.l.setList(self.file_list) logger.debug("moveToPath: %s", selection_path) self.moveToPath(selection_path)
def getDateText(path, file_type, date): logger.debug("path: %s, file_type: %s, date: %s", path, file_type, date) count = 0 date_text = "" if path in self.lock_list: file_op = self.lock_list[path] if file_op == FILE_OP_COPY: date_text = _("COPYING") elif file_op == FILE_OP_MOVE: date_text = _("MOVING") elif file_op == FILE_OP_DELETE: date_text = _("DELETING") else: if file_type == FILE_TYPE_FILE: if config.plugins.moviecockpit.list_show_mount_points.value: words = path.split("/") if len(words) > 3 and words[1] == "media": date_text = words[2] else: date_text = datetime.fromtimestamp(date).strftime( config.plugins.moviecockpit.movie_date_format.value ) else: if os.path.basename(path) == "trashcan": info_value = config.plugins.moviecockpit.trashcan_info.value else: info_value = config.plugins.moviecockpit.directories_info.value if os.path.basename(path) == "..": date_text = _("up") else: if info_value == "D": if os.path.basename(path) == "trashcan": date_text = _("trashcan") else: date_text = _("directory") else: count, size = FileManager.getInstance( ).getCountSize(path) counttext = "%d" % count size /= (1024 * 1024 * 1024) # GB sizetext = "%.0f GB" % size if size >= 1024: sizetext = "%.1f TB" % (size / 1024) if info_value == "C": date_text = "(%s)" % counttext elif info_value == "S": date_text = "(%s)" % sizetext elif info_value == "CS": date_text = "(%s/%s)" % (counttext, sizetext) logger.debug("count: %s, date_text: %s", count, date_text) return date_text
def createMovieList(self, file_list): file_names = "" movies = len(file_list) for i, path in enumerate(file_list): if i >= 5 and movies > 5: # only show first 5 entries in file_list file_names += " ..." break file_name = FileManager.getInstance().getFile("recordings", path)[FILE_IDX_NAME] file_names += "\n" + file_name return file_names
def getCover(self, path): logger.info("path: %s", path) cover = "" path, ext = os.path.splitext(path) # strip cut number if path[-4] == "_" and path[-3:].isdigit(): path = path[:-4] path += ext afile = FileManager.getInstance().getFile("covers", path) if afile: cover = afile[COVER_IDX_COVER] if not cover and config.plugins.moviecockpit.cover_fallback.value: cover = readFile(getSkinPath("images/no_cover.png")) return cover
def selectedEntry(self): afile = self.movie_list.getCurrentSelection() if afile: path = afile[FILE_IDX_PATH] if path not in FileManager.getInstance().getLockList(): if afile[FILE_IDX_TYPE] != FILE_TYPE_FILE: self.changeDir(path) else: if os.path.exists(path): self.openPlayer(path) else: self.session.open( MessageBox, _("Video file does not exist") + "\n" + path, MessageBox.TYPE_ERROR, 10) else: self.showFileManagerProgress()
def reloadCutList(self, path): data = readFile(path + ".cuts") FileManager.getInstance().update(path, cuts=data) cut_list = unpackCutList(data) logger.info("path: %s, cut_list: %s", path, cut_list) return cut_list
def deleteCutList(self, path): logger.info("path: %s", path) data = "" FileManager.getInstance().update(path, cuts=data) deleteFile(path + ".cuts")
def reloadCacheResponse(self, response): if response: FileManager.getInstance().loadDatabase() self.session.open(FileManagerProgress, FILE_OP_LOAD)
def onDialogHide(self): logger.info("self.return_path: %s", self.return_path) FileManager.getInstance().onDatabaseLoaded() FileManager.getInstance().onDatabaseChanged() self.pigWorkaround()
def cancel(self): logger.debug("...") self.request_cancel = True FileManager.getInstance().cancelJobs()
def execFileManagerOps(self, file_ops_list): logger.info("file_ops_list: %s", file_ops_list) for file_op, path, target_dir in file_ops_list: FileManager.getInstance().execFileManagerOp( file_op, path, target_dir, self.execFileManagerOpCallback) self.movie_list.loadList()
def emptyTrashcanResponse(self, response): if response: FileManager.getInstance().purgeTrashcan( 0, self.execFileManagerOpCallback)
def writeCutList(self, path, cut_list): logger.info("path: %s, cut_list: %s", path, cut_list) data = packCutList(cut_list) writeFile(path + ".cuts", data) FileManager.getInstance().update(path, cuts=data)
def invalidateList(self): self.lock_list = FileManager.getInstance().getLockList() self.l.invalidate()