From 00501e49c6560924cf4aa581bfd76236e3d892e7 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Jun 28 2024 15:59:53 +0000 Subject: fedora_submit.py: handle being called the old way After a few folks tested this, I realized their results aren't being submitted because they have existing .config files with the old submit hook definition: commithook="./fedora_submit.py $username $password -l $logfile" which no longer matches how the script expects to be called. Telling everyone to edit their config files is dumb, so let's handle being called that way instead, but also print a warning that people should edit the username and password out of their config file for security. Signed-off-by: Adam Williamson --- diff --git a/fedora_submit.py b/fedora_submit.py index ed4eb9d..a3bdcfb 100755 --- a/fedora_submit.py +++ b/fedora_submit.py @@ -8,11 +8,20 @@ from openidc_client.requestsauth import OpenIDCClientAuther import requests import sys -log = sys.argv[1:] -if len(log) != 1: - print('fedora_submit.py ') - sys.exit(2) -log = log[0] +try: + lpos = sys.argv.index("-l") + log = sys.argv[lpos+1] + if len(sys.argv) > 3: + print( + "Warning: config file contains your username and password! This " + "is no longer needed. Edit .config and remove them" + ) +except (ValueError, IndexError): + log = sys.argv[1:] + if len(log) != 1 or log == ["-l"]: + print('fedora_submit.py or fedora_submit.py -l ') + sys.exit(2) + log = log[0] print(log) client = OpenIDCClient(