mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
lvmdbusd: WS/pep8 corrections
This commit is contained in:
parent
1870b3293a
commit
5392a612dc
@ -135,11 +135,11 @@ def background_execute(command, background_job):
|
||||
# the command always!
|
||||
command.insert(0, cfg.LVM_CMD)
|
||||
process = subprocess.Popen(command, stdout=subprocess.PIPE,
|
||||
env=os.environ,
|
||||
env=os.environ,
|
||||
stderr=subprocess.PIPE, close_fds=True)
|
||||
|
||||
log_debug("Background process for %s is %d" %
|
||||
(str(command), process.pid))
|
||||
(str(command), process.pid))
|
||||
|
||||
lines_iterator = iter(process.stdout.readline, b"")
|
||||
for line in lines_iterator:
|
||||
@ -149,8 +149,8 @@ def background_execute(command, background_job):
|
||||
try:
|
||||
if line_str.count(':') == 2:
|
||||
(device, ignore, percentage) = line_str.split(':')
|
||||
background_job.Percent = \
|
||||
round(float(percentage.strip()[:-1]), 1)
|
||||
background_job.Percent = round(
|
||||
float(percentage.strip()[:-1]), 1)
|
||||
except ValueError:
|
||||
log_error("Trying to parse percentage which failed for %s" %
|
||||
line_str)
|
||||
@ -161,7 +161,7 @@ def background_execute(command, background_job):
|
||||
background_job.Percent = 100
|
||||
else:
|
||||
log_error("Failed to execute background job %s, STDERR= %s"
|
||||
% (str(command), out[1]))
|
||||
% (str(command), out[1]))
|
||||
|
||||
background_job.set_result(process.returncode, out[1])
|
||||
log_debug("Background process %d complete!" % process.pid)
|
||||
|
@ -120,6 +120,7 @@ def call_lvm(command, debug=False):
|
||||
# from forking a new process to using lvm shell
|
||||
_t_call = call_lvm
|
||||
|
||||
|
||||
def _shell_cfg():
|
||||
global _t_call
|
||||
try:
|
||||
|
@ -260,7 +260,7 @@ class LvCommon(AutomatedProperties):
|
||||
'e': 'raid or pool metadata or pool metadata spare',
|
||||
'-': 'Unspecified'}
|
||||
return dbus.Struct((self.state.Attr[0], type_map[self.state.Attr[0]]),
|
||||
signature="as")
|
||||
signature="as")
|
||||
|
||||
@property
|
||||
def Permissions(self):
|
||||
@ -268,7 +268,7 @@ class LvCommon(AutomatedProperties):
|
||||
'R': 'Read-only activation of non-read-only volume',
|
||||
'-': 'Unspecified'}
|
||||
return dbus.Struct((self.state.Attr[1], type_map[self.state.Attr[1]]),
|
||||
signature="(ss)")
|
||||
signature="(ss)")
|
||||
|
||||
@property
|
||||
def AllocationPolicy(self):
|
||||
@ -278,7 +278,7 @@ class LvCommon(AutomatedProperties):
|
||||
'l': 'cling', 'L': 'cling locked',
|
||||
'n': 'normal', 'N': 'normal locked', '-': 'Unspecified'}
|
||||
return dbus.Struct((self.state.Attr[2], type_map[self.state.Attr[2]]),
|
||||
signature="(ss)")
|
||||
signature="(ss)")
|
||||
|
||||
@property
|
||||
def FixedMinor(self):
|
||||
@ -294,7 +294,7 @@ class LvCommon(AutomatedProperties):
|
||||
'i': 'mapped device present with inactive table',
|
||||
'X': 'unknown', '-': 'Unspecified'}
|
||||
return dbus.Struct((self.state.Attr[4], type_map[self.state.Attr[4]]),
|
||||
signature="(ss)")
|
||||
signature="(ss)")
|
||||
|
||||
@property
|
||||
def TargetType(self):
|
||||
@ -302,7 +302,7 @@ class LvCommon(AutomatedProperties):
|
||||
's': 'snapshot', 't': 'thin', 'u': 'unknown',
|
||||
'v': 'virtual', '-': 'Unspecified'}
|
||||
return dbus.Struct((self.state.Attr[6], type_map[self.state.Attr[6]]),
|
||||
signature="(ss)")
|
||||
signature="(ss)")
|
||||
|
||||
@property
|
||||
def ZeroBlocks(self):
|
||||
@ -314,7 +314,7 @@ class LvCommon(AutomatedProperties):
|
||||
'm': 'mismatches', 'w': 'writemostly',
|
||||
'X': 'X unknown', '-': 'Unspecified'}
|
||||
return dbus.Struct((self.state.Attr[8], type_map[self.state.Attr[8]]),
|
||||
signature="(ss)")
|
||||
signature="(ss)")
|
||||
|
||||
@property
|
||||
def SkipActivation(self):
|
||||
|
@ -115,7 +115,6 @@ class LVMShellProxy(object):
|
||||
local_env["LVM_REPORT_FD"] = "32"
|
||||
local_env["LVM_COMMAND_PROFILE"] = "lvmdbusd"
|
||||
|
||||
|
||||
flags = fcntl(self.report_r, F_GETFL)
|
||||
fcntl(self.report_r, F_SETFL, flags | os.O_NONBLOCK)
|
||||
|
||||
@ -223,7 +222,7 @@ if __name__ == "__main__":
|
||||
end = time.time()
|
||||
|
||||
print(("RC: %d" % ret))
|
||||
#print(("OUT:\n%s" % out))
|
||||
# print(("OUT:\n%s" % out))
|
||||
print(("ERR:\n%s" % err))
|
||||
|
||||
print("Command = %f seconds" % (end - start))
|
||||
|
@ -96,20 +96,24 @@ def main():
|
||||
start = time.time()
|
||||
# Add simple command line handling
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--udev", action='store_true',
|
||||
help="Use udev for updating state", default=False,
|
||||
dest='use_udev')
|
||||
parser.add_argument("--debug", action='store_true',
|
||||
help="Dump debug messages", default=False,
|
||||
dest='debug')
|
||||
parser.add_argument("--nojson", action='store_false',
|
||||
help="Do not use LVM JSON output (Note: This "
|
||||
"does not work with --lvmshell", default=True,
|
||||
dest='use_json')
|
||||
parser.add_argument("--lvmshell", action='store_true',
|
||||
help="Use the lvm shell, not fork & exec lvm",
|
||||
default=False,
|
||||
dest='use_lvm_shell')
|
||||
parser.add_argument(
|
||||
"--udev", action='store_true',
|
||||
help="Use udev for updating state",
|
||||
default=False,
|
||||
dest='use_udev')
|
||||
parser.add_argument(
|
||||
"--debug", action='store_true',
|
||||
help="Dump debug messages", default=False,
|
||||
dest='debug')
|
||||
parser.add_argument(
|
||||
"--nojson", action='store_false',
|
||||
help="Do not use LVM JSON output (disables lvmshell)", default=True,
|
||||
dest='use_json')
|
||||
parser.add_argument(
|
||||
"--lvmshell", action='store_true',
|
||||
help="Use the lvm shell, not fork & exec lvm",
|
||||
default=False,
|
||||
dest='use_lvm_shell')
|
||||
|
||||
use_session = os.getenv('LVMDBUSD_USE_SESSION', False)
|
||||
|
||||
|
@ -19,6 +19,7 @@ from .request import RequestEntry
|
||||
from .refresh import event_add
|
||||
from . import udevwatch
|
||||
|
||||
|
||||
# noinspection PyPep8Naming
|
||||
class Manager(AutomatedProperties):
|
||||
_Version_meta = ("s", MANAGER_INTERFACE)
|
||||
|
@ -125,7 +125,7 @@ class ObjectManager(AutomatedProperties):
|
||||
path, props = dbus_object.emit_data()
|
||||
|
||||
# print('Registering object path %s for %s' %
|
||||
# (path, dbus_object.lvm_id))
|
||||
# (path, dbus_object.lvm_id))
|
||||
|
||||
# We want fast access to the object by a number of different ways
|
||||
# so we use multiple hashs with different keys
|
||||
|
Loading…
Reference in New Issue
Block a user