Exemplo n.º 1
0
	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
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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))
Exemplo n.º 5
0
 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
Exemplo n.º 6
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
Exemplo n.º 7
0
 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
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
 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
Exemplo n.º 10
0
        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
Exemplo n.º 11
0
 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
Exemplo n.º 12
0
 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()
Exemplo n.º 13
0
 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)
Exemplo n.º 14
0
 def emptyTrashcanResponse(self, response):
     if response:
         FileManager.getInstance().purgeTrashcan(
             0, self.execFileManagerOpCallback)
Exemplo n.º 15
0
 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
Exemplo n.º 16
0
 def deleteCutList(self, path):
     logger.info("path: %s", path)
     data = ""
     FileManager.getInstance().update(path, cuts=data)
     deleteFile(path + ".cuts")
Exemplo n.º 17
0
 def getInstance():
     global file_manager_instance
     if file_manager_instance is None:
         file_manager_instance = FileManager()
     return file_manager_instance
Exemplo n.º 18
0
 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()
Exemplo n.º 19
0
 def reloadCacheResponse(self, response):
     if response:
         FileManager.getInstance().loadDatabase()
         self.session.open(FileManagerProgress, FILE_OP_LOAD)
Exemplo n.º 20
0
 def invalidateList(self):
     self.lock_list = FileManager.getInstance().getLockList()
     self.l.invalidate()
Exemplo n.º 21
0
 def onDialogHide(self):
     logger.info("self.return_path: %s", self.return_path)
     FileManager.getInstance().onDatabaseLoaded()
     FileManager.getInstance().onDatabaseChanged()
     self.pigWorkaround()
Exemplo n.º 22
0
	def cancel(self):
		logger.debug("...")
		self.request_cancel = True
		FileManager.getInstance().cancelJobs()