def __serviceStarted(self):
     logger.info("self.is_closing: %s", self.is_closing)
     if not self.service_started and not self.is_closing:
         self.service_started = True
         self.setAudioTrack()
         self.setSubtitleState(True)
         self.downloadCuesheet()
         if self.config_plugins_plugin.movie_ignore_first_marks.value:
             self.cut_list = removeFirstMarks(self.cut_list)
         if self.config_plugins_plugin.movie_resume_at_last_pos.value:
             self.resume_point = getCutListLast(self.cut_list)
             if self.resume_point > 0:
                 seconds = ptsToSeconds(self.resume_point)
                 logger.debug("resume_point: %s", seconds)
                 Notifications.AddNotificationWithCallback(
                     self.__serviceStartedCallback,
                     MessageBox,
                     _("Do you want to resume playback at position: %d:%02d:%02d?"
                       ) %
                     (seconds / 3600, seconds % 3600 / 60, seconds % 60),
                     timeout=10,
                     type=MessageBox.TYPE_YESNO,
                     default=False,
                 )
             else:
                 self.__serviceStartedCallback(False)
         else:
             self.__serviceStartedCallback(False)
Example #2
0
	def doActivityTimer(self):
		logger.debug("...")
		self.total_files, self.file_name, self.file_op, self.file_progress = self.checkJobs()
		self.msg = _("Remaining files") + ": %d" % self.total_files
		if self.request_cancel:
			self["key_red"].hide()
			self["key_blue"].hide()
			if self.total_files:
				self["key_green"].hide()
				self.status = _("Cancelling, please wait") + "..."
				self.activity_timer.start(self.activity_timer_delay, True)
			else:
				self["key_green"].show()
				self.op_msg = ""
				self.status = _("Cancelled") + "."
				self.request_cancel = False
				self.cancelled = True
		else:
			if self.total_files:
				self.status = _("Please wait") + " ..."
				self.op_msg = {FILE_OP_LOAD: _("Loading"), FILE_OP_DELETE: _("Deleting"), FILE_OP_MOVE: _("Moving"), FILE_OP_COPY: _("Copying")}[self.file_op]
				self.op_msg += ": " + self.file_name
				self.activity_timer.start(self.activity_timer_delay, True)
			else:
				self["key_red"].hide()
				self["key_blue"].hide()
				self["key_green"].show()
				self.op_msg = ""
				self.status = _("Done") + "."
				self.file_progress = 0
				self.op_msg = _("No file operation in process")
		self.updateProgress()
 def execPiconDownloadProgress(self):
     logger.debug("...")
     self.status = _("Initializing") + " ..."
     self.updateProgress()
     self.execution_list = self.picons
     self.total_files = len(self.execution_list)
     DelayTimer(10, self.nextFileOp)
Example #4
0
    def sortList(self, file_list, dir_list, sort_mode, sort_order):
        logger.debug("list_dirs_inline: %s",
                     config.plugins.moviecockpit.list_dirs_inline.value)
        dir_list.sort(key=lambda x: (x[FILE_IDX_NAME].lower()))

        if config.plugins.moviecockpit.list_dirs_inline.value and sort_mode == "alpha":
            file_list = file_list + dir_list
            dir_list = []

        if sort_mode == "date":
            if not sort_order:
                file_list.sort(
                    key=lambda x:
                    (x[FILE_IDX_EVENT_START_TIME], x[FILE_IDX_NAME].lower()),
                    reverse=True)
            else:
                file_list.sort(key=lambda x: (x[FILE_IDX_EVENT_START_TIME], x[
                    FILE_IDX_NAME].lower()))

        elif sort_mode == "alpha":
            if not sort_order:
                file_list.sort(key=lambda x: (x[FILE_IDX_NAME].lower(), -x[
                    FILE_IDX_EVENT_START_TIME]))
            else:
                file_list.sort(
                    key=lambda x:
                    (x[FILE_IDX_NAME].lower(), x[FILE_IDX_EVENT_START_TIME]),
                    reverse=True)

        if config.plugins.moviecockpit.list_dirs_inline.value and sort_mode == "date":
            alist = file_list + dir_list
        else:
            alist = dir_list + file_list
        return alist
Example #5
0
 def getHomeDir(self, plugin):
     home = ""
     mounted_bookmarks = self.getMountedBookmarks(plugin)
     if mounted_bookmarks:
         home = mounted_bookmarks[0]
     logger.debug("home: %s", home)
     return home
Example #6
0
 def stop(self):
     logger.debug("...")
     self.activity_timer.stop()
     self.pic_loading.instance.setPixmap(gPixmapPtr())
     if self.summaries:
         self.summaries[0]["background"].hide()
         self.summaries[0]["lcd_pic_loading"].hide()
Example #7
0
    def selectedTargetDir(self, file_op, selection_list, target_dir):
        logger.debug("file_op: %s, target_dir: %s", file_op, target_dir)
        if target_dir:
            if not MountCockpit.getInstance().getMountPoint(ID, target_dir):
                self.session.open(MessageBox,
                                  target_dir + " " + _("is not mounted"),
                                  MessageBox.TYPE_ERROR)
            else:
                active_recordings_list = []
                file_ops_list = []
                for path in selection_list:
                    if not path.endswith("trashcan") and not path.endswith(
                            ".."):
                        if not isRecording(path):
                            file_ops_list.append(
                                (file_op, path, os.path.normpath(target_dir)))
                        else:
                            active_recordings_list.append(path)
                self.execFileManagerOps(file_ops_list)

                if active_recordings_list:
                    file_names = self.createMovieList(active_recordings_list)
                    msg = _(
                        "Can't move recordings"
                    ) + "\n" + file_names if file_op == FILE_OP_MOVE else _(
                        "Can't copy recordings") + "\n" + file_names
                    self.session.open(MessageBox, msg, MessageBox.TYPE_INFO)
Example #8
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
Example #9
0
 def getMountPoint(self, plugin, path):
     mount_point = None
     bookmark = self.getBookmark(plugin, path)
     if bookmark in self.mounts_table:
         mount_point = self.mounts_table[bookmark]
     logger.debug("path: %s, mount_point: %s", path, mount_point)
     return mount_point
Example #10
0
 def stdoutPingData(self, data):
     logger.info("...")
     #logger.info("data: %s", data)
     lines = data.splitlines()
     ip = packets = None
     for line in lines:
         line = " ".join(line.split())
         words = line.split(" ")
         if not ip and "PING" in line:
             ip = words[1]
         elif "packets received" in line:
             packets = int(words[3])
         if ip is not None and packets is not None:
             for sharename in iAutoMount.mounts:
                 if iAutoMount.mounts[sharename]["ip"] == ip:
                     if packets == 0:
                         #logger.debug("%s (%s) is offline", sharename, ip)
                         if iAutoMount.mounts[sharename]["active"]:
                             iAutoMount.mounts[sharename]["active"] = False
                             self.shares_changed.append(sharename)
                     else:
                         #logger.debug("%s (%s) is online", sharename, ip)
                         if not iAutoMount.mounts[sharename]["active"]:
                             iAutoMount.mounts[sharename]["active"] = True
                             self.shares_changed.append(sharename)
             ip = packets = None
     for sharename in iAutoMount.mounts:
         logger.debug("sharename: %s, ip: %s, active: %s", sharename,
                      iAutoMount.mounts[sharename]["ip"],
                      iAutoMount.mounts[sharename]["active"])
Example #11
0
 def finishedPing(self, _ret_val=None):
     logger.debug("shares_changed: %s", self.shares_changed)
     if self.shares_changed:
         iAutoMount.apply(self.shares_changed, self.onMountsChange)
         iAutoMount.save()
     else:
         self.check4InitComplete()
