1
0
Fork 0
mirror of https://github.com/YunoHost/apps.git synced 2024-09-03 20:06:07 +02:00

Read credentials from .github_credentials instead of having to provide them through arguments

This commit is contained in:
Alexandre Aubin 2020-03-20 18:36:53 +01:00
parent 844d14beba
commit abddc03b63
2 changed files with 7 additions and 8 deletions

2
.gitignore vendored
View file

@ -4,3 +4,5 @@
# builded
*-build.json
.github_credentials

View file

@ -20,6 +20,10 @@ re_commit_author = re.compile(
re.MULTILINE
)
# GitHub credentials from ./.github_credentials than should contain <user>:<token>
# 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 <username>:<password>")
# 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():