diff --git a/tools/donate-cpu-server.py b/tools/donate-cpu-server.py index 456f6c21f76..2e0ceb4918d 100755 --- a/tools/donate-cpu-server.py +++ b/tools/donate-cpu-server.py @@ -26,7 +26,7 @@ # Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/ # Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic # changes) -SERVER_VERSION = "1.3.52" +SERVER_VERSION = "1.3.53" OLD_VERSION = '2.14.0' @@ -76,6 +76,10 @@ def dateTimeFromStr(datestr: str) -> datetime.datetime: return datetime.datetime.strptime(datestr, '%Y-%m-%d %H:%M') +def pkg_from_file(filename: str) -> str: + return filename[filename.rfind('/')+1:] + + def overviewReport() -> str: html = '\n' html += '
\n' html += '' + fmt('Package', 'Date Time', link=False) + '\n' - current_year = datetime.date.today().year for filename in sorted(glob.glob(os.path.expanduser(results_path + '/*'))): - if not os.path.isfile(filename) or filename.endswith('.diff'): + if filename.endswith('.diff') or not os.path.isfile(filename): continue - for line in open(filename, 'rt'): - line = line.strip() - if line.startswith(str(current_year) + '-') or line.startswith(str(current_year - 1) + '-'): - datestr = line - else: - continue - dt = dateTimeFromStr(datestr) - diff = datetime.datetime.now() - dt - if diff.days < 30: - continue - package = filename[filename.rfind('/')+1:] - html += fmt(package, datestr) + '\n' - break + with open(filename, 'rt') as f: + # first line is datetime string + datestr = f.readline().strip() + try: + dt = dateTimeFromStr(datestr) + diff = datetime.datetime.now() - dt + except: + # there might be very outdated files which still might have an invalid timestamp + diff = datetime.timedelta(days=thresh_d) + if diff.days >= thresh_d: + package = pkg_from_file(filename) + html += fmt(package, datestr) + '\n' html += '\n' html += '\n' @@ -1121,7 +1129,7 @@ def run(self): html = timeoutReport(self.resultPath) httpGetResponse(self.connection, html, 'text/html') elif url == '/stale.html': - html = staleReport(self.resultPath) + html = staleReport(self.resultPath, queryParams) httpGetResponse(self.connection, html, 'text/html') elif url == '/diff.html': html = diffReport(self.resultPath)