Add missing docstrings, require them by pylint

This commit is contained in:
Marek Marczykowski-Górecki 2017-02-25 20:56:31 +01:00
parent 61cb9887af
commit 3e73b242d1
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
6 changed files with 34 additions and 4 deletions

View File

@ -7,8 +7,7 @@ ignore=tests
disable=
bad-continuation,
fixme,
locally-disabled,
missing-docstring
locally-disabled
[REPORTS]

View File

@ -18,6 +18,7 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.
'''Qubes OS management client.'''
import os
import qubesmgmt.base

View File

@ -18,8 +18,12 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.
import socket
'''
Main Qubes() class and related classes.
'''
import socket
import subprocess
import qubesmgmt.base
@ -29,7 +33,9 @@ import qubesmgmt.exc
QUBESD_SOCK = '/var/run/qubesd.sock'
BUF_SIZE = 4096
class VMCollection(object):
'''Collection of VMs objects'''
def __init__(self, app):
self.app = app
self._vm_list = None
@ -72,6 +78,7 @@ class VMCollection(object):
yield self[vm]
def keys(self):
'''Get list of VM names.'''
self.refresh_cache()
return self._vm_list.keys()
@ -88,6 +95,10 @@ class QubesBase(qubesmgmt.base.PropertyHolder):
class QubesLocal(QubesBase):
'''Application object communicating through local socket.
Used when running in dom0.
'''
def qubesd_call(self, dest, method, arg=None, payload=None):
try:
client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
@ -108,6 +119,10 @@ class QubesLocal(QubesBase):
class QubesRemote(QubesBase):
'''Application object communicating through qrexec services.
Used when running in VM.
'''
def qubesd_call(self, dest, method, arg=None, payload=None):
service_name = method
if arg is not None:

View File

@ -17,11 +17,15 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.
'''Base classes for managed objects'''
import ast
import qubesmgmt.exc
DEFAULT = object()
class PropertyHolder(object):
'''A base class for object having properties retrievable using mgmt API.
@ -60,6 +64,11 @@ class PropertyHolder(object):
@staticmethod
def _parse_qubesd_response(response_data):
'''Parse response from qubesd.
In case of success, return actual data. In case of error,
raise appropriate exception.
'''
if response_data[0:2] == b'\x30\x00':
return response_data[2:]
elif response_data[0:2] == b'\x32\x00':

View File

@ -18,8 +18,11 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.
class QubesException(Exception):
'''Exception hierarchy.'''
class QubesException(Exception):
'''Base exception for all Qubes-related errors.'''
def __init__(self, message_format, *args, **kwargs):
# TODO: handle translations
super(QubesException, self).__init__(message_format % args, **kwargs)

View File

@ -18,10 +18,13 @@
# You should have received a copy of the GNU General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.
'''Qubes VM objects.'''
import qubesmgmt.base
class QubesVM(qubesmgmt.base.PropertyHolder):
'''Qubes domain.'''
def __init__(self, app, name, vm_class):
self._class = vm_class
super(QubesVM, self).__init__(app, 'mgmt.vm.property.', name)