def hasFile(self, path, comparepath=None): if media.isMounted(): filepath = self.joinPath(path) if (os.path.isfile(filepath) and not comparepath or compareFiles(path, comparepath)): return True return False
def hasFile(self, path, comparepath=None): if self.isMounted(): filepath = self.joinPath(path) if (os.path.isfile(filepath) and not comparepath or compareFiles(path, comparepath)): return True return False
def findFile(self, path, comparepath=None): if path.startswith("localmedia:"): path = path[11:] while path[:2] == "//": path = path[1:] for media in self._medias: if media.isMounted(): filepath = media.joinPath(path) if (os.path.isfile(filepath) and not comparepath or compareFiles(filepath, comparepath)): return media return None
def compute(self): self._available.clear() self._media.clear() fetcher = self._fetcher progress = self._progress mediaset = fetcher.getMediaSet() steps = 0 for channel in self._channels: steps += len(channel.getCacheCompareURLs()) progress.start() progress.set(0, steps * 2) for channel in self._channels: if not channel.isRemovable(): self._available[channel] = True progress.add(2) continue urls = channel.getCacheCompareURLs() if not urls: self._available[channel] = False progress.add(2) continue datadir = sysconf.get("data-dir") tmpdir = os.path.join(datadir, "tmp/") if not os.path.isdir(tmpdir): os.makedirs(tmpdir) channelsdir = os.path.join(datadir, "channels/") if not os.path.isdir(channelsdir): self._available[channel] = False progress.add(2) continue media = None available = False for url in urls: # Fetch cached item. fetcher.reset() fetcher.setLocalDir(channelsdir, mangle=True) fetcher.setCaching(ALWAYS) fetcher.setForceCopy(True) fetcher.setLocalPathPrefix(channel.getAlias() + "%%") channelsitem = fetcher.enqueue(url) fetcher.run("channels", progress=progress) fetcher.setForceCopy(False) fetcher.setLocalPathPrefix(None) if channelsitem.getStatus() is FAILED: progress.add(1) break if url.startswith("localmedia:/"): progress.add(1) channelspath = channelsitem.getTargetPath() media = mediaset.findFile(url, comparepath=channelspath) if not media: break else: # Fetch temporary item. fetcher.reset() fetcher.setLocalDir(tmpdir, mangle=True) fetcher.setCaching(NEVER) tmpitem = fetcher.enqueue(url) fetcher.run("tmp", progress=progress) if tmpitem.getStatus() is FAILED: break # Compare items. channelspath = channelsitem.getTargetPath() tmppath = tmpitem.getTargetPath() if not compareFiles(channelspath, tmppath): if tmppath.startswith(datadir): os.unlink(tmppath) break else: self._available[channel] = True if media: self._media[channel] = media progress.stop()
def compute(self): self._available.clear() self._media.clear() fetcher = self._fetcher progress = self._progress mediaset = fetcher.getMediaSet() steps = 0 for channel in self._channels: steps += len(channel.getCacheCompareURLs()) progress.start() progress.set(0, steps*2) for channel in self._channels: if not channel.isRemovable(): self._available[channel] = True progress.add(2) continue urls = channel.getCacheCompareURLs() if not urls: self._available[channel] = False progress.add(2) continue datadir = sysconf.get("data-dir") tmpdir = os.path.join(datadir, "tmp/") if not os.path.isdir(tmpdir): os.makedirs(tmpdir) channelsdir = os.path.join(datadir, "channels/") if not os.path.isdir(channelsdir): self._available[channel] = False progress.add(2) continue media = None available = False for url in urls: # Fetch cached item. fetcher.reset() fetcher.setLocalDir(channelsdir, mangle=True) fetcher.setCaching(ALWAYS) fetcher.setForceCopy(True) fetcher.setLocalPathPrefix(channel.getAlias()+"%%") channelsitem = fetcher.enqueue(url) fetcher.run("channels", progress=progress) fetcher.setForceCopy(False) fetcher.setLocalPathPrefix(None) if channelsitem.getStatus() is FAILED: progress.add(1) break if url.startswith("localmedia:/"): progress.add(1) channelspath = channelsitem.getTargetPath() media = mediaset.findFile(url, comparepath=channelspath) if not media: break else: # Fetch temporary item. fetcher.reset() fetcher.setLocalDir(tmpdir, mangle=True) fetcher.setCaching(NEVER) tmpitem = fetcher.enqueue(url) fetcher.run("tmp", progress=progress) if tmpitem.getStatus() is FAILED: break # Compare items. channelspath = channelsitem.getTargetPath() tmppath = tmpitem.getTargetPath() if not compareFiles(channelspath, tmppath): if tmppath.startswith(datadir): os.unlink(tmppath) break else: self._available[channel] = True if media: self._media[channel] = media progress.stop()