[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/72] scripts/qom-fuse: Apply pylint rules
From: |
John Snow |
Subject: |
[PULL 10/72] scripts/qom-fuse: Apply pylint rules |
Date: |
Fri, 18 Jun 2021 19:03:53 -0400 |
- Catch specific exceptions from QMP
- Reraise errors with explicit context
- method parameters should match parent's names
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20210603003719.1321369-11-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/qmp/qom-fuse | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse
index ca30e92867..805e99c8ec 100755
--- a/scripts/qmp/qom-fuse
+++ b/scripts/qmp/qom-fuse
@@ -23,7 +23,7 @@ from fuse import FUSE, FuseOSError, Operations
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.qmp import QEMUMonitorProtocol
+from qemu.qmp import QEMUMonitorProtocol, QMPResponseError
fuse.fuse_python_api = (0, 2)
@@ -47,7 +47,7 @@ class QOMFS(Operations):
try:
self.qmp.command('qom-list', path=path)
return True
- except:
+ except QMPResponseError:
return False
def is_property(self, path):
@@ -59,7 +59,7 @@ class QOMFS(Operations):
if item['name'] == prop:
return True
return False
- except:
+ except QMPResponseError:
return False
def is_link(self, path):
@@ -73,10 +73,10 @@ class QOMFS(Operations):
return True
return False
return False
- except:
+ except QMPResponseError:
return False
- def read(self, path, length, offset, fh):
+ def read(self, path, size, offset, fh):
if not self.is_property(path):
return -ENOENT
@@ -86,13 +86,13 @@ class QOMFS(Operations):
try:
data = self.qmp.command('qom-get', path=path, property=prop)
data += '\n' # make values shell friendly
- except:
- raise FuseOSError(EPERM)
+ except QMPResponseError as err:
+ raise FuseOSError(EPERM) from err
if offset > len(data):
return ''
- return bytes(data[offset:][:length], encoding='utf-8')
+ return bytes(data[offset:][:size], encoding='utf-8')
def readlink(self, path):
if not self.is_link(path):
--
2.31.1
- [PULL 13/72] scripts/qom-fuse: use QOMCommand.qom_list(), (continued)
- [PULL 13/72] scripts/qom-fuse: use QOMCommand.qom_list(), John Snow, 2021/06/18
- [PULL 18/72] scripts/qom-fuse: add redirection shim to python/qemu/qmp/qom-fuse.py, John Snow, 2021/06/18
- [PULL 20/72] scripts/qemu-ga-client: apply isort rules, John Snow, 2021/06/18
- [PULL 22/72] scripts/qemu-ga-client: Fix exception handling, John Snow, 2021/06/18
- [PULL 27/72] scripts/qemu-ga-client: add mypy type hints, John Snow, 2021/06/18
- [PULL 26/72] python/qmp: Correct type of QMPReturnValue, John Snow, 2021/06/18
- [PULL 28/72] scripts/qemu-ga-client: move to python/qemu/qmp/qemu_ga_client.py, John Snow, 2021/06/18
- [PULL 36/72] scripts/qmp-shell: remove shadowed variable from _print(), John Snow, 2021/06/18
- [PULL 19/72] python/qmp: add fuse command to 'qom' tools, John Snow, 2021/06/18
- [PULL 37/72] scripts/qmp-shell: use @classmethod where appropriate, John Snow, 2021/06/18
- [PULL 10/72] scripts/qom-fuse: Apply pylint rules,
John Snow <=
- [PULL 21/72] scripts/qemu-ga-client: apply (most) flake8 rules, John Snow, 2021/06/18
- [PULL 29/72] python/qemu-ga-client: add entry point, John Snow, 2021/06/18
- [PULL 33/72] scripts/qmp-shell: fix show_banner signature, John Snow, 2021/06/18
- [PULL 48/72] scripts/qmp-shell: Add pretty attribute to HMP shell, John Snow, 2021/06/18
- [PULL 44/72] scripts/qmp-shell: fix shell history exception handling, John Snow, 2021/06/18
- [PULL 46/72] scripts/qmp-shell: use isinstance() instead of type(), John Snow, 2021/06/18
- [PULL 43/72] scripts/qmp-shell: rename one and two-letter variables, John Snow, 2021/06/18
- [PULL 49/72] scripts/qmp-shell: Make verbose a public attribute, John Snow, 2021/06/18
- [PULL 31/72] scripts/qmp-shell: apply isort rules, John Snow, 2021/06/18
- [PULL 39/72] scripts/qmp-shell: declare verbose in __init__, John Snow, 2021/06/18