Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 245637d

Browse files
AA-Turnerhugovk
andauthoredSep 23, 2024··
Apply suggestions from code review
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 1649490 commit 245637d

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed
 

‎check_times.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
"""Check the frequency of the rebuild loop.
22
3-
This must be run in a directory that has the ``docsbuild.log.*`` files.
3+
This must be run in a directory that has the ``docsbuild.log*`` files.
44
For example:
55
66
.. code-block:: bash
77
8-
$ cd docsbuild-logs
9-
$ scp "adam@docs.nyc1.psf.io:/var/log/docsbuild/docsbuild.log*" .
10-
$ python ../check_times.py
8+
$ scp "adam@docs.nyc1.psf.io:/var/log/docsbuild/docsbuild.log*" docsbuild-logs
9+
$ python check_times.py
1110
"""
1211

1312
import datetime as dt
1413
import gzip
1514
from pathlib import Path
1615

16+
from build_docs import format_seconds
1717

1818
def get_lines() -> list[str]:
1919
lines = []
@@ -31,7 +31,7 @@ def calc_time(lines: list[str]) -> None:
3131
start = end = language = version = start_timestamp = None
3232
reason = lang_ver = ''
3333

34-
print("Start | Version | Language | Build | Reason")
34+
print("Start | Version | Language | Build | Trigger")
3535
print(":-- | :--: | :--: | --: | :--:")
3636

3737
for line in lines:
@@ -52,7 +52,7 @@ def calc_time(lines: list[str]) -> None:
5252
timestamp = line[:23].replace(",", ".")
5353
language, version = line.split(" ")[3].removesuffix(":").split("/")
5454
start = dt.datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S.%f")
55-
start_timestamp = f"{line[:16]} GMT"
55+
start_timestamp = f"{line[:16]} UTC"
5656

5757
if start and ": Build done " in line:
5858
timestamp = line[:23].replace(",", ".")
@@ -68,22 +68,14 @@ def calc_time(lines: list[str]) -> None:
6868
start = end = start_timestamp = None
6969

7070
if ': Full build done' in line:
71-
timestamp = f"{line[:16]} GMT"
71+
timestamp = f"{line[:16]} UTC"
7272
_, fmt_duration = line.removesuffix(").").split("(")
7373
print(f"{timestamp: <20} | --FULL- | -BUILD-- | {fmt_duration :<14} | -----------")
7474

7575
if start and end is None:
7676
print(f"{start_timestamp: <20} | {version: <7} | {language: <8} | In progress... | {reason}")
7777

7878

79-
def format_seconds(seconds: float) -> str:
80-
hours, minutes = divmod(seconds, 3600)
81-
minutes, _ = divmod(minutes, 60)
82-
hours, minutes = int(hours), int(minutes)
83-
if hours == 0:
84-
return f"{minutes}m"
85-
return f"{hours}h {minutes}m"
86-
8779

8880
if __name__ == "__main__":
8981
calc_time(get_lines())

0 commit comments

Comments
 (0)
Please sign in to comment.