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.
44For example:
55
66.. code-block:: bash
77
8- $ cd docsbuild-logs
9- $ scp "[email protected] :/var/log/docsbuild/docsbuild.log*" . 10- $ python ../check_times.py
8+ $ scp "[email protected] :/var/log/docsbuild/docsbuild.log*" docsbuild-logs 9+ $ python check_times.py
1110"""
1211
1312import datetime as dt
1413import gzip
1514from pathlib import Path
1615
16+ from build_docs import format_seconds
1717
1818def 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
8880if __name__ == "__main__" :
8981 calc_time (get_lines ())
0 commit comments