Fix pylint warning no-else-return
This commit is contained in:
parent
eb217e0d27
commit
5bc7a8f9e3
@ -269,8 +269,8 @@ class DeviceCollection(object):
|
|||||||
if dev:
|
if dev:
|
||||||
assert len(dev) == 1
|
assert len(dev) == 1
|
||||||
return dev[0]
|
return dev[0]
|
||||||
else:
|
|
||||||
return UnknownDevice(self._vm, ident)
|
return UnknownDevice(self._vm, ident)
|
||||||
|
|
||||||
|
|
||||||
class DeviceManager(dict):
|
class DeviceManager(dict):
|
||||||
|
@ -406,8 +406,7 @@ class Firewall(object):
|
|||||||
def _translate_action(key):
|
def _translate_action(key):
|
||||||
if xml_root.get(key, policy_v1) == 'allow':
|
if xml_root.get(key, policy_v1) == 'allow':
|
||||||
return Action.accept
|
return Action.accept
|
||||||
else:
|
return Action.drop
|
||||||
return Action.drop
|
|
||||||
|
|
||||||
self.rules.append(Rule(None,
|
self.rules.append(Rule(None,
|
||||||
action=_translate_action('dns'),
|
action=_translate_action('dns'),
|
||||||
|
@ -55,8 +55,8 @@ class Element(object):
|
|||||||
if wrap:
|
if wrap:
|
||||||
return ''.join(self.schema.wrapper.fill(p) + '\n\n'
|
return ''.join(self.schema.wrapper.fill(p) + '\n\n'
|
||||||
for p in textwrap.dedent(xml.text.strip('\n')).split('\n\n'))
|
for p in textwrap.dedent(xml.text.strip('\n')).split('\n\n'))
|
||||||
else:
|
|
||||||
return ' '.join(xml.text.strip().split())
|
return ' '.join(xml.text.strip().split())
|
||||||
|
|
||||||
|
|
||||||
def get_data_type(self, xml=None):
|
def get_data_type(self, xml=None):
|
||||||
|
@ -460,8 +460,8 @@ class Storage(object):
|
|||||||
"You need to pass a Volume or pool name as str"
|
"You need to pass a Volume or pool name as str"
|
||||||
if isinstance(volume, Volume):
|
if isinstance(volume, Volume):
|
||||||
return self.pools[volume.name]
|
return self.pools[volume.name]
|
||||||
else:
|
|
||||||
return self.vm.app.pools[volume]
|
return self.vm.app.pools[volume]
|
||||||
|
|
||||||
def commit(self):
|
def commit(self):
|
||||||
''' Makes changes to an 'origin' volume persistent '''
|
''' Makes changes to an 'origin' volume persistent '''
|
||||||
@ -490,8 +490,8 @@ class Storage(object):
|
|||||||
"You need to pass a Volume or pool name as str"
|
"You need to pass a Volume or pool name as str"
|
||||||
if isinstance(volume, Volume):
|
if isinstance(volume, Volume):
|
||||||
return self.pools[volume.name].export(volume)
|
return self.pools[volume.name].export(volume)
|
||||||
else:
|
|
||||||
return self.pools[volume].export(self.vm.volumes[volume])
|
return self.pools[volume].export(self.vm.volumes[volume])
|
||||||
|
|
||||||
|
|
||||||
class Pool(object):
|
class Pool(object):
|
||||||
|
@ -377,10 +377,10 @@ class FileVolume(qubes.storage.Volume):
|
|||||||
|
|
||||||
if not os.path.exists(old_revision):
|
if not os.path.exists(old_revision):
|
||||||
return {}
|
return {}
|
||||||
else:
|
|
||||||
seconds = os.path.getctime(old_revision)
|
seconds = os.path.getctime(old_revision)
|
||||||
iso_date = qubes.storage.isodate(seconds).split('.', 1)[0]
|
iso_date = qubes.storage.isodate(seconds).split('.', 1)[0]
|
||||||
return {iso_date: old_revision}
|
return {iso_date: old_revision}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def usage(self):
|
def usage(self):
|
||||||
|
@ -401,8 +401,8 @@ class ThinVolume(qubes.storage.Volume):
|
|||||||
return qubes.storage.BlockDevice(
|
return qubes.storage.BlockDevice(
|
||||||
'/dev/' + self._vid_snap, self.name, self.script,
|
'/dev/' + self._vid_snap, self.name, self.script,
|
||||||
self.rw, self.domain, self.devtype)
|
self.rw, self.domain, self.devtype)
|
||||||
else:
|
|
||||||
return super(ThinVolume, self).block_device()
|
return super(ThinVolume, self).block_device()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def usage(self): # lvm thin usage always returns at least the same usage as
|
def usage(self): # lvm thin usage always returns at least the same usage as
|
||||||
|
@ -40,8 +40,7 @@ class TarSparseInfo(tarfile.TarInfo):
|
|||||||
def realsize(self):
|
def realsize(self):
|
||||||
if self.sparsemap:
|
if self.sparsemap:
|
||||||
return self.sparsemap[-1][0] + self.sparsemap[-1][1]
|
return self.sparsemap[-1][0] + self.sparsemap[-1][1]
|
||||||
else:
|
return self.size
|
||||||
return self.size
|
|
||||||
|
|
||||||
def sparse_header_chunk(self, index):
|
def sparse_header_chunk(self, index):
|
||||||
if index < len(self.sparsemap):
|
if index < len(self.sparsemap):
|
||||||
@ -49,8 +48,7 @@ class TarSparseInfo(tarfile.TarInfo):
|
|||||||
tarfile.itn(self.sparsemap[index][0], 12, tarfile.GNU_FORMAT),
|
tarfile.itn(self.sparsemap[index][0], 12, tarfile.GNU_FORMAT),
|
||||||
tarfile.itn(self.sparsemap[index][1], 12, tarfile.GNU_FORMAT),
|
tarfile.itn(self.sparsemap[index][1], 12, tarfile.GNU_FORMAT),
|
||||||
])
|
])
|
||||||
else:
|
return b'\0' * 12 * 2
|
||||||
return b'\0' * 12 * 2
|
|
||||||
|
|
||||||
def get_gnu_header(self):
|
def get_gnu_header(self):
|
||||||
'''Part placed in 'prefix' field of posix header'''
|
'''Part placed in 'prefix' field of posix header'''
|
||||||
@ -81,8 +79,7 @@ class TarSparseInfo(tarfile.TarInfo):
|
|||||||
header_buf = super(TarSparseInfo, self).tobuf(format, encoding, errors)
|
header_buf = super(TarSparseInfo, self).tobuf(format, encoding, errors)
|
||||||
if len(self.sparsemap) > 4:
|
if len(self.sparsemap) > 4:
|
||||||
return header_buf + b''.join(self.create_ext_sparse_headers())
|
return header_buf + b''.join(self.create_ext_sparse_headers())
|
||||||
else:
|
return header_buf
|
||||||
return header_buf
|
|
||||||
|
|
||||||
def create_ext_sparse_headers(self):
|
def create_ext_sparse_headers(self):
|
||||||
for ext_hdr in range(4, len(self.sparsemap), 21):
|
for ext_hdr in range(4, len(self.sparsemap), 21):
|
||||||
|
@ -309,8 +309,8 @@ class StatusColumn(Column):
|
|||||||
if ret is not None:
|
if ret is not None:
|
||||||
if getattr(vm, 'hvm', False):
|
if getattr(vm, 'hvm', False):
|
||||||
return ret.upper()
|
return ret.upper()
|
||||||
else:
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
@flag(2)
|
@flag(2)
|
||||||
@ -478,8 +478,8 @@ class Table(object):
|
|||||||
'''Format single table row (all columns for one domain).'''
|
'''Format single table row (all columns for one domain).'''
|
||||||
if self.raw_data:
|
if self.raw_data:
|
||||||
return '|'.join(col.format(vm) for col in self.columns)
|
return '|'.join(col.format(vm) for col in self.columns)
|
||||||
else:
|
|
||||||
return ''.join(col.cell(vm) for col in self.columns)
|
return ''.join(col.cell(vm) for col in self.columns)
|
||||||
|
|
||||||
|
|
||||||
def write_table(self, stream=sys.stdout):
|
def write_table(self, stream=sys.stdout):
|
||||||
|
@ -111,22 +111,22 @@ def parse_size(size):
|
|||||||
def mbytes_to_kmg(size):
|
def mbytes_to_kmg(size):
|
||||||
if size > 1024:
|
if size > 1024:
|
||||||
return "%d GiB" % (size / 1024)
|
return "%d GiB" % (size / 1024)
|
||||||
else:
|
|
||||||
return "%d MiB" % size
|
return "%d MiB" % size
|
||||||
|
|
||||||
|
|
||||||
def kbytes_to_kmg(size):
|
def kbytes_to_kmg(size):
|
||||||
if size > 1024:
|
if size > 1024:
|
||||||
return mbytes_to_kmg(size / 1024)
|
return mbytes_to_kmg(size / 1024)
|
||||||
else:
|
|
||||||
return "%d KiB" % size
|
return "%d KiB" % size
|
||||||
|
|
||||||
|
|
||||||
def bytes_to_kmg(size):
|
def bytes_to_kmg(size):
|
||||||
if size > 1024:
|
if size > 1024:
|
||||||
return kbytes_to_kmg(size / 1024)
|
return kbytes_to_kmg(size / 1024)
|
||||||
else:
|
|
||||||
return "%d B" % size
|
return "%d B" % size
|
||||||
|
|
||||||
|
|
||||||
def size_to_human(size):
|
def size_to_human(size):
|
||||||
@ -137,8 +137,8 @@ def size_to_human(size):
|
|||||||
return str(round(size / 1024.0, 1)) + ' KiB'
|
return str(round(size / 1024.0, 1)) + ' KiB'
|
||||||
elif size < 1024 * 1024 * 1024:
|
elif size < 1024 * 1024 * 1024:
|
||||||
return str(round(size / (1024.0 * 1024), 1)) + ' MiB'
|
return str(round(size / (1024.0 * 1024), 1)) + ' MiB'
|
||||||
else:
|
|
||||||
return str(round(size / (1024.0 * 1024 * 1024), 1)) + ' GiB'
|
return str(round(size / (1024.0 * 1024 * 1024), 1)) + ' GiB'
|
||||||
|
|
||||||
|
|
||||||
def urandom(size):
|
def urandom(size):
|
||||||
|
@ -49,8 +49,8 @@ def _default_ip(self):
|
|||||||
return None
|
return None
|
||||||
if self.netvm is not None:
|
if self.netvm is not None:
|
||||||
return self.netvm.get_ip_for_vm(self) # pylint: disable=no-member
|
return self.netvm.get_ip_for_vm(self) # pylint: disable=no-member
|
||||||
else:
|
|
||||||
return self.get_ip_for_vm(self)
|
return self.get_ip_for_vm(self)
|
||||||
|
|
||||||
|
|
||||||
def _setter_ip(self, prop, value):
|
def _setter_ip(self, prop, value):
|
||||||
@ -173,8 +173,8 @@ class NetVMMixin(qubes.events.Emitter):
|
|||||||
'10.139.1.1',
|
'10.139.1.1',
|
||||||
'10.139.1.2',
|
'10.139.1.2',
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self._firewall = None
|
self._firewall = None
|
||||||
|
@ -1432,10 +1432,10 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
|||||||
else:
|
else:
|
||||||
if not self.is_fully_usable():
|
if not self.is_fully_usable():
|
||||||
return "Transient"
|
return "Transient"
|
||||||
else:
|
|
||||||
return "Running"
|
return "Running"
|
||||||
else:
|
|
||||||
return 'Halted'
|
return 'Halted'
|
||||||
except libvirt.libvirtError as e:
|
except libvirt.libvirtError as e:
|
||||||
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
|
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
|
||||||
return 'Halted'
|
return 'Halted'
|
||||||
@ -1614,8 +1614,8 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
|||||||
'/vm/{}/start_time'.format(self.uuid))
|
'/vm/{}/start_time'.format(self.uuid))
|
||||||
if start_time != '':
|
if start_time != '':
|
||||||
return datetime.datetime.fromtimestamp(float(start_time))
|
return datetime.datetime.fromtimestamp(float(start_time))
|
||||||
else:
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def is_outdated(self):
|
def is_outdated(self):
|
||||||
'''Check whether domain needs restart to update root image from \
|
'''Check whether domain needs restart to update root image from \
|
||||||
|
Loading…
Reference in New Issue
Block a user