Rework how logging it done

This will help knowing what the service is doing

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
Pierre-Yves Chibon 2020-04-22 13:00:12 +02:00
parent 1df9b3e8cb
commit d390ef18f4

View file

@ -50,23 +50,24 @@ def run_command(command, cwd=None):
def mirror_from_pagure():
""" Sync packagers and schedules the next one. """
for url in urls:
_log.info("Syncing %s", url)
name = url.rsplit("/", 1)[-1]
dest_folder = os.path.join(mirror_folder, name)
if not os.path.exists(dest_folder):
_log.info(" Cloning as new %s", url)
cmd = ["git", "clone", "--mirror", url]
run_command(cmd, cwd=mirror_folder)
_log.info(" Running git fetch")
cmd = ["git", "fetch"]
run_command(cmd, cwd=dest_folder)
_log.info(" Running git fsck")
cmd = ["git", "fsck"]
run_command(cmd, cwd=dest_folder)
print(
"%s Run finished, next run in %s seconds"
% (datetime.datetime.utcnow().isoformat(), delay)
)
_log.info("Run finished, next run in %s seconds", delay)
s.enter(delay, 1, mirror_from_pagure, argument=())
@ -89,4 +90,7 @@ def run():
if __name__ == "__main__":
formater = '%(asctime)-15s %(message)s'
logging.basicConfig(format=formater)
_log.setLevel(logging.INFO)
main()