[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/72] scripts/qom-fuse: apply flake8 rules
From: |
John Snow |
Subject: |
[PULL 08/72] scripts/qom-fuse: apply flake8 rules |
Date: |
Fri, 18 Jun 2021 19:03:51 -0400 |
flake8 still has one warning because of the sys.path hack, but that will
be going away by the end of this patch series.
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20210603003719.1321369-9-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/qmp/qom-fuse | 81 +++++++++++++++++++++++---------------------
1 file changed, 43 insertions(+), 38 deletions(-)
diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse
index 62deb9adb1..ca30e92867 100755
--- a/scripts/qmp/qom-fuse
+++ b/scripts/qmp/qom-fuse
@@ -9,13 +9,12 @@
# Anthony Liguori <aliguori@us.ibm.com>
# Markus Armbruster <armbru@redhat.com>
#
-# This work is licensed under the terms of the GNU GPL, version 2 or later.
See
-# the COPYING file in the top-level directory.
+# This work is licensed under the terms of the GNU GPL, version 2 or later.
+# See the COPYING file in the top-level directory.
##
-from errno import *
+from errno import ENOENT, EPERM
import os
-import posix
import stat
import sys
@@ -29,6 +28,7 @@ from qemu.qmp import QEMUMonitorProtocol
fuse.fuse_python_api = (0, 2)
+
class QOMFS(Operations):
def __init__(self, qmp):
self.qmp = qmp
@@ -45,7 +45,7 @@ class QOMFS(Operations):
def is_object(self, path):
try:
- items = self.qmp.command('qom-list', path=path)
+ self.qmp.command('qom-list', path=path)
return True
except:
return False
@@ -85,7 +85,7 @@ class QOMFS(Operations):
path = '/'
try:
data = self.qmp.command('qom-get', path=path, property=prop)
- data += '\n' # make values shell friendly
+ data += '\n' # make values shell friendly
except:
raise FuseOSError(EPERM)
@@ -104,38 +104,44 @@ class QOMFS(Operations):
def getattr(self, path, fh=None):
if self.is_link(path):
- value = { 'st_mode': 0o755 | stat.S_IFLNK,
- 'st_ino': self.get_ino(path),
- 'st_dev': 0,
- 'st_nlink': 2,
- 'st_uid': 1000,
- 'st_gid': 1000,
- 'st_size': 4096,
- 'st_atime': 0,
- 'st_mtime': 0,
- 'st_ctime': 0 }
+ value = {
+ 'st_mode': 0o755 | stat.S_IFLNK,
+ 'st_ino': self.get_ino(path),
+ 'st_dev': 0,
+ 'st_nlink': 2,
+ 'st_uid': 1000,
+ 'st_gid': 1000,
+ 'st_size': 4096,
+ 'st_atime': 0,
+ 'st_mtime': 0,
+ 'st_ctime': 0
+ }
elif self.is_object(path):
- value = { 'st_mode': 0o755 | stat.S_IFDIR,
- 'st_ino': self.get_ino(path),
- 'st_dev': 0,
- 'st_nlink': 2,
- 'st_uid': 1000,
- 'st_gid': 1000,
- 'st_size': 4096,
- 'st_atime': 0,
- 'st_mtime': 0,
- 'st_ctime': 0 }
+ value = {
+ 'st_mode': 0o755 | stat.S_IFDIR,
+ 'st_ino': self.get_ino(path),
+ 'st_dev': 0,
+ 'st_nlink': 2,
+ 'st_uid': 1000,
+ 'st_gid': 1000,
+ 'st_size': 4096,
+ 'st_atime': 0,
+ 'st_mtime': 0,
+ 'st_ctime': 0
+ }
elif self.is_property(path):
- value = { 'st_mode': 0o644 | stat.S_IFREG,
- 'st_ino': self.get_ino(path),
- 'st_dev': 0,
- 'st_nlink': 1,
- 'st_uid': 1000,
- 'st_gid': 1000,
- 'st_size': 4096,
- 'st_atime': 0,
- 'st_mtime': 0,
- 'st_ctime': 0 }
+ value = {
+ 'st_mode': 0o644 | stat.S_IFREG,
+ 'st_ino': self.get_ino(path),
+ 'st_dev': 0,
+ 'st_nlink': 1,
+ 'st_uid': 1000,
+ 'st_gid': 1000,
+ 'st_size': 4096,
+ 'st_atime': 0,
+ 'st_mtime': 0,
+ 'st_ctime': 0
+ }
else:
raise FuseOSError(ENOENT)
return value
@@ -146,8 +152,7 @@ class QOMFS(Operations):
for item in self.qmp.command('qom-list', path=path):
yield str(item['name'])
+
if __name__ == '__main__':
- import os
-
fuse = FUSE(QOMFS(QEMUMonitorProtocol(os.environ['QMP_SOCKET'])),
sys.argv[1], foreground=True)
--
2.31.1
- [PULL 00/72] Python patches, John Snow, 2021/06/18
- [PULL 02/72] python/qmp: Fix type of SocketAddrT, John Snow, 2021/06/18
- [PULL 05/72] python/qmp: add qom script entry points, John Snow, 2021/06/18
- [PULL 07/72] scripts/qom-fuse: apply isort rules, John Snow, 2021/06/18
- [PULL 12/72] scripts/qom-fuse: Convert to QOMCommand, John Snow, 2021/06/18
- [PULL 14/72] scripts/qom-fuse: ensure QOMFuse.read always returns bytes, John Snow, 2021/06/18
- [PULL 06/72] scripts/qmp: redirect qom-xxx scripts to python/qemu/qmp/, John Snow, 2021/06/18
- [PULL 09/72] python: Add 'fh' to known-good variable names, John Snow, 2021/06/18
- [PULL 17/72] scripts/qom-fuse: move to python/qemu/qmp/qom_fuse.py, John Snow, 2021/06/18
- [PULL 01/72] python/pipenv: Update Pipfile.lock, John Snow, 2021/06/18
- [PULL 08/72] scripts/qom-fuse: apply flake8 rules,
John Snow <=
- [PULL 15/72] scripts/qom-fuse: add static type hints, John Snow, 2021/06/18
- [PULL 11/72] scripts/qom-fuse: Add docstrings, John Snow, 2021/06/18
- [PULL 16/72] python: add optional FUSE dependencies, John Snow, 2021/06/18
- [PULL 30/72] scripts/qemu-ga-client: Add forwarder shim, John Snow, 2021/06/18
- [PULL 35/72] scripts/qmp-shell: fix connect method signature, John Snow, 2021/06/18
- [PULL 32/72] scripts/qmp-shell: Apply flake8 rules, John Snow, 2021/06/18
- [PULL 38/72] scripts/qmp-shell: Use python3-style super(), John Snow, 2021/06/18
- [PULL 03/72] python/qmp: add parse_address classmethod, John Snow, 2021/06/18
- [PULL 04/72] python/qmp: Add qom script rewrites, John Snow, 2021/06/18
- [PULL 13/72] scripts/qom-fuse: use QOMCommand.qom_list(), John Snow, 2021/06/18