[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 08/19] scripts/qom-fuse: apply flake8 rules
From: |
John Snow |
Subject: |
[PATCH v3 08/19] scripts/qom-fuse: apply flake8 rules |
Date: |
Wed, 2 Jun 2021 20:37:08 -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>
---
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 62deb9adb12..ca30e928679 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
- [PATCH v3 00/19] Python: move /scripts/qmp/qom* to /python/qemu/qmp/qom*, John Snow, 2021/06/02
- [PATCH v3 03/19] python/qmp: add parse_address classmethod, John Snow, 2021/06/02
- [PATCH v3 02/19] python/qmp: Fix type of SocketAddrT, John Snow, 2021/06/02
- [PATCH v3 01/19] python/pipenv: Update Pipfile.lock, John Snow, 2021/06/02
- [PATCH v3 05/19] python/qmp: add qom script entry points, John Snow, 2021/06/02
- [PATCH v3 04/19] python/qmp: Add qom script rewrites, John Snow, 2021/06/02
- [PATCH v3 06/19] scripts/qmp: redirect qom-xxx scripts to python/qemu/qmp/, John Snow, 2021/06/02
- [PATCH v3 07/19] scripts/qom-fuse: apply isort rules, John Snow, 2021/06/02
- [PATCH v3 08/19] scripts/qom-fuse: apply flake8 rules,
John Snow <=
- [PATCH v3 09/19] python: Add 'fh' to known-good variable names, John Snow, 2021/06/02
- [PATCH v3 10/19] scripts/qom-fuse: Apply pylint rules, John Snow, 2021/06/02
- [PATCH v3 11/19] scripts/qom-fuse: Add docstrings, John Snow, 2021/06/02
- [PATCH v3 12/19] scripts/qom-fuse: Convert to QOMCommand, John Snow, 2021/06/02
- [PATCH v3 13/19] scripts/qom-fuse: use QOMCommand.qom_list(), John Snow, 2021/06/02
- [PATCH v3 14/19] scripts/qom-fuse: ensure QOMFuse.read always returns bytes, John Snow, 2021/06/02
- [PATCH v3 15/19] scripts/qom-fuse: add static type hints, John Snow, 2021/06/02
- [PATCH v3 16/19] python: add optional FUSE dependencies, John Snow, 2021/06/02