Skip to content

Commit

Permalink
Apply review suggestions.
Browse files Browse the repository at this point in the history
Signed-off-by: Trevor Benson <[email protected]>
  • Loading branch information
TrevorBenson committed Jan 8, 2024
1 parent 0a0a158 commit f5a9a51
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions sos/policies/distros/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,19 +391,23 @@ def prompt_for_upload_s3_access_key(self):
"""
if not self.get_upload_s3_access_key():

msg = ("Please provide the upload access key for bucket %s via "
"endpoint %s: " % (self.get_upload_s3_bucket(),
self.get_upload_s3_endpoint()))
msg = (
"Please provide the upload access key for bucket"
f" {self.get_upload_s3_bucket()} via endpoint"
f" {self.get_upload_s3_endpoint()}: "
)
self.upload_s3_access_key = input(_(msg))

def prompt_for_upload_s3_secret_key(self):
"""Should be overridden by policies to determine if a secret key needs
to be provided for upload or not
"""
if not self.get_upload_s3_secret_key():
msg = ("Please provide the upload secret key for bucket %s via "
"endpoint %s: " % (self.get_upload_s3_bucket(),
self.get_upload_s3_endpoint()))
msg = (
"Please provide the upload secret key for bucket"
f" {self.get_upload_s3_bucket()} via endpoint"
f" {self.get_upload_s3_endpoint()}: "
)
self.upload_s3_secret_key = getpass(msg)

def prompt_for_upload_s3_bucket(self):
Expand All @@ -424,11 +428,11 @@ def prompt_for_upload_s3_endpoint(self):
"""
default_endpoint = self._upload_s3_endpoint
if not self.upload_s3_endpoint:
msg = "Please provide the upload endpoint for bucket %s " \
"(default: %s): " % (
self.get_upload_s3_bucket(),
default_endpoint
)
msg = (
"Please provide the upload endpoint for bucket"
f" {self.get_upload_s3_bucket()}"
f" (default: {default_endpoint}): "
)
user_input = input(_(msg))
self.upload_s3_endpoint = user_input or default_endpoint
return self.upload_s3_endpoint
Expand Down Expand Up @@ -980,7 +984,7 @@ def upload_s3(self, endpoint=None, region=None, bucket=None, prefix=None,
bucket, key)
return True
except Exception as e:
raise Exception("Failed to upload to S3: %s" % str(e))
raise Exception(f"Failed to upload to S3: {str(e)}") from e

def set_sos_prefix(self):
"""If sosreport commands need to always be prefixed with something,
Expand Down

0 comments on commit f5a9a51

Please sign in to comment.