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:
parent
844d14beba
commit
abddc03b63
2 changed files with 7 additions and 8 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,3 +4,5 @@
|
||||||
|
|
||||||
# builded
|
# builded
|
||||||
*-build.json
|
*-build.json
|
||||||
|
|
||||||
|
.github_credentials
|
||||||
|
|
|
@ -20,6 +20,10 @@ re_commit_author = re.compile(
|
||||||
re.MULTILINE
|
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
|
# Helpers
|
||||||
|
|
||||||
|
@ -72,7 +76,7 @@ def get_json(url, verify=True):
|
||||||
try:
|
try:
|
||||||
# Retrieve and load manifest
|
# Retrieve and load manifest
|
||||||
if ".github" in url:
|
if ".github" in url:
|
||||||
r = requests.get(url, verify=verify, auth=token)
|
r = requests.get(url, verify=verify, auth=github_credentials)
|
||||||
else:
|
else:
|
||||||
r = requests.get(url, verify=verify)
|
r = requests.get(url, verify=verify)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
|
@ -106,7 +110,6 @@ parser = argparse.ArgumentParser(description='Process YunoHost application list.
|
||||||
# Add arguments and options
|
# Add arguments and options
|
||||||
parser.add_argument("input", help="Path to json input file")
|
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("-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
|
# Parse args
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -133,12 +136,6 @@ if os.path.exists(args.output):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Error while trying to load already built file: %s" % 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
|
# Loop through every apps
|
||||||
result_dict = {}
|
result_dict = {}
|
||||||
for app, info in apps_list.items():
|
for app, info in apps_list.items():
|
||||||
|
|
Loading…
Add table
Reference in a new issue