def write_diffs_to_file(io_dir, diffs, valid_saas_file_changes_only): required_keys = ['saas_file_name', 'environment'] diffs = [{k: v for k, v in diff.items() if k in required_keys} for diff in diffs] unique_diffs = [] for diff in diffs: if diff not in unique_diffs: unique_diffs.append(diff) file_path = get_diffs_file_path(io_dir) body = { 'valid_saas_file_changes_only': valid_saas_file_changes_only, 'items': unique_diffs } with open(file_path, 'w') as f: f.write(json.dumps(body)) throughput.change_files_ownership(io_dir)
def generate(self, io_dir, fetch_state): """ Generates job definitions from JJB configs :param io_dir: Input/output directory :param fetch_state: subdirectory to use ('desired' or 'current') """ for name, wd in self.working_dirs.items(): ini_path = '{}/{}.ini'.format(wd, name) config_path = '{}/config.yaml'.format(wd) output_dir = path.join(io_dir, 'jjb', fetch_state, name) args = ['--conf', ini_path, 'test', config_path, '-o', output_dir, '--config-xml'] self.execute(args) throughput.change_files_ownership(io_dir)
def write_baseline_to_file(io_dir, baseline): file_path = get_baseline_file_path(io_dir) with open(file_path, 'w') as f: f.write(json.dumps(baseline)) throughput.change_files_ownership(io_dir)