Example #12
0
 def parsePiconSetList(self, picon_set_list):
     logger.info("...")
     logger.debug("last_picon_set: %s",
                  config.plugins.piconcockpit.last_picon_set.value)
     picon_list = []
     for picon_set in picon_set_list:
         if not picon_set.startswith('<meta'):
             info_list = picon_set.split(';')
             if len(info_list) >= 9:
                 dir_url = os.path.join(
                     config.plugins.piconcockpit.picon_server.value,
                     info_list[0])
                 pic_url = os.path.join(
                     config.plugins.piconcockpit.picon_server.value,
                     info_list[0], info_list[1])
                 date = info_list[2]
                 name = info_list[3]
                 satellite = info_list[4]
                 creator = info_list[5]
                 bit = (info_list[6].replace(' ', '').lower()).replace(
                     'bit', ' bit')
                 size = info_list[7].replace(' ', '').lower()
                 uploader = info_list[8]
                 identifier = str(uuid.uuid4())
                 signature = "%s | %s - %s | %s | %s | %s" % (
                     satellite, creator, name, size, bit, uploader)
                 name = signature + " | %s" % date
                 if config.plugins.piconcockpit.satellite.value in ["all", satellite] and\
                  config.plugins.piconcockpit.creator.value in ["all", creator] and\
                  config.plugins.piconcockpit.size.value in ["all", size] and\
                  config.plugins.piconcockpit.bit.value in ["all", bit]:
                     picon_list.append(
                         (name, dir_url, pic_url, identifier, signature))
     return picon_list
 def setTrashcanActions(self, csel, path):
     logger.debug("path: %s", path)
     if path and "trashcan" in path:
         self.color_buttons_matrix[0][KEY_YELLOW] = [
             _("Restore"), csel.restoreMovies
         ]
         self.color_buttons_matrix[0][KEY_BLUE] = [
             _("Home"),
             boundFunction(csel.changeDir,
                           MountCockpit.getInstance().getHomeDir(ID))
         ]
     else:
         self.color_buttons_matrix[0][KEY_YELLOW] = [
             _("Move"), csel.moveMovies
         ]
         if config.plugins.moviecockpit.trashcan_enable.value:
             self.color_buttons_matrix[0][KEY_BLUE] = [
                 _("Trashcan"), csel.openTrashcan
             ]
         else:
             self.color_buttons_matrix[0][KEY_BLUE] = [
                 _("Home"),
                 boundFunction(csel.changeDir,
                               MountCockpit.getInstance().getHomeDir(ID))
             ]
     self.setColorButtons()
Example #14
0
def initBookmarks():
    logger.info("...")
    bookmarks = []
    for video_dir in config.movielist.videodirs.value:
        bookmarks.append(os.path.normpath(video_dir))
    logger.debug("bookmarks: %s", bookmarks)
    return bookmarks
Example #15
0
    def _parse(self, tree, types, defaults):
        def setFromTag(parent, key, data, abool=False):
            elements = parent.findall(key)
            if elements:
                val = elements[0].text
                if abool:
                    val = val == "True"
                if val is not None:
                    data[key] = val

        keys = [
            "active", "hdd_replacement", "ip", "sharedir", "sharename",
            "options", "username", "password"
        ]
        bool_keys = ["active", "hdd_replacement"]
        for i, _item in enumerate(types):
            mounttype = types[i]
            for parent in tree.findall(mounttype):
                for mount in parent.findall("mount"):
                    data = deepcopy(defaults[i])
                    try:
                        for key in keys:
                            setFromTag(mount, key, data, key in bool_keys)
                        logger.debug("%s share %s", mounttype.upper(), data)
                        if data["active"]:
                            self._numActive += 1
                        #Workaround for nfs shares previously being saved without their leading /
                        if mounttype == "nfs" and not data[
                                "sharedir"].startswith("/"):
                            data["sharedir"] = "/%s" % data["sharedir"]
                        self._mounts[data["sharename"]] = data
                    except Exception as e:
                        logger.warning("Error reading %s share: %s",
                                       mounttype.upper(), e)
