aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2023-01-19 09:03:58 +0100
committerJake Hunsaker <jhunsake@redhat.com>2023-01-27 12:18:56 -0500
commit4267a41313588443c4bc4c3a161d13895d4f2f42 (patch)
tree344f8c7530a91d96ddd8539e33cace1fe82748ed
parent59a755f3e72fcc6cd5fc8e584c98d7974fec01e3 (diff)
downloadsos-4267a41313588443c4bc4c3a161d13895d4f2f42.tar.gz
[policies] set case_id before prompting for upload credentials
Since prompting for upload username/password relies on case_id for some policies, let fully set case_id before that. Resolves: #3117 Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r--sos/policies/distros/__init__.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/sos/policies/distros/__init__.py b/sos/policies/distros/__init__.py
index 84382c08..d848e8e3 100644
--- a/sos/policies/distros/__init__.py
+++ b/sos/policies/distros/__init__.py
@@ -286,6 +286,7 @@ class LinuxPolicy(Policy):
self.upload_password = cmdline_opts.upload_pass
self.upload_archive_name = ''
+ # set or query for case id
if not cmdline_opts.batch and not \
cmdline_opts.quiet:
try:
@@ -296,6 +297,16 @@ class LinuxPolicy(Policy):
_("Optionally, please enter the case id that you are "
"generating this report for [%s]: ") % caseid
)
+ except KeyboardInterrupt:
+ raise
+ if cmdline_opts.case_id:
+ self.case_id = cmdline_opts.case_id
+
+ # set or query for upload credentials; this needs to be done after
+ # setting case id, as below methods might rely on detection of it
+ if not cmdline_opts.batch and not \
+ cmdline_opts.quiet:
+ try:
# Policies will need to handle the prompts for user information
if cmdline_opts.upload and self.get_upload_url():
self.prompt_for_upload_user()
@@ -304,9 +315,6 @@ class LinuxPolicy(Policy):
except KeyboardInterrupt:
raise
- if cmdline_opts.case_id:
- self.case_id = cmdline_opts.case_id
-
return
def prompt_for_upload_user(self):