def close_archive_screen(self): if not config.plugins.archivCZSK.preload.getValue(): self.__addons.clear() self.__repositories.clear() ArchivCZSK.__loaded = False self.__console = None # We dont need worker thread anymore so we stop it Task.stopWorkerThread() # finally save all cfg changes - edit by shamman configfile.save() # clear tmp content by shamman filelist = [ f for f in os.listdir("/tmp") if f.endswith(".url") ] for f in filelist: try: os.remove(os.path.join('/tmp', f)) except OSError: continue filelist = [ f for f in os.listdir("/tmp") if f.endswith(".png") ] for f in filelist: try: os.remove(os.path.join('/tmp', f)) except OSError: continue shutil.rmtree("/tmp/archivCZSK", True) if config.plugins.archivCZSK.clearMemory.getValue(): try: with open("/proc/sys/vm/drop_caches", "w") as f: f.write("1") except IOError as e: log.error('cannot drop caches : %s' % str(e))
def open_archive_screen(self, callback=None): if not ArchivCZSK.__loaded: self.load_repositories() # first screen to open when starting plugin, # so we start worker thread where we can run our tasks(ie. loading archives) Task.startWorkerThread() self.session.openWithCallback(self.close_archive_screen, ArchivCZSKContentScreen, self)
def toggleCancelLoading(self): if Task.getInstance() is not None and not Task.getInstance().isCancelling(): self["status_label"].setText("Canceling...") Task.getInstance().setCancel() elif Task.getInstance() is not None and Task.getInstance().isCancelling(): self["status_label"].setText("Loading...") Task.getInstance().setResume() else: log.debug("Task is not running")
def wrapped_func(*args, **kwargs): task = Task.getInstance() if task and task._aborted: raise AddonThreadException() func(*args, **kwargs)