(results_path: str, query_params: dict)
| 347 | |
| 348 | |
| 349 | def staleReport(results_path: str, query_params: dict) -> str: |
| 350 | thresh_d = query_params.get('days') |
| 351 | if thresh_d is None: |
| 352 | thresh_d = 30 |
| 353 | else: |
| 354 | thresh_d = int(thresh_d) |
| 355 | |
| 356 | html = '<!DOCTYPE html>\n' |
| 357 | html += '<html><head><title>Stale report</title></head><body>\n' |
| 358 | html += '<h1>Stale report</h1>\n' |
| 359 | html += '<pre>\n' |
| 360 | html += '<b>' + fmt('Package', 'Date Time', link=False) + '</b>\n' |
| 361 | for filename in sorted(glob.glob(os.path.expanduser(results_path + '/*'))): |
| 362 | if filename.endswith('.diff') or not os.path.isfile(filename): |
| 363 | continue |
| 364 | with open(filename, 'rt') as f: |
| 365 | # first line is datetime string |
| 366 | datestr = f.readline().strip() |
| 367 | try: |
| 368 | dt = dateTimeFromStr(datestr) |
| 369 | diff = datetime.datetime.now() - dt |
| 370 | except: |
| 371 | # there might be very outdated files which still might have an invalid timestamp |
| 372 | diff = datetime.timedelta(days=thresh_d) |
| 373 | if diff.days >= thresh_d: |
| 374 | package = pkg_from_file(filename) |
| 375 | html += fmt(package, datestr) + '\n' |
| 376 | html += '</pre>\n' |
| 377 | |
| 378 | html += '</body></html>\n' |
| 379 | return html |
| 380 | |
| 381 | |
| 382 | def diffReportFromDict(out: dict, today: str) -> str: |
no test coverage detected