def writable(self): """ Check if self.location is writable, or permissions are sufficient to create it if it does not exist yet. @rtype: bool @return: True if self.location is writable or can be created, False otherwise """ return os.access(first_existing(self.location), os.W_OK)
def _prefetch_exit(self, prefetcher): if self._was_cancelled(): self.wait() return opts = self.opts pkg = self.pkg settings = self.settings if opts.fetchonly: if opts.pretend: fetcher = EbuildFetchonly(fetch_all=opts.fetch_all_uri, pkg=pkg, pretend=opts.pretend, settings=settings) retval = fetcher.execute() if retval == os.EX_OK: self._current_task = None self.returncode = os.EX_OK self._async_wait() else: # For pretend mode, the convention it to execute # pkg_nofetch and return a successful exitcode. self._start_task( SpawnNofetchWithoutBuilddir( background=self.background, portdb=self.pkg.root_config.trees[ self._tree].dbapi, ebuild_path=self._ebuild_path, scheduler=self.scheduler, settings=self.settings), self._default_final_exit) return quiet_setting = settings.get("PORTAGE_QUIET", False) fetch_log = None logwrite_access = False if quiet_setting: fetch_log = os.path.join(_emerge.emergelog._emerge_log_dir, "emerge-fetch.log") logwrite_access = os.access(first_existing(fetch_log), os.W_OK) fetcher = EbuildFetcher( config_pool=self.config_pool, ebuild_path=self._ebuild_path, fetchall=self.opts.fetch_all_uri, fetchonly=self.opts.fetchonly, background=quiet_setting if logwrite_access else False, logfile=fetch_log if logwrite_access else None, pkg=self.pkg, scheduler=self.scheduler, ) if fetch_log and logwrite_access: fetcher.addExitListener(self._fetchonly_exit) self._task_queued(fetcher) self.scheduler.fetch.schedule(fetcher, force_queue=True) else: self._start_task(fetcher, self._fetchonly_exit) return self._build_dir = EbuildBuildDir(scheduler=self.scheduler, settings=settings) self._start_task(AsyncTaskFuture(future=self._build_dir.async_lock()), self._start_pre_clean)