qubes: pylint fixes (fix signatures)
This commit is contained in:
parent
8d3edbf133
commit
6798790e1f
@ -485,7 +485,7 @@ class VMCollection(object):
|
|||||||
|
|
||||||
|
|
||||||
def get_vms_connected_to(self, netvm):
|
def get_vms_connected_to(self, netvm):
|
||||||
new_vms = set([netvm])
|
new_vms = set([self[netvm]])
|
||||||
dependent_vms = set()
|
dependent_vms = set()
|
||||||
|
|
||||||
# Dependency resolving only makes sense on NetVM (or derivative)
|
# Dependency resolving only makes sense on NetVM (or derivative)
|
||||||
@ -962,7 +962,7 @@ class PropertyHolder(qubes.events.Emitter):
|
|||||||
for prop in self.proplist():
|
for prop in self.proplist():
|
||||||
try:
|
try:
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
self._init_property(self, prop, getattr(src, prop._attr_name))
|
self._init_property(prop, getattr(src, prop._attr_name))
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -1211,11 +1211,11 @@ class Qubes(PropertyHolder):
|
|||||||
self, None, qid=0, name='dom0'))
|
self, None, qid=0, name='dom0'))
|
||||||
|
|
||||||
# stage 3: load global properties
|
# stage 3: load global properties
|
||||||
self.load_properties(self.xml, load_stage=3)
|
self.load_properties(load_stage=3)
|
||||||
|
|
||||||
# stage 4: fill all remaining VM properties
|
# stage 4: fill all remaining VM properties
|
||||||
for vm in self.domains:
|
for vm in self.domains:
|
||||||
vm.load_properties(None, load_stage=4)
|
vm.load_properties(load_stage=4)
|
||||||
|
|
||||||
# stage 5: misc fixups
|
# stage 5: misc fixups
|
||||||
|
|
||||||
@ -1335,8 +1335,6 @@ class Qubes(PropertyHolder):
|
|||||||
if self.default_template == vm:
|
if self.default_template == vm:
|
||||||
del self.default_template
|
del self.default_template
|
||||||
|
|
||||||
return super(QubesVmCollection, self).pop(qid)
|
|
||||||
|
|
||||||
|
|
||||||
@qubes.events.handler('property-pre-set:clockvm')
|
@qubes.events.handler('property-pre-set:clockvm')
|
||||||
def on_property_pre_set_clockvm(self, event, name, newvalue, oldvalue=None):
|
def on_property_pre_set_clockvm(self, event, name, newvalue, oldvalue=None):
|
||||||
@ -1349,7 +1347,9 @@ class Qubes(PropertyHolder):
|
|||||||
newvalue.services['ntpd'] = False
|
newvalue.services['ntpd'] = False
|
||||||
|
|
||||||
|
|
||||||
@qubes.events.handler('property-pre-set:default_netvm')
|
@qubes.events.handler(
|
||||||
|
'property-pre-set:default_netvm',
|
||||||
|
'property-pre-set:default_fw_netvm')
|
||||||
def on_property_pre_set_default_netvm(self, event, name, newvalue,
|
def on_property_pre_set_default_netvm(self, event, name, newvalue,
|
||||||
oldvalue=None):
|
oldvalue=None):
|
||||||
# pylint: disable=unused-argument,invalid-name
|
# pylint: disable=unused-argument,invalid-name
|
||||||
|
@ -58,7 +58,7 @@ def fetch_ticket_info(uri):
|
|||||||
for row in list(reader)[:2])))
|
for row in list(reader)[:2])))
|
||||||
|
|
||||||
|
|
||||||
def ticket(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
def ticket(name, rawtext, text, lineno, inliner, options=None, content=None):
|
||||||
'''Link to qubes ticket
|
'''Link to qubes ticket
|
||||||
|
|
||||||
:param str name: The role name used in the document
|
:param str name: The role name used in the document
|
||||||
@ -71,6 +71,9 @@ def ticket(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
|||||||
:param content: The directive content for customisation
|
:param content: The directive content for customisation
|
||||||
''' # pylint: disable=unused-argument
|
''' # pylint: disable=unused-argument
|
||||||
|
|
||||||
|
if options is None:
|
||||||
|
options = {}
|
||||||
|
|
||||||
ticketno = text.lstrip('#')
|
ticketno = text.lstrip('#')
|
||||||
if not ticket.isdigit():
|
if not ticket.isdigit():
|
||||||
msg = inliner.reporter.error(
|
msg = inliner.reporter.error(
|
||||||
|
@ -69,7 +69,7 @@ def ishandler(obj):
|
|||||||
class EmitterMeta(type):
|
class EmitterMeta(type):
|
||||||
'''Metaclass for :py:class:`Emitter`'''
|
'''Metaclass for :py:class:`Emitter`'''
|
||||||
def __init__(cls, name, bases, dict_):
|
def __init__(cls, name, bases, dict_):
|
||||||
super(type, cls).__init__(name, bases, dict_)
|
super(EmitterMeta, cls).__init__(name, bases, dict_)
|
||||||
cls.__handlers__ = collections.defaultdict(set)
|
cls.__handlers__ = collections.defaultdict(set)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -33,6 +33,7 @@ import os
|
|||||||
class Plugin(type):
|
class Plugin(type):
|
||||||
'''Base metaclass for plugins'''
|
'''Base metaclass for plugins'''
|
||||||
def __init__(cls, name, bases, dict_):
|
def __init__(cls, name, bases, dict_):
|
||||||
|
super(Plugin, cls).__init__(name, bases, dict_)
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
if hasattr(cls, 'register'):
|
if hasattr(cls, 'register'):
|
||||||
cls.register[cls.__name__] = cls
|
cls.register[cls.__name__] = cls
|
||||||
|
@ -100,7 +100,8 @@ class VMStorage(object):
|
|||||||
def get_config_params(self):
|
def get_config_params(self):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def _copy_file(self, source, destination):
|
@staticmethod
|
||||||
|
def _copy_file(source, destination):
|
||||||
'''Effective file copy, preserving sparse files etc.
|
'''Effective file copy, preserving sparse files etc.
|
||||||
'''
|
'''
|
||||||
# TODO: Windows support
|
# TODO: Windows support
|
||||||
@ -142,9 +143,9 @@ class VMStorage(object):
|
|||||||
|
|
||||||
self.vm.log.info('Creating directory: {0}'.format(self.vm.dir_path))
|
self.vm.log.info('Creating directory: {0}'.format(self.vm.dir_path))
|
||||||
os.mkdir(self.vmdir)
|
os.mkdir(self.vmdir)
|
||||||
self.create_on_disk_private_img(verbose, source_template)
|
self.create_on_disk_private_img(source_template)
|
||||||
self.create_on_disk_root_img(verbose, source_template)
|
self.create_on_disk_root_img(source_template)
|
||||||
self.reset_volatile_storage(verbose, source_template)
|
self.reset_volatile_storage(source_template)
|
||||||
|
|
||||||
os.umask(old_umask)
|
os.umask(old_umask)
|
||||||
|
|
||||||
@ -166,7 +167,8 @@ class VMStorage(object):
|
|||||||
# XXX which modules? -woju
|
# XXX which modules? -woju
|
||||||
|
|
||||||
|
|
||||||
def rename(self, newpath, oldpath):
|
@staticmethod
|
||||||
|
def rename(newpath, oldpath):
|
||||||
'''Move storage directory, most likely during domain's rename.
|
'''Move storage directory, most likely during domain's rename.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
@ -138,7 +138,7 @@ class QubesTestCase(unittest.TestCase):
|
|||||||
self.assertEqual(xml1.get(key), xml2.get(key))
|
self.assertEqual(xml1.get(key), xml2.get(key))
|
||||||
|
|
||||||
|
|
||||||
def assertEventFired(self, emitter, event, args=[], kwargs=[]):
|
def assertEventFired(self, emitter, event, args=None, kwargs=None):
|
||||||
'''Check whether event was fired on given emitter and fail if it did
|
'''Check whether event was fired on given emitter and fail if it did
|
||||||
not.
|
not.
|
||||||
|
|
||||||
@ -154,9 +154,9 @@ class QubesTestCase(unittest.TestCase):
|
|||||||
for ev, ev_args, ev_kwargs in emitter.fired_events:
|
for ev, ev_args, ev_kwargs in emitter.fired_events:
|
||||||
if ev != event:
|
if ev != event:
|
||||||
continue
|
continue
|
||||||
if any(i not in ev_args for i in args):
|
if args is not None and any(i not in ev_args for i in args):
|
||||||
continue
|
continue
|
||||||
if any(i not in ev_kwargs for i in kwargs):
|
if kwargs is not None and any(i not in ev_kwargs for i in kwargs):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -164,7 +164,7 @@ class QubesTestCase(unittest.TestCase):
|
|||||||
self.fail('event {!r} did not fire on {!r}'.format(event, emitter))
|
self.fail('event {!r} did not fire on {!r}'.format(event, emitter))
|
||||||
|
|
||||||
|
|
||||||
def assertEventNotFired(self, emitter, event, args=[], kwargs=[]):
|
def assertEventNotFired(self, emitter, event, args=None, kwargs=None):
|
||||||
'''Check whether event was fired on given emitter. Fail if it did.
|
'''Check whether event was fired on given emitter. Fail if it did.
|
||||||
|
|
||||||
:param emitter: emitter which is being checked
|
:param emitter: emitter which is being checked
|
||||||
@ -179,9 +179,9 @@ class QubesTestCase(unittest.TestCase):
|
|||||||
for ev, ev_args, ev_kwargs in emitter.fired_events:
|
for ev, ev_args, ev_kwargs in emitter.fired_events:
|
||||||
if ev != event:
|
if ev != event:
|
||||||
continue
|
continue
|
||||||
if any(i not in ev_args for i in args):
|
if args is not None and any(i not in ev_args for i in args):
|
||||||
continue
|
continue
|
||||||
if any(i not in ev_kwargs for i in kwargs):
|
if kwargs is not None and any(i not in ev_kwargs for i in kwargs):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.fail('event {!r} did fire on {!r}'.format(event, emitter))
|
self.fail('event {!r} did fire on {!r}'.format(event, emitter))
|
||||||
|
@ -36,12 +36,13 @@ class TestVMM(object):
|
|||||||
|
|
||||||
class TestHost(object):
|
class TestHost(object):
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
def __init__(self, offline_mode=False):
|
def __init__(self):
|
||||||
self.memory_total = 1000
|
self.memory_total = 1000
|
||||||
|
|
||||||
# this probably can be shared and not as dummy as is
|
# this probably can be shared and not as dummy as is
|
||||||
class TestApp(qubes.tests.TestEmitter):
|
class TestApp(qubes.tests.TestEmitter):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
super(TestApp, self).__init__()
|
||||||
self.vmm = TestVMM()
|
self.vmm = TestVMM()
|
||||||
self.host = TestHost()
|
self.host = TestHost()
|
||||||
|
|
||||||
|
@ -141,21 +141,21 @@ class BaseVM(qubes.PropertyHolder):
|
|||||||
|
|
||||||
__metaclass__ = BaseVMMeta
|
__metaclass__ = BaseVMMeta
|
||||||
|
|
||||||
def __init__(self, app, xml, load_stage=2, services={}, devices=None,
|
def __init__(self, app, xml, services=None, devices=None, tags=None,
|
||||||
tags={}, *args, **kwargs):
|
*args, **kwargs):
|
||||||
# pylint: disable=redefined-outer-name
|
# pylint: disable=redefined-outer-name
|
||||||
#: mother :py:class:`qubes.Qubes` object
|
#: mother :py:class:`qubes.Qubes` object
|
||||||
self.app = app
|
self.app = app
|
||||||
|
|
||||||
#: dictionary of services that are run on this domain
|
#: dictionary of services that are run on this domain
|
||||||
self.services = services
|
self.services = services or {}
|
||||||
|
|
||||||
#: :py:class`DeviceManager` object keeping devices that are attached to
|
#: :py:class`DeviceManager` object keeping devices that are attached to
|
||||||
#: this domain
|
#: this domain
|
||||||
self.devices = DeviceManager(self) if devices is None else devices
|
self.devices = DeviceManager(self) if devices is None else devices
|
||||||
|
|
||||||
#: user-specified tags
|
#: user-specified tags
|
||||||
self.tags = tags
|
self.tags = tags or {}
|
||||||
|
|
||||||
self.events_enabled = False
|
self.events_enabled = False
|
||||||
all_names = set(prop.__name__
|
all_names = set(prop.__name__
|
||||||
@ -535,7 +535,8 @@ class BaseVM(qubes.PropertyHolder):
|
|||||||
def has_firewall(self):
|
def has_firewall(self):
|
||||||
return os.path.exists(self.firewall_conf)
|
return os.path.exists(self.firewall_conf)
|
||||||
|
|
||||||
def get_firewall_defaults(self):
|
@staticmethod
|
||||||
|
def get_firewall_defaults():
|
||||||
return {
|
return {
|
||||||
'rules': list(),
|
'rules': list(),
|
||||||
'allow': True,
|
'allow': True,
|
||||||
|
@ -357,7 +357,7 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
@property
|
@property
|
||||||
def uses_custom_config(self):
|
def uses_custom_config(self):
|
||||||
'''True if this machine has config in non-standard place.'''
|
'''True if this machine has config in non-standard place.'''
|
||||||
return not self.property_is_default(self, 'conf_file')
|
return not self.property_is_default('conf_file')
|
||||||
# return self.conf_file != self.storage.abspath(self.name + '.conf')
|
# return self.conf_file != self.storage.abspath(self.name + '.conf')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -585,7 +585,7 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
self.dir_path = self.dir_path.replace(
|
self.dir_path = self.dir_path.replace(
|
||||||
'/{}/', '/{}/'.format(old_name, new_name))
|
'/{}/', '/{}/'.format(old_name, new_name))
|
||||||
|
|
||||||
if self.property_is_default(self, 'conf_file'):
|
if self.property_is_default('conf_file'):
|
||||||
new_conf = os.path.join(
|
new_conf = os.path.join(
|
||||||
self.dir_path, _default_conf_file(self, old_name))
|
self.dir_path, _default_conf_file(self, old_name))
|
||||||
old_conf = os.path.join(
|
old_conf = os.path.join(
|
||||||
@ -746,14 +746,14 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
|
|
||||||
if self._start_guid_first and start_guid and not preparing_dvm \
|
if self._start_guid_first and start_guid and not preparing_dvm \
|
||||||
and os.path.exists('/var/run/shm.id'):
|
and os.path.exists('/var/run/shm.id'):
|
||||||
self.start_guid(notify_function=notify_function)
|
self.start_guid()
|
||||||
|
|
||||||
if not preparing_dvm:
|
if not preparing_dvm:
|
||||||
self.start_qrexec_daemon(notify_function=notify_function)
|
self.start_qrexec_daemon()
|
||||||
|
|
||||||
if start_guid and not preparing_dvm \
|
if start_guid and not preparing_dvm \
|
||||||
and os.path.exists('/var/run/shm.id'):
|
and os.path.exists('/var/run/shm.id'):
|
||||||
self.start_guid(notify_function=notify_function)
|
self.start_guid()
|
||||||
|
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
@ -881,7 +881,7 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
|
|
||||||
if gui and os.getenv("DISPLAY") is not None \
|
if gui and os.getenv("DISPLAY") is not None \
|
||||||
and not self.is_guid_running():
|
and not self.is_guid_running():
|
||||||
self.start_guid(verbose=verbose, notify_function=notify_function)
|
self.start_guid()
|
||||||
|
|
||||||
args = [qubes.config.system_path['qrexec_client_path'],
|
args = [qubes.config.system_path['qrexec_client_path'],
|
||||||
'-d', str(self.name),
|
'-d', str(self.name),
|
||||||
@ -957,7 +957,7 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def start_guid(self, extra_guid_args=[]):
|
def start_guid(self, extra_guid_args=None):
|
||||||
'''Launch gui daemon.
|
'''Launch gui daemon.
|
||||||
|
|
||||||
GUI daemon securely displays windows from domain.
|
GUI daemon securely displays windows from domain.
|
||||||
@ -972,6 +972,7 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
'-c', self.label.color,
|
'-c', self.label.color,
|
||||||
'-i', self.label.icon_path,
|
'-i', self.label.icon_path,
|
||||||
'-l', str(self.label.index)]
|
'-l', str(self.label.index)]
|
||||||
|
if extra_guid_args is not None:
|
||||||
guid_cmd += extra_guid_args
|
guid_cmd += extra_guid_args
|
||||||
|
|
||||||
if self.debug:
|
if self.debug:
|
||||||
@ -1059,7 +1060,7 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
source_template = self.template
|
source_template = self.template
|
||||||
assert source_template is not None
|
assert source_template is not None
|
||||||
|
|
||||||
self.storage.create_on_disk(verbose, source_template)
|
self.storage.create_on_disk(source_template)
|
||||||
|
|
||||||
if self.updateable:
|
if self.updateable:
|
||||||
kernels_dir = source_template.kernels_dir
|
kernels_dir = source_template.kernels_dir
|
||||||
|
Loading…
Reference in New Issue
Block a user