Compare commits
No commits in common. "0a449d168d413ad5b7beb8d2b40faa1e8fa9026a" and "ffc86897d9d913c0db6725df9e069930cb84f4b9" have entirely different histories.
0a449d168d
...
ffc86897d9
2 changed files with 15 additions and 36 deletions
|
@ -20,8 +20,6 @@ is_log_timed = true
|
||||||
log_limit = 1073741824
|
log_limit = 1073741824
|
||||||
# If true, then make the build fail if the limit is reached
|
# If true, then make the build fail if the limit is reached
|
||||||
error_on_limit = false
|
error_on_limit = false
|
||||||
# If true, timestamps are in localtime. If false, timestamps are UTC.
|
|
||||||
datetime_in_local_time = true
|
|
||||||
########## END OF MANDATORY VARIABLES
|
########## END OF MANDATORY VARIABLES
|
||||||
|
|
||||||
# Each [[entry]] needs a "name".
|
# Each [[entry]] needs a "name".
|
||||||
|
|
49
update.py
49
update.py
|
@ -26,7 +26,6 @@ GLOBAL_LOG_FILE = "log.txt"
|
||||||
DEFAULT_EDITOR = "/usr/bin/nano"
|
DEFAULT_EDITOR = "/usr/bin/nano"
|
||||||
IS_DIGIT_REGEX = re.compile("^[0-9]+$")
|
IS_DIGIT_REGEX = re.compile("^[0-9]+$")
|
||||||
STRFTIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
|
STRFTIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
|
||||||
STRFTIME_LOCAL_FORMAT = "%Y-%m-%dT%H:%M:%S"
|
|
||||||
|
|
||||||
|
|
||||||
class ArchPkgVersion:
|
class ArchPkgVersion:
|
||||||
|
@ -202,26 +201,6 @@ class ArchPkgVersion:
|
||||||
return self_str
|
return self_str
|
||||||
|
|
||||||
|
|
||||||
def timedelta_to_offset_string(timed: datetime.timedelta):
|
|
||||||
seconds = timed.days * 24 * 60 * 60 + timed.seconds
|
|
||||||
minutes_offset = int(seconds / 60)
|
|
||||||
hours_offset = int(minutes_offset / 60)
|
|
||||||
minutes_offset = minutes_offset - hours_offset * 60
|
|
||||||
return f"{hours_offset:+03d}:{minutes_offset:02d}"
|
|
||||||
|
|
||||||
|
|
||||||
def get_datetime_timezone_now(other_state):
|
|
||||||
if other_state["datetime_in_local_time"]:
|
|
||||||
lt = datetime.datetime.now(datetime.timezone.utc).astimezone()
|
|
||||||
return lt.strftime(STRFTIME_LOCAL_FORMAT) + timedelta_to_offset_string(
|
|
||||||
lt.tzinfo.utcoffset(None)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
return datetime.datetime.now(datetime.timezone.utc).strftime(
|
|
||||||
STRFTIME_FORMAT
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def log_print(*args, **kwargs):
|
def log_print(*args, **kwargs):
|
||||||
"""Prints to stdout, then logs to GLOBAL_LOG_FILE."""
|
"""Prints to stdout, then logs to GLOBAL_LOG_FILE."""
|
||||||
|
|
||||||
|
@ -230,7 +209,9 @@ def log_print(*args, **kwargs):
|
||||||
and "is_timed" in kwargs["other_state"]
|
and "is_timed" in kwargs["other_state"]
|
||||||
and kwargs["other_state"]["is_timed"]
|
and kwargs["other_state"]["is_timed"]
|
||||||
):
|
):
|
||||||
t = get_datetime_timezone_now(kwargs["other_state"])
|
t = datetime.datetime.now(datetime.timezone.utc).strftime(
|
||||||
|
STRFTIME_FORMAT
|
||||||
|
)
|
||||||
print(t, end=" ")
|
print(t, end=" ")
|
||||||
with open(GLOBAL_LOG_FILE, "a", encoding="utf-8") as lf:
|
with open(GLOBAL_LOG_FILE, "a", encoding="utf-8") as lf:
|
||||||
print(t, end=" ", file=lf)
|
print(t, end=" ", file=lf)
|
||||||
|
@ -1144,7 +1125,9 @@ def handle_output_stream(
|
||||||
|
|
||||||
if not limit_reached:
|
if not limit_reached:
|
||||||
if other_state["is_log_timed"]:
|
if other_state["is_log_timed"]:
|
||||||
nowstring = get_datetime_timezone_now(other_state)
|
nowstring = datetime.datetime.now(
|
||||||
|
datetime.timezone.utc
|
||||||
|
).strftime(STRFTIME_FORMAT + " ")
|
||||||
line = nowstring + line
|
line = nowstring + line
|
||||||
log_count += len(line)
|
log_count += len(line)
|
||||||
if log_count > other_state["log_limit"]:
|
if log_count > other_state["log_limit"]:
|
||||||
|
@ -1273,7 +1256,9 @@ def update_pkg_list(
|
||||||
2, f'SCCACHE_CACHE_SIZE={pkg_state[pkg]["sccache_cache_size"]}'
|
2, f'SCCACHE_CACHE_SIZE={pkg_state[pkg]["sccache_cache_size"]}'
|
||||||
)
|
)
|
||||||
post_command_list.insert(3, "RUSTC_WRAPPER=/usr/bin/sccache")
|
post_command_list.insert(3, "RUSTC_WRAPPER=/usr/bin/sccache")
|
||||||
nowstring = get_datetime_timezone_now(other_state)
|
nowstring = datetime.datetime.now(datetime.timezone.utc).strftime(
|
||||||
|
STRFTIME_FORMAT
|
||||||
|
)
|
||||||
if "link_cargo_registry" in pkg_state[pkg]:
|
if "link_cargo_registry" in pkg_state[pkg]:
|
||||||
command_list.insert(2, "-d")
|
command_list.insert(2, "-d")
|
||||||
command_list.insert(
|
command_list.insert(
|
||||||
|
@ -1753,7 +1738,9 @@ if __name__ == "__main__":
|
||||||
if args_logs_dir is not None:
|
if args_logs_dir is not None:
|
||||||
GLOBAL_LOG_FILE = args_logs_dir + "/update.py_logs"
|
GLOBAL_LOG_FILE = args_logs_dir + "/update.py_logs"
|
||||||
log_print(
|
log_print(
|
||||||
get_datetime_timezone_now(other_state),
|
datetime.datetime.now(datetime.timezone.utc).strftime(
|
||||||
|
STRFTIME_FORMAT
|
||||||
|
),
|
||||||
other_state=other_state,
|
other_state=other_state,
|
||||||
)
|
)
|
||||||
log_print(
|
log_print(
|
||||||
|
@ -1833,18 +1820,12 @@ if __name__ == "__main__":
|
||||||
other_state["gpg_home"] = d["gpg_dir"]
|
other_state["gpg_home"] = d["gpg_dir"]
|
||||||
other_state["logs_dir"] = d["logs_dir"]
|
other_state["logs_dir"] = d["logs_dir"]
|
||||||
other_state["clones_dir"] = d["clones_dir"]
|
other_state["clones_dir"] = d["clones_dir"]
|
||||||
if (
|
|
||||||
"datetime_in_local_time" in d
|
|
||||||
and type(d["datetime_in_local_time"]) is bool
|
|
||||||
and d["datetime_in_local_time"]
|
|
||||||
):
|
|
||||||
other_state["datetime_in_local_time"] = True
|
|
||||||
else:
|
|
||||||
other_state["datetime_in_local_time"] = False
|
|
||||||
if other_state["logs_dir"] is not None:
|
if other_state["logs_dir"] is not None:
|
||||||
GLOBAL_LOG_FILE = other_state["logs_dir"] + "/update.py_logs"
|
GLOBAL_LOG_FILE = other_state["logs_dir"] + "/update.py_logs"
|
||||||
log_print(
|
log_print(
|
||||||
get_datetime_timezone_now(other_state),
|
datetime.datetime.now(datetime.timezone.utc).strftime(
|
||||||
|
STRFTIME_FORMAT
|
||||||
|
),
|
||||||
other_state=other_state,
|
other_state=other_state,
|
||||||
)
|
)
|
||||||
log_print(
|
log_print(
|
||||||
|
|
Loading…
Reference in a new issue