summaryrefslogtreecommitdiffstats
path: root/tools/scripts
diff options
context:
space:
mode:
authorAlan Rominger <arominge@redhat.com>2023-09-12 21:47:12 +0200
committerGitHub <noreply@github.com>2023-09-12 21:47:12 +0200
commit8feeb5f1fae951332ea4b520e5618982109da570 (patch)
tree8f05217cfcfa6967ccc6b41f7a77ec35d5c97807 /tools/scripts
parentShow a toast when the job is already in the process of launching (diff)
downloadawx-8feeb5f1fae951332ea4b520e5618982109da570.tar.xz
awx-8feeb5f1fae951332ea4b520e5618982109da570.zip
Allow saving github creds in user folder (#14435)
Diffstat (limited to 'tools/scripts')
-rwxr-xr-xtools/scripts/get_next_release.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/tools/scripts/get_next_release.py b/tools/scripts/get_next_release.py
index 33e50a0566..0fa36592ab 100755
--- a/tools/scripts/get_next_release.py
+++ b/tools/scripts/get_next_release.py
@@ -3,17 +3,15 @@
missing_modules = []
try:
import requests
-except:
+except ImportError:
missing_modules.append('requests')
import json
import os
-import re
import sys
-import time
try:
import semantic_version
-except:
+except ImportError:
missing_modules.append('semantic_version')
if len(missing_modules) > 0:
@@ -55,7 +53,7 @@ def getNextReleases():
try:
if a_pr['html_url'] in pr_votes:
continue
- except:
+ except KeyError:
print("Unable to check on PR")
print(json.dumps(a_pr, indent=4))
sys.exit(255)
@@ -133,14 +131,17 @@ def getNextReleases():
# Load the users session information
#
session = requests.Session()
-try:
- print("Loading credentials")
- with open(".github_creds", "r") as f:
- password = f.read().strip()
- session.headers.update({'Authorization': 'bearer {}'.format(password), 'Accept': 'application/vnd.github.v3+json'})
-except Exception:
- print("Failed to load credentials from ./.github_creds")
- sys.exit(255)
+
+print("Loading credentials")
+CREDS_LOCATIONS = ('.github_creds', '~/.github_creds')
+for creds_loc in CREDS_LOCATIONS:
+ if os.path.exists(os.path.expanduser(creds_loc)):
+ with open(os.path.expanduser(creds_loc), "r") as f:
+ password = f.read().strip()
+ session.headers.update({'Authorization': 'bearer {}'.format(password), 'Accept': 'application/vnd.github.v3+json'})
+ break
+else:
+ raise Exception(f'Could not location github token in locations {CREDS_LOCATIONS}')
versions = {
'current': {},