As per D555, switched from TAP to YAML
Details
Details
Diff Detail
Diff Detail
- Repository
- rDEPCK task-depcheck
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
| kparal | |
| tflink |
As per D555, switched from TAP to YAML
Ran Unit Tests
| Automatic diff as part of commit; lint not applicable. |
| Automatic diff as part of commit; unit tests not applicable. |
| Path | Packages | |||
|---|---|---|---|---|
| M | depcheck/squash_results.py (10 lines) |
| Commit | Tree | Parents | Author | Summary | Date |
|---|---|---|---|---|---|
| 6c2c61717309 | b71f6672b3a3 | c8eb4c3323e9 | Josef Skladanka | y u make empty artifacts? | Sep 16 2015, 12:52 PM |
| c8eb4c3323e9 | ab17f6a0e421 | d35b622543df | Josef Skladanka | typo | Sep 16 2015, 12:37 PM |
| d35b622543df | 2e84b56f5881 | 3d43edfa5421 | Josef Skladanka | Move from TAP to YAML in Depcheck (Show More…) | Sep 9 2015, 1:24 PM |
| Show First 20 Lines • Show All 105 Lines • ▼ Show 20 Line(s) | 75 | for update_alias, update in updates.items(): | |||
|---|---|---|---|---|---|
| 106 | 106 | | |||
| 107 | # set summary | 107 | # set summary | ||
| 108 | if update['request']: | 108 | if update['request']: | ||
| 109 | target = 'into %s %s' % (update['release']['name'], | 109 | target = 'into %s %s' % (update['release']['name'], | ||
| 110 | update['request']) | 110 | update['request']) | ||
| 111 | else: | 111 | else: | ||
| 112 | target = 'in %s %s' % (update['release']['name'], | 112 | target = 'in %s %s' % (update['release']['name'], | ||
| 113 | update['status']) | 113 | update['status']) | ||
| 114 | cd.summary = '%s %s' % (update_alias, target) | 114 | cd.note = '%s %s' % (update_alias, target) | ||
| 115 | 115 | | |||
| 116 | return updates_results | 116 | return updates_results | ||
| 117 | 117 | | |||
| 118 | 118 | | |||
| 119 | def squash_results(run_result, bodhi_client = None, koji_client = None): | 119 | def squash_results(run_result, bodhi_client = None, koji_client = None): | ||
| 120 | per_nvr = _squash_rpms_to_builds(run_result, koji_client) | 120 | per_nvr = _squash_rpms_to_builds(run_result, koji_client) | ||
| 121 | per_update = _squash_builds_to_updates(per_nvr, bodhi_client) | 121 | per_update = _squash_builds_to_updates(per_nvr, bodhi_client) | ||
| 122 | 122 | | |||
| 123 | return per_update | 123 | return per_update | ||
| 124 | 124 | | |||
| 125 | def format_output(run_result, arch, report_format="rpms", artifactsdir=None): | 125 | def format_output(run_result, arch, report_format="rpms", artifactsdir=None): | ||
| 126 | if not run_result: | 126 | if not run_result: | ||
| 127 | return check.export_TAP([]) | 127 | return check.export_YAML([]) | ||
| 128 | 128 | | |||
| 129 | if 'updates' or 'builds' in report_format: | 129 | if 'updates' or 'builds' in report_format: | ||
| 130 | results = [] | 130 | results = [] | ||
| 131 | 131 | | |||
| 132 | build_results = _squash_rpms_to_builds(run_result) | 132 | build_results = _squash_rpms_to_builds(run_result) | ||
| 133 | if 'builds' in report_format: | 133 | if 'builds' in report_format: | ||
| 134 | for name, status in build_results.iteritems(): | 134 | for name, status in build_results.iteritems(): | ||
| 135 | cd = check.CheckDetail(name, check.ReportType.KOJI_BUILD, status['result']) | 135 | cd = check.CheckDetail(name, check.ReportType.KOJI_BUILD, status['result']) | ||
| 136 | cd.output.extend(status['details']) | 136 | cd.output.extend(status['details']) | ||
| 137 | results.append(cd) | 137 | results.append(cd) | ||
| 138 | 138 | | |||
| 139 | if 'updates' in report_format: | 139 | if 'updates' in report_format: | ||
| 140 | update_results = _squash_builds_to_updates(build_results) | 140 | update_results = _squash_builds_to_updates(build_results) | ||
| 141 | results.extend(update_results) | 141 | results.extend(update_results) | ||
| 142 | 142 | | |||
| 143 | # remove the arch conversion to be consistent with cmdline arch | 143 | # remove the arch conversion to be consistent with cmdline arch | ||
| 144 | if arch == 'i686': | 144 | if arch == 'i686': | ||
| 145 | arch = 'i386' | 145 | arch = 'i386' | ||
| 146 | for result in results: | 146 | for result in results: | ||
| 147 | result.keyvals['arch'] = arch | 147 | result.keyvals['arch'] = arch | ||
| 148 | 148 | | |||
| 149 | store_artifacts(results, artifactsdir) | 149 | store_artifacts(results, artifactsdir) | ||
| 150 | output = check.export_TAP(results, checkname='depcheck') | 150 | output = check.export_YAML(results) | ||
| 151 | 151 | | |||
| 152 | else: | 152 | else: | ||
| 153 | output = json.dumps(run_result, indent=4, separators=(',', ': ')) | 153 | output = json.dumps(run_result, indent=4, separators=(',', ': ')) | ||
| 154 | 154 | | |||
| 155 | return output | 155 | return output | ||
| 156 | 156 | | |||
| 157 | def store_artifacts(results, artifactsdir=None): | 157 | def store_artifacts(results, artifactsdir=None): | ||
| 158 | '''Take a list of CheckDetails and save it as inidividual log files in | 158 | '''Take a list of CheckDetails and save it as inidividual log files in | ||
| Show All 25 Lines | 181 | if len(filename) > 255: # the max file name length for most Linux filesystems | |||
| 184 | extra_bits = 3 + 4 + len(result.keyvals['arch']) | 184 | extra_bits = 3 + 4 + len(result.keyvals['arch']) | ||
| 185 | item = item[:-exceed_len-extra_bits] + '...' | 185 | item = item[:-exceed_len-extra_bits] + '...' | ||
| 186 | # don't need . separating item and arch since item ends with ... now | 186 | # don't need . separating item and arch since item ends with ... now | ||
| 187 | filename = "%s%s.log" % (item, result.keyvals['arch']) | 187 | filename = "%s%s.log" % (item, result.keyvals['arch']) | ||
| 188 | assert len(filename) <= 255 | 188 | assert len(filename) <= 255 | ||
| 189 | 189 | | |||
| 190 | filepath = os.path.join(storedir, filename) | 190 | filepath = os.path.join(storedir, filename) | ||
| 191 | fout = open(filepath, 'w') | 191 | fout = open(filepath, 'w') | ||
| 192 | fout.write(check.export_TAP([result], checkname='depcheck')) | 192 | fout.write(check.export_YAML(result)) | ||
| 193 | fout.write('\n\n') | ||||
| 194 | fout.write('\n'.join(result.output)) | ||||
| 193 | fout.close() | 195 | fout.close() | ||
| 194 | result.artifact = filepath | 196 | result.artifact = filepath | ||
| 195 | 197 | | |||
| 196 | except OSError as e: | 198 | except OSError as e: | ||
| 197 | log.logger.error('Individual logs not saved into %s, an error occured. ' | 199 | log.logger.error('Individual logs not saved into %s, an error occured. ' | ||
| 198 | 'Raising.', artifactsdir) | 200 | 'Raising.', artifactsdir) | ||
| 199 | raise e | 201 | raise e | ||
| 200 | 202 | | |||