Example #16
0
 def keySaveNew(self):
     logger.debug("...")
     save_value = True
     for i, conf in enumerate(self.config_list):
         #logger.debug("i: %s, conf[0]: %s", i, conf[0])
         if conf[0] != self.section:
             if conf[1].isChanged():
                 #logger.debug("i: %s, conf[0]: %s isChanged", i, conf[0])
                 if conf[2]:
                     # execute value changed function
                     #logger.debug("execute value changed function")
                     if not conf[2](conf[1]):
                         logger.error("value function error: %s", conf[0])
                         save_value = False
                 # Check parent entries
                 for parent in conf[5]:
                     #logger.debug("parent: %s, conf[5]: %s", str(parent), str(conf[5]))
                     if self.config_list[i + parent][2]:
                         # execute parent value changed function
                         #logger.debug("execute parent value changed function")
                         if not self.config_list[i + parent][2](
                                 self.config_list[i + parent][1]):
                             logger.error("parent value function error: %s",
                                          self.config_list[i + parent][2])
                 if save_value:
                     logger.debug("saving: %s", conf[0])
                     conf[1].save()
     configfile.save()
     if not save_value:
         self.createConfig()
     else:
         if self.needs_restart:
             self.restartGUI()
         else:
             self.close(True)
Example #17
0
    def applySkin(self, desktop, parent):
        attribs = []
        value_attributes = []
        size_attributes = []
        font_attributes = []
        color_attributes = []

        if self.skinAttributes:
            for (attrib, value) in self.skinAttributes:
                if attrib in value_attributes:
                    setattr(self, attrib, int(value))
                elif attrib in size_attributes:
                    setattr(self, attrib, parseSize(value, ((1, 1), (1, 1))))
                elif attrib in font_attributes:
                    setattr(self, attrib, parseFont(value, ((1, 1), (1, 1))))
                elif attrib in color_attributes:
                    setattr(self, attrib, parseColor(value).argb())
                else:
                    attribs.append((attrib, value))
        self.skinAttributes = attribs

        self.list_styles, template_attributes = parseTemplate(
            MovieList.default_template)
        self.setListStyle(config.plugins.moviecockpit.list_style.value)

        logger.debug("self.skinAttributes: %s", str(self.skinAttributes))
        GUIComponent.applySkin(self, desktop, parent)

        template_attributes["width"] = self.l.getItemSize().width() - 15
        self.applyTemplate(additional_locals=template_attributes)
Example #18
0
 def unselectPath(self, path):
     logger.debug("path: %s", path)
     if path in self.selection_list:
         self.selection_list.remove(path)
         index = self.getFileIndex(path)
         if index > -1:
             self.invalidateEntry(index)
Example #19
0
 def selectionChanged(self):
     logger.debug("...")
     if self.page == PAGE_SELECTION:
         self.getInfoAndCoverForCurrentSelection(TEMP_INFO_PATH,
                                                 TEMP_COVER_PATH,
                                                 TEMP_BACKDROP_PATH)
         self.switchPage()
Example #20
0
        def parseHeader(data, pos):
            e = struct.unpack(">HHBBBBBBH", data[pos:pos + 12])
            self.eit["event_id"] = e[0]
            y, mo, d = parseMJD(e[1])  # Y, M, D
            h, mi, s = unBCD(e[2]), unBCD(e[3]), unBCD(e[4])  # HH, MM, SS
            try:
                dt = datetime.datetime(y, mo, d, h, mi, s)
                logger.debug("dt: %s", str(dt))
                start_seconds = int(time.mktime(dt.timetuple()))
                self.eit[
                    "start"] = start_seconds - time.timezone + time.localtime(
                        start_seconds).tm_isdst * 3600  # daylight savings time
            except Exception as e:
                logger.error("exception: %s", e)
                self.eit["start"] = 0

            self.eit["length"] = unBCD(e[5]) * 3600 + unBCD(e[6]) * 60 + unBCD(
                e[7])

            #free_CA_mode = e[8] & 0x1000
            #descriptors_loop_length = e[8] & 0x0fff

            running_status = (e[8] & 0xe000) >> 13
            if running_status in [1, 2]:
                self.eit['when'] = "NEXT"
            elif running_status in [3, 4]:
                self.eit['when'] = "NOW"
