Rename '_do_qubesd_call' to 'qubesd_call'
This method don't need to be private. Also the 'do_' prefix is superfluous - methods typically do something. QubesOS/qubes-issues#853
This commit is contained in:
parent
58c940b5c0
commit
745d16a879
@ -47,7 +47,7 @@ class PropertyHolder(object):
|
|||||||
self._properties = None
|
self._properties = None
|
||||||
self._properties_help = None
|
self._properties_help = None
|
||||||
|
|
||||||
def _do_qubesd_call(self, dest, method, arg=None, payload=None):
|
def qubesd_call(self, dest, method, arg=None, payload=None):
|
||||||
'''
|
'''
|
||||||
Call into qubesd using appropriate mechanism. This method should be
|
Call into qubesd using appropriate mechanism. This method should be
|
||||||
defined by a subclass.
|
defined by a subclass.
|
||||||
@ -60,7 +60,7 @@ class PropertyHolder(object):
|
|||||||
'''
|
'''
|
||||||
# have the actual implementation at Qubes() instance
|
# have the actual implementation at Qubes() instance
|
||||||
if self.app:
|
if self.app:
|
||||||
return self.app._do_qubesd_call(dest, method, arg, payload)
|
return self.app.qubesd_call(dest, method, arg, payload)
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def _parse_qubesd_response(self, response_data):
|
def _parse_qubesd_response(self, response_data):
|
||||||
@ -81,7 +81,7 @@ class PropertyHolder(object):
|
|||||||
|
|
||||||
def property_list(self):
|
def property_list(self):
|
||||||
if self._properties is None:
|
if self._properties is None:
|
||||||
properties_str = self._do_qubesd_call(
|
properties_str = self.qubesd_call(
|
||||||
self._method_dest,
|
self._method_dest,
|
||||||
self._method_prefix + 'List',
|
self._method_prefix + 'List',
|
||||||
None,
|
None,
|
||||||
@ -93,7 +93,7 @@ class PropertyHolder(object):
|
|||||||
def property_is_default(self, item):
|
def property_is_default(self, item):
|
||||||
if item.startswith('_'):
|
if item.startswith('_'):
|
||||||
raise AttributeError(item)
|
raise AttributeError(item)
|
||||||
property_str = self._do_qubesd_call(
|
property_str = self.qubesd_call(
|
||||||
self._method_dest,
|
self._method_dest,
|
||||||
self._method_prefix + 'Get',
|
self._method_prefix + 'Get',
|
||||||
item,
|
item,
|
||||||
@ -108,7 +108,7 @@ class PropertyHolder(object):
|
|||||||
def __getattr__(self, item):
|
def __getattr__(self, item):
|
||||||
if item.startswith('_'):
|
if item.startswith('_'):
|
||||||
raise AttributeError(item)
|
raise AttributeError(item)
|
||||||
property_str = self._do_qubesd_call(
|
property_str = self.qubesd_call(
|
||||||
self._method_dest,
|
self._method_dest,
|
||||||
self._method_prefix + 'Get',
|
self._method_prefix + 'Get',
|
||||||
item,
|
item,
|
||||||
@ -123,7 +123,7 @@ class PropertyHolder(object):
|
|||||||
if key.startswith('_') or key in dir(self):
|
if key.startswith('_') or key in dir(self):
|
||||||
return super(PropertyHolder, self).__setattr__(key, value)
|
return super(PropertyHolder, self).__setattr__(key, value)
|
||||||
if value is DEFAULT:
|
if value is DEFAULT:
|
||||||
self._do_qubesd_call(
|
self.qubesd_call(
|
||||||
self._method_dest,
|
self._method_dest,
|
||||||
self._method_prefix + 'Reset',
|
self._method_prefix + 'Reset',
|
||||||
key,
|
key,
|
||||||
@ -131,7 +131,7 @@ class PropertyHolder(object):
|
|||||||
else:
|
else:
|
||||||
if isinstance(value, qubesmgmt.vm.QubesVM):
|
if isinstance(value, qubesmgmt.vm.QubesVM):
|
||||||
value = value._name
|
value = value._name
|
||||||
self._do_qubesd_call(
|
self.qubesd_call(
|
||||||
self._method_dest,
|
self._method_dest,
|
||||||
self._method_prefix + 'Set',
|
self._method_prefix + 'Set',
|
||||||
key,
|
key,
|
||||||
@ -140,7 +140,7 @@ class PropertyHolder(object):
|
|||||||
def __delattr__(self, name):
|
def __delattr__(self, name):
|
||||||
if name.startswith('_') or name in dir(self):
|
if name.startswith('_') or name in dir(self):
|
||||||
return super(PropertyHolder, self).__delattr__(name)
|
return super(PropertyHolder, self).__delattr__(name)
|
||||||
self._do_qubesd_call(
|
self.qubesd_call(
|
||||||
self._method_dest,
|
self._method_dest,
|
||||||
self._method_prefix + 'Reset',
|
self._method_prefix + 'Reset',
|
||||||
name
|
name
|
||||||
|
@ -37,7 +37,7 @@ class VMCollection(object):
|
|||||||
def refresh_cache(self, force=False):
|
def refresh_cache(self, force=False):
|
||||||
if not force and self._vm_list is not None:
|
if not force and self._vm_list is not None:
|
||||||
return
|
return
|
||||||
vm_list_data = self.app._do_qubesd_call(
|
vm_list_data = self.app.qubesd_call(
|
||||||
'dom0',
|
'dom0',
|
||||||
'mgmt.vm.List'
|
'mgmt.vm.List'
|
||||||
)
|
)
|
||||||
@ -83,7 +83,7 @@ class QubesBase(qubesmgmt.PropertyHolder):
|
|||||||
|
|
||||||
|
|
||||||
class QubesLocal(QubesBase):
|
class QubesLocal(QubesBase):
|
||||||
def _do_qubesd_call(self, dest, method, arg=None, payload=None):
|
def qubesd_call(self, dest, method, arg=None, payload=None):
|
||||||
try:
|
try:
|
||||||
client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
client_socket.connect(QUBESD_SOCK)
|
client_socket.connect(QUBESD_SOCK)
|
||||||
@ -103,7 +103,7 @@ class QubesLocal(QubesBase):
|
|||||||
|
|
||||||
|
|
||||||
class QubesRemote(QubesBase):
|
class QubesRemote(QubesBase):
|
||||||
def _do_qubesd_call(self, dest, method, arg=None, payload=None):
|
def qubesd_call(self, dest, method, arg=None, payload=None):
|
||||||
service_name = method
|
service_name = method
|
||||||
if arg is not None:
|
if arg is not None:
|
||||||
service_name += '+' + arg
|
service_name += '+' + arg
|
||||||
|
@ -34,7 +34,7 @@ class QubesTest(qubesmgmt.app.QubesBase):
|
|||||||
#: actual calls made
|
#: actual calls made
|
||||||
self.actual_calls = []
|
self.actual_calls = []
|
||||||
|
|
||||||
def _do_qubesd_call(self, dest, method, arg=None, payload=None):
|
def qubesd_call(self, dest, method, arg=None, payload=None):
|
||||||
call_key = (dest, method, arg, payload)
|
call_key = (dest, method, arg, payload)
|
||||||
self.actual_calls.append(call_key)
|
self.actual_calls.append(call_key)
|
||||||
if call_key not in self.expected_calls:
|
if call_key not in self.expected_calls:
|
||||||
|
Loading…
Reference in New Issue
Block a user