more logging improvement

This commit is contained in:
2020-08-13 12:29:05 +02:00
parent 465388922f
commit 4bfef96f26

View File

@@ -49,6 +49,12 @@ def get_failed_packages(repo):
return []
def build_cleanup():
logging.debug("[GIT] %s", subprocess.run(["git", "clean", "-xdf"], check=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT).stdout.decode())
os.chdir(sys.path[0])
def build(pkgbuild, repo):
start_time = time.time()
name = pathlib.Path(pkgbuild).parts[-4]
@@ -70,15 +76,13 @@ def build(pkgbuild, repo):
with open(os.path.join(config["basedir"]["repo"], repo + "_failed.txt"), "a") as f:
f.write(name + "\n")
# write logs to file
# write logs
if not os.path.exists(os.path.join(config["basedir"]["repo"], "logs", repo)):
pathlib.Path(os.path.join(config["basedir"]["repo"], "logs", repo)).mkdir(parents=True, exist_ok=True)
with open(os.path.join(config["basedir"]["repo"], "logs", repo, name + ".log"), "w") as log:
log.write(res.stdout.decode())
logging.debug("[GIT] %s", subprocess.run(["git", "clean", "-xdf"], check=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT).stdout.decode())
os.chdir(sys.path[0])
build_cleanup()
return
# signing
@@ -88,9 +92,7 @@ def build(pkgbuild, repo):
stderr=subprocess.STDOUT)
if s_res.returncode:
logging.error("[%s/%s] Signing failed: %s", repo, name, s_res.stdout.decode())
logging.debug("[GIT] %s", subprocess.run(["git", "clean", "-xdf"], check=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT).stdout.decode())
os.chdir(sys.path[0])
build_cleanup()
return
# copying
@@ -104,28 +106,24 @@ def build(pkgbuild, repo):
r_res = subprocess.run(["repo-add", "-s", "-v",
os.path.join(config["basedir"]["repo"], repo, "os", config["arch"], repo + ".db.tar.xz"),
pkgs[0]], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
logging.debug("[REPO-ADD] %s", r_res.stdout.decode())
if r_res.returncode:
logging.error("[%s/%s] Repo action failed: %s", repo, name, r_res.stdout.decode())
logging.debug("[GIT] %s", subprocess.run(["git", "clean", "-xdf"], check=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT).stdout.decode())
os.chdir(sys.path[0])
build_cleanup()
return
p_res = subprocess.run(
["paccache", "-rc", os.path.join(config["basedir"]["repo"], repo, "os", config["arch"]), "-k", "1"],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
logging.debug("[PACCACHE] %s", p_res.stdout.decode())
if p_res.returncode:
logging.error("[%s/%s] Repo cleanup failed: %s", repo, name, p_res.stdout.decode())
logging.debug("[GIT] %s", subprocess.run(["git", "clean", "-xdf"], check=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT).stdout.decode())
os.chdir(sys.path[0])
build_cleanup()
return
# cleanup
logging.debug("[GIT] %s", subprocess.run(["git", "clean", "-xdf"], check=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT).stdout.decode())
os.chdir(sys.path[0])
logging.info("[%s/%s] Build successful (%s)", repo, name, time.time() - start_time)
build_cleanup()
logging.info("[%s/%s] Build successful (%s)", repo, name, int(time.time() - start_time))
def setup_makepkg(repo):