mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
scripts/qom-fuse: apply flake8 rules
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>
This commit is contained in:
parent
c6b7eae9b6
commit
26c1ccadc4
1 changed files with 43 additions and 38 deletions
|
@ -9,13 +9,12 @@
|
||||||
# Anthony Liguori <aliguori@us.ibm.com>
|
# Anthony Liguori <aliguori@us.ibm.com>
|
||||||
# Markus Armbruster <armbru@redhat.com>
|
# Markus Armbruster <armbru@redhat.com>
|
||||||
#
|
#
|
||||||
# This work is licensed under the terms of the GNU GPL, version 2 or later. See
|
# This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||||
# the COPYING file in the top-level directory.
|
# See the COPYING file in the top-level directory.
|
||||||
##
|
##
|
||||||
|
|
||||||
from errno import *
|
from errno import ENOENT, EPERM
|
||||||
import os
|
import os
|
||||||
import posix
|
|
||||||
import stat
|
import stat
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -29,6 +28,7 @@ from qemu.qmp import QEMUMonitorProtocol
|
||||||
|
|
||||||
fuse.fuse_python_api = (0, 2)
|
fuse.fuse_python_api = (0, 2)
|
||||||
|
|
||||||
|
|
||||||
class QOMFS(Operations):
|
class QOMFS(Operations):
|
||||||
def __init__(self, qmp):
|
def __init__(self, qmp):
|
||||||
self.qmp = qmp
|
self.qmp = qmp
|
||||||
|
@ -45,7 +45,7 @@ class QOMFS(Operations):
|
||||||
|
|
||||||
def is_object(self, path):
|
def is_object(self, path):
|
||||||
try:
|
try:
|
||||||
items = self.qmp.command('qom-list', path=path)
|
self.qmp.command('qom-list', path=path)
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
@ -104,7 +104,8 @@ class QOMFS(Operations):
|
||||||
|
|
||||||
def getattr(self, path, fh=None):
|
def getattr(self, path, fh=None):
|
||||||
if self.is_link(path):
|
if self.is_link(path):
|
||||||
value = { 'st_mode': 0o755 | stat.S_IFLNK,
|
value = {
|
||||||
|
'st_mode': 0o755 | stat.S_IFLNK,
|
||||||
'st_ino': self.get_ino(path),
|
'st_ino': self.get_ino(path),
|
||||||
'st_dev': 0,
|
'st_dev': 0,
|
||||||
'st_nlink': 2,
|
'st_nlink': 2,
|
||||||
|
@ -113,9 +114,11 @@ class QOMFS(Operations):
|
||||||
'st_size': 4096,
|
'st_size': 4096,
|
||||||
'st_atime': 0,
|
'st_atime': 0,
|
||||||
'st_mtime': 0,
|
'st_mtime': 0,
|
||||||
'st_ctime': 0 }
|
'st_ctime': 0
|
||||||
|
}
|
||||||
elif self.is_object(path):
|
elif self.is_object(path):
|
||||||
value = { 'st_mode': 0o755 | stat.S_IFDIR,
|
value = {
|
||||||
|
'st_mode': 0o755 | stat.S_IFDIR,
|
||||||
'st_ino': self.get_ino(path),
|
'st_ino': self.get_ino(path),
|
||||||
'st_dev': 0,
|
'st_dev': 0,
|
||||||
'st_nlink': 2,
|
'st_nlink': 2,
|
||||||
|
@ -124,9 +127,11 @@ class QOMFS(Operations):
|
||||||
'st_size': 4096,
|
'st_size': 4096,
|
||||||
'st_atime': 0,
|
'st_atime': 0,
|
||||||
'st_mtime': 0,
|
'st_mtime': 0,
|
||||||
'st_ctime': 0 }
|
'st_ctime': 0
|
||||||
|
}
|
||||||
elif self.is_property(path):
|
elif self.is_property(path):
|
||||||
value = { 'st_mode': 0o644 | stat.S_IFREG,
|
value = {
|
||||||
|
'st_mode': 0o644 | stat.S_IFREG,
|
||||||
'st_ino': self.get_ino(path),
|
'st_ino': self.get_ino(path),
|
||||||
'st_dev': 0,
|
'st_dev': 0,
|
||||||
'st_nlink': 1,
|
'st_nlink': 1,
|
||||||
|
@ -135,7 +140,8 @@ class QOMFS(Operations):
|
||||||
'st_size': 4096,
|
'st_size': 4096,
|
||||||
'st_atime': 0,
|
'st_atime': 0,
|
||||||
'st_mtime': 0,
|
'st_mtime': 0,
|
||||||
'st_ctime': 0 }
|
'st_ctime': 0
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
raise FuseOSError(ENOENT)
|
raise FuseOSError(ENOENT)
|
||||||
return value
|
return value
|
||||||
|
@ -146,8 +152,7 @@ class QOMFS(Operations):
|
||||||
for item in self.qmp.command('qom-list', path=path):
|
for item in self.qmp.command('qom-list', path=path):
|
||||||
yield str(item['name'])
|
yield str(item['name'])
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
fuse = FUSE(QOMFS(QEMUMonitorProtocol(os.environ['QMP_SOCKET'])),
|
fuse = FUSE(QOMFS(QEMUMonitorProtocol(os.environ['QMP_SOCKET'])),
|
||||||
sys.argv[1], foreground=True)
|
sys.argv[1], foreground=True)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue