#60 Raise TestcloudImageError if failed to open file
Merged 4 years ago by lbrabec. Opened 4 years ago by mvadkert.
mvadkert/testcloud master  into  master

file modified
+4 -1
@@ -154,7 +154,10 @@ 

                          break

  

          except OSError:

-             log.error("Problem writing to {}.".format(config_data.PRISTINE))

+             # note: suppress inside exception warnings

+             raise TestcloudImageError(

+                 'Problem writing to {}. Are you in group testcloud?'.format(local_path)

+             ) from None

  

      def _handle_file_url(self, source_path, dest_path, copy=True):

          if not os.path.exists(dest_path):

If user installs testcloud and uses the default configuration
without adding himself to group testcloud, the tool will fail
for him without any clue as config_data.PRISTING does not exist
and testcloud will just print help. The original permission error
is suppressed.

Signed-off-by: Miroslav Vadkerti mvadkert@redhat.com

Hey @lbrabec, can you please review? Thanks.

Metadata Update from @kparal:
- Request assigned

4 years ago

Just a little nitpick, could you adjust the exception message so it looks something like this:
"Problem writing to {}. Are you in group testcloud?".format(local_path)

Other than that, LGTM. I merged #61, please rebase and I will merge this PR.

rebased onto f1e29a8980422c70e33e2c8b5705e166747c1ec9

4 years ago

rebased onto dadd248

4 years ago

Pull-Request has been merged by lbrabec

4 years ago

@lbrabec changed, can you please check it, not sure why my editor tells me the code is invalid syntax :D

Works for me as expected:

$ testcloud instance create f32cloud -u https://dl.fedoraproject.org/pub/fedora/linux/releases/31/Cloud/x86_64/images/Fedora-Cloud-Base-31-1.9.x86_64.qcow2
<...snip...>
testcloud.exceptions.TestcloudImageError: Problem writing to /var/lib/testcloud/backingstores/Fedora-Cloud-Base-31-1.9.x86_64.qcow2. Are you in group testcloud?

My vscode with python extension and flake8 doesn't complain.

good :) so I am done ...

Metadata