Example #21
0
 def getPiconSetInfo(self):
     logger.info("...")
     url = os.path.join(config.plugins.piconcockpit.picon_server.value,
                        "picons", picon_info_file)
     download_file = os.path.join(self.picon_dir, picon_info_file)
     logger.debug("url: %s, download_file: %s", url, download_file)
     downloadPage(url, download_file).addCallback(
         self.gotPiconSetInfo).addErrback(self.downloadError, url)
Example #22
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
Example #23
0
 def selectPath(self, path):
     logger.debug("path: %s", path)
     if path and not path.endswith(
             "..") and path not in self.selection_list:
         self.selection_list.append(path)
         index = self.getFileIndex(path)
         if index > -1:
             self.invalidateEntry(index)
Example #24
0
 def completionStatus(self):
     covers_percent = 0 if self.covers_tried == 0 else float(
         float(self.covers_found) / float(self.covers_tried)) * 100
     logger.debug("%s of %s new covers: %.2f%%", self.covers_found,
                  self.covers_tried, covers_percent)
     return (_("Done") + " : %s " + _("of") + " %s " + _("new covers") +
             " (%.2f%%)") % (self.covers_found, self.covers_tried,
                             covers_percent)
Example #25
0
 def apply(self, shares_changed, callback=None):
     logger.info("shares_changed: %s", shares_changed)
     for sharename in shares_changed:
         self._applyShare(self._mounts[sharename])
     self._reloadSystemd(callback=self._onSharesApplied)
     logger.debug("self._mounts: %s", self._mounts)
     if callback is not None:
         callback(True)
Example #26
0
 def doActivityTimer(self):
     path = getSkinPath("images/spinner/wait%s.png" % (self.pic_index + 1))
     logger.debug("pic_index: %s", self.pic_index)
     pixmap = LoadPixmap(path, cached=False)
     self.pic_loading.instance.setPixmap(pixmap)
     if self.summaries:
         self.summaries[0]["lcd_pic_loading"].instance.setPixmap(pixmap)
     self.pic_index = (self.pic_index + 1) % self.pics
Example #27
0
 def updateCutList(self, path, last=None, length=None):
     logger.debug("path: %s, last: %s, length: %s", path, last, length)
     cut_list = self.readCutList(path)
     if last is not None:
         cut_list = replaceLast(cut_list, last)
     if length is not None:
         cut_list = replaceLength(cut_list, length)
     self.writeCutList(path, cut_list)
Example #28
0
 def selectionChanged(self):
     afile = self.movie_list.getCurrentSelection()
     if afile:
         self.return_path = afile[FILE_IDX_PATH]
         self.return_dir = afile[FILE_IDX_DIR]
     logger.debug("self.return_dir: %s, self.return_path: %s",
                  self.return_dir, self.return_path)
     self.updateInfo()
Example #29
0
 def getInfoString(self, _service=None, info_type=None):
     logger.debug("info_type: %s", info_type)
     if info_type == iServiceInformation.sServiceref:
         return self.info and self.info.getServiceReference()
     if info_type == iServiceInformation.sDescription:
         return self.info and self.info.getShortDescription()
     if info_type == iServiceInformation.sTags:
         return self.info and self.info.getTags()
     return "None"
Example #30
0
 def getMountedBookmarks(self, plugin):
     mounted_bookmarks = []
     if plugin in self.bookmarks:
         for bookmark in self.bookmarks[plugin]:
             if self.getMountPoint(plugin, bookmark):
                 mounted_bookmarks.append(bookmark)
     logger.debug("plugin: %s, mounted_bookmarks: %s", plugin,
                  mounted_bookmarks)
     return mounted_bookmarks