From: Tony Asleson <tasleson@redhat.com>
To: linux-nvme@lists.infradead.org
Subject: [PATCH 2/6] nvmetcli: Improve IOError handling on restore
Date: Fri, 20 Mar 2020 15:39:42 -0500 [thread overview]
Message-ID: <20200320203946.37338-3-tasleson@redhat.com> (raw)
In-Reply-To: <20200320203946.37338-1-tasleson@redhat.com>
Not all IOErrors are caused by specifing a missing configuration
file. When the file is present, dump the error exception text too,
so the user has a better idea what is wrong.
Signed-off-by: Tony Asleson <tasleson@redhat.com>
---
nvmetcli | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/nvmetcli b/nvmetcli
index 3d8c16e..5553721 100755
--- a/nvmetcli
+++ b/nvmetcli
@@ -24,6 +24,7 @@ import os
import sys
import configshell_fb as configshell
import nvmet as nvme
+import errno
from string import hexdigits
import uuid
@@ -674,15 +675,26 @@ def save(to_file):
def restore(from_file):
+ errors = None
+
try:
errors = nvme.Root().restore_from_file(from_file)
- except IOError:
- # Not an error if the restore file is not present
- print("No saved config file at %s, ok, exiting" % from_file)
- sys.exit(0)
+ except IOError as e:
+ if e.errno == errno.ENOENT:
+ # Not an error if the restore file is not present
+ print("No saved config file at %s, ok, exiting" % from_file)
+ sys.exit(0)
+ else:
+ print("Error processing config file at %s, error %s, exiting" %
+ (from_file, str(e)))
+ sys.exit(1)
- for error in errors:
- print(error)
+ if errors:
+ for error in errors:
+ print(error)
+ sys.exit(1)
+
+ sys.exit(0)
def clear(unused):
--
2.25.1
_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
next prev parent reply other threads:[~2020-03-20 20:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-20 20:39 [PATCH 0/6] nvmetcli: Misc. corrections Tony Asleson
2020-03-20 20:39 ` [PATCH 1/6] README: Update URL for configshell-fb Tony Asleson
2020-03-21 0:47 ` Chaitanya Kulkarni
2020-03-21 2:49 ` Tony Asleson
2020-03-20 20:39 ` Tony Asleson [this message]
2020-03-20 20:39 ` [PATCH 3/6] nvme.py: Explicit close is redundant Tony Asleson
2020-03-21 1:06 ` Chaitanya Kulkarni
2020-03-20 20:39 ` [PATCH 4/6] nvme.py: Sync the containing directory Tony Asleson
2020-03-20 20:39 ` [PATCH 5/6] nvme.py: Make modprobe work for kmod lib too Tony Asleson
2020-03-20 20:39 ` [PATCH 6/6] test_nvmet.py: Use string.ascii_lowercase Tony Asleson
2020-03-21 1:12 ` Chaitanya Kulkarni
2020-03-21 2:34 ` Tony Asleson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200320203946.37338-3-tasleson@redhat.com \
--to=tasleson@redhat.com \
--cc=linux-nvme@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).