jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/375500 )
Change subject: Prompt for HTTP password instead of keeping it on disk ...................................................................... Prompt for HTTP password instead of keeping it on disk Per discussion on T174760. Change-Id: I4c6f4bd614ebb9cfc4e5ec95935a493b0f497a95 --- M .gitignore D config.json.example M upgrade.py 3 files changed, 11 insertions(+), 21 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/.gitignore b/.gitignore index 5db91c0..7157448 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ extensions/*.html index.html sniffs/*.html -config.json diff --git a/config.json.example b/config.json.example deleted file mode 100755 index 8983e57..0000000 --- a/config.json.example +++ /dev/null @@ -1,4 +0,0 @@ -{ - "GERRIT_USER": "libraryupgrader", - "GERRIT_PW": "" -} diff --git a/upgrade.py b/upgrade.py index e4093f4..193d70f 100755 --- a/upgrade.py +++ b/upgrade.py @@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. """ -import json +import getpass import os import sys @@ -25,12 +25,7 @@ import mw -if os.path.exists('config.json'): - with open('config.json') as f: - CONFIG = json.load(f) -else: - CONFIG = {} - +GERRIT_USER = 'libraryupgrader' CANARIES = [ 'mediawiki/extensions/Linter', 'mediawiki/extensions/MassMessage', @@ -40,14 +35,14 @@ ] -def run(repo: str, library: str, version: str) -> str: +def run(repo: str, library: str, version: str, pw: str) -> str: env = { 'MODE': 'upgrade', 'REPO': repo, 'PACKAGE': library, 'VERSION': version, - 'GERRIT_USER': CONFIG.get('GERRIT_USER'), - 'GERRIT_PW': CONFIG.get('GERRIT_PW'), + 'GERRIT_USER': GERRIT_USER, + 'GERRIT_PW': pw, } name = repo.split('/')[-1] + library.split('/')[-1] docker.run(name, env) @@ -55,11 +50,10 @@ return name -def get_safe_logs(name: str) -> str: +def get_safe_logs(name: str, pw: str) -> str: logs = docker.logs(name) - if CONFIG.get('GERRIT_PW'): - # Prevent the password from accidentally leaking - logs = logs.replace(CONFIG.get('GERRIT_PW'), '<password>') + # Prevent the password from accidentally leaking + logs = logs.replace(pw, '<password>') return logs @@ -76,6 +70,7 @@ library = sys.argv[1] version = sys.argv[2] repo = sys.argv[3] + pw = getpass.getpass('HTTP Password for %s: ' % GERRIT_USER) if repo == 'extensions': repos = get_extension_list(library, version_match=version) elif repo == 'canaries': @@ -84,13 +79,13 @@ repos = [repo] processed = set() for repo in repos: - name = run(repo, library, version) + name = run(repo, library, version, pw) processed.add(name) docker.wait_for_containers(count=2) docker.wait_for_containers(0) for name in processed: - logs = get_safe_logs(name) + logs = get_safe_logs(name, pw) with open(os.path.join('logs', name + '.log'), 'w') as f: f.write(logs) print('Saved logs to %s.log' % name) -- To view, visit https://gerrit.wikimedia.org/r/375500 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4c6f4bd614ebb9cfc4e5ec95935a493b0f497a95 Gerrit-PatchSet: 1 Gerrit-Project: labs/libraryupgrader Gerrit-Branch: master Gerrit-Owner: Legoktm <lego...@member.fsf.org> Gerrit-Reviewer: Legoktm <lego...@member.fsf.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits