def read_target_info_cache(): if not os.path.exists(settings.cache_directory): os.makedirs(settings.cache_directory) if not os.path.isfile(settings.target_info_cache_file): return {} with lock_file(settings.target_info_cache_file): return read_pod(settings.target_info_cache_file)
def _update_cache(self): if not os.path.exists(self.path): return if self.last_modified != os.stat(self.path): apk_info_cache_logger.debug('Updating cache {}'.format(self.path)) self.cache = read_pod(self.path) self.last_modified = os.stat(self.path)
def reload(self): super(RunOutput, self).reload() self.info = RunInfo.from_pod(read_pod(self.infofile)) self.state = RunState.from_pod(read_pod(self.statefile)) if os.path.isfile(self.configfile): self._combined_config = CombinedConfig.from_pod(read_pod(self.configfile)) if os.path.isfile(self.targetfile): self.target_info = TargetInfo.from_pod(read_pod(self.targetfile)) if os.path.isfile(self.jobsfile): self.job_specs = self.read_job_specs() for job_state in self.state.jobs.values(): job_path = os.path.join(self.basepath, job_state.output_name) job = JobOutput(job_path, job_state.id, job_state.label, job_state.iteration, job_state.retries) job.status = job_state.status job.spec = self.get_job_spec(job.id) if job.spec is None: logger.warning('Could not find spec for job {}'.format(job.id)) self.jobs.append(job)
def reload(self): try: if os.path.isdir(self.basepath): pod = read_pod(self.resultfile) self.result = Result.from_pod(pod) else: self.result = Result() self.result.status = Status.PENDING except Exception as e: # pylint: disable=broad-except self.result = Result() self.result.status = Status.UNKNOWN self.add_event(str(e))
def _load_file(filepath, error_name): if not os.path.isfile(filepath): raise ValueError("{} does not exist".format(filepath)) try: raw = read_pod(filepath) includes = _process_includes(raw, filepath, error_name) except SerializerSyntaxError as e: raise ConfigError('Error parsing {} {}: {}'.format(error_name, filepath, e)) if not isinstance(raw, dict): message = '{} does not contain a valid {} structure; top level must be a dict.' raise ConfigError(message.format(filepath, error_name)) return raw, includes
def _load_file(filepath, error_name): if not os.path.isfile(filepath): raise ValueError("{} does not exist".format(filepath)) try: raw = read_pod(filepath) includes = _process_includes(raw, filepath, error_name) except SerializerSyntaxError as e: raise ConfigError('Error parsing {} {}: {}'.format( error_name, filepath, e)) if not isinstance(raw, dict): message = '{} does not contain a valid {} structure; top level must be a dict.' raise ConfigError(message.format(filepath, error_name)) return raw, includes
def read_job_specs(self): if not os.path.isfile(self.jobsfile): return None pod = read_pod(self.jobsfile) return [JobSpec.from_pod(jp) for jp in pod['jobs']]
def read_config(self): if not os.path.isfile(self.configfile): return None return CombinedConfig.from_pod(read_pod(self.configfile))
def read_target_info_cache(): if not os.path.exists(settings.cache_directory): os.makedirs(settings.cache_directory) if not os.path.isfile(settings.target_info_cache_file): return {} return read_pod(settings.target_info_cache_file)