1
1
"""Check the frequency of the rebuild loop.
2
2
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.
4
4
For example:
5
5
6
6
.. code-block:: bash
7
7
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
11
10
"""
12
11
13
12
import datetime as dt
14
13
import gzip
15
14
from pathlib import Path
16
15
16
+ from build_docs import format_seconds
17
17
18
18
def get_lines () -> list [str ]:
19
19
lines = []
@@ -31,7 +31,7 @@ def calc_time(lines: list[str]) -> None:
31
31
start = end = language = version = start_timestamp = None
32
32
reason = lang_ver = ''
33
33
34
- print ("Start | Version | Language | Build | Reason " )
34
+ print ("Start | Version | Language | Build | Trigger " )
35
35
print (":-- | :--: | :--: | --: | :--:" )
36
36
37
37
for line in lines :
@@ -52,7 +52,7 @@ def calc_time(lines: list[str]) -> None:
52
52
timestamp = line [:23 ].replace ("," , "." )
53
53
language , version = line .split (" " )[3 ].removesuffix (":" ).split ("/" )
54
54
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 "
56
56
57
57
if start and ": Build done " in line :
58
58
timestamp = line [:23 ].replace ("," , "." )
@@ -68,22 +68,14 @@ def calc_time(lines: list[str]) -> None:
68
68
start = end = start_timestamp = None
69
69
70
70
if ': Full build done' in line :
71
- timestamp = f"{ line [:16 ]} GMT "
71
+ timestamp = f"{ line [:16 ]} UTC "
72
72
_ , fmt_duration = line .removesuffix (")." ).split ("(" )
73
73
print (f"{ timestamp : <20} | --FULL- | -BUILD-- | { fmt_duration :<14} | -----------" )
74
74
75
75
if start and end is None :
76
76
print (f"{ start_timestamp : <20} | { version : <7} | { language : <8} | In progress... | { reason } " )
77
77
78
78
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
-
87
79
88
80
if __name__ == "__main__" :
89
81
calc_time (get_lines ())
0 commit comments