From 94d8dcb1985adc7878264ef304e84257afb5d2be Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 20 Mar 2020 18:36:53 +0100 Subject: [PATCH 1/5] Read credentials from .github_credentials instead of having to provide them through arguments --- list_builder.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/list_builder.py b/list_builder.py index e1fc7ad..077fbe4 100755 --- a/list_builder.py +++ b/list_builder.py @@ -20,6 +20,10 @@ re_commit_author = re.compile( re.MULTILINE ) +# GitHub credentials from ./.github_credentials than should contain : +# For example: foobar:abcdef1234567890 +github_credentials = open("./.github_credentials").read().strip().split(":") + # Helpers @@ -72,7 +76,7 @@ def get_json(url, verify=True): try: # Retrieve and load manifest if ".github" in url: - r = requests.get(url, verify=verify, auth=token) + r = requests.get(url, verify=verify, auth=github_credentials) else: r = requests.get(url, verify=verify) r.raise_for_status() @@ -106,7 +110,6 @@ parser = argparse.ArgumentParser(description='Process YunoHost application list. # Add arguments and options parser.add_argument("input", help="Path to json input file") parser.add_argument("-o", "--output", help="Path to result file. If not specified, '-build' suffix will be added to input filename.") -parser.add_argument("-g", "--github", help="Github token :") # Parse args args = parser.parse_args() @@ -133,12 +136,6 @@ if os.path.exists(args.output): except Exception as e: print("Error while trying to load already built file: %s" % e) -# GitHub credentials -if args.github: - token = (args.github.split(':')[0], args.github.split(':')[1]) -else: - token = None - # Loop through every apps result_dict = {} for app, info in apps_list.items(): From 5d9d3686fa080574e583bb4bafc1dae757f4f0e1 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 20 Mar 2020 18:37:29 +0100 Subject: [PATCH 2/5] Replace should_i_rebuild.sh by a new script that corresponds to what we do in the current cron job nowadays --- rebuild.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 rebuild.sh diff --git a/rebuild.sh b/rebuild.sh new file mode 100644 index 0000000..dfe9bec --- /dev/null +++ b/rebuild.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +workdir=$(dirname "$0") +log=$workdir/app_list_auto_update.log + +cd $workdir +date >> $log +git pull >/dev/null + +python ./list_builder.py &>> $log || sendxmpppy "[listbuilder] Rebuilding the application list failed miserably" From 2a54e5e9b01525dc07d75866bc5e0bd7636ca3d6 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 4 Apr 2020 17:03:46 +0200 Subject: [PATCH 3/5] We don't need no argument parsin' --- list_builder.py | 64 +++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/list_builder.py b/list_builder.py index 077fbe4..07ec7bf 100755 --- a/list_builder.py +++ b/list_builder.py @@ -5,7 +5,6 @@ import sys import time import json import zlib -import argparse import subprocess import yaml @@ -15,15 +14,14 @@ from dateutil.parser import parse # Regular expression patterns -re_commit_author = re.compile( - r'^author (?P.+) <(?P.+)> (?P