> @@ -0,0 +1,82 @@
> +#
> +# Copyright (C) 2016 Red Hat, Inc.
> +#
> +# This copyrighted material is made available to anyone wishing to use,
> +# modify, copy, or redistribute it subject to the terms and conditions of
> +# the GNU General Public License v.2, or (at your option) any later version.
> +# This program is distributed in the hope that it will be useful, but WITHOUT
> +# ANY WARRANTY expressed or implied, including the implied warranties of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
> +# Public License for more details. You should have received a copy of the
> +# GNU General Public License along with this program; if not, write to the
> +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
> +# source code or documentation are not subject to the GNU General Public
> +# License and may only be used or replicated with the express permission of
> +# Red Hat, Inc.
> +#
> +# Red Hat Author(s): David Lehman <dlehman(a)redhat.com>
> +#
> +import dbus
> +
> +from .constants import DEVICE_INTERFACE, DEVICE_OBJECT_PATH_BASE
> +from .object import DBusObject
> +
> +
> +class DBusDevice(DBusObject):
> + def __init__(self, device):
> + self._device = device
> + self._object_path = self.get_object_path_by_id(self._device.id)
> + super().__init__()
> +
> + @staticmethod
> + def get_object_path_by_id(object_id):
> + return "%s/%d" % (DEVICE_OBJECT_PATH_BASE, object_id)
> +
> + @property
> + def object_path(self):
> + return self._object_path
> +
> + @property
> + def interface(self):
> + return DEVICE_INTERFACE
> +
> + @property
> + def properties(self):
> + props = {"Name": self._device.name,
> + "Path": self._device.path,
> + "Type": self._device.type,
> + "Size": dbus.UInt64(self._device.size),
> + "ID": self._device.id,
> + "UUID": self._device.uuid or "",
> + "Status": self._device.status or False,
> + "RaidLevel": self._get_raid_level(),
> + "Parents": dbus.Array((self.get_object_path_by_id(d.id) for d in self._device.parents), signature='s'),
> + "Children": dbus.Array((self.get_object_path_by_id(d.id) for d in self._device.children), signature='s'),
You're correct. Nice catch. I forgot to update the signature when I changed the value.
--
To view this pull request on github, visit https://github.com/rhinstaller/blivet/pull/392#discussion_r61597741
> @@ -100,9 +100,13 @@ def ResolveDevice(self, spec):
> """ Return a string describing the device the given specifier resolves to. """
> device = self._blivet.devicetree.resolve_device(spec)
> object_path = ""
> - if device is not None:
> - dbus_device = next(d for d in self._dbus_devices if d._device == device)
> - object_path = dbus_device.object_path
> + if device is None:
> + raise dbus.exceptions.DBusException('%s.DeviceLookupFailed' % BUS_NAME,
> + 'No device was found that matches the device '
> + 'descriptor "%s".' % spec)
> +
> + dbus_device = next(d for d in self._dbus_devices if d._device == device)
> + object_path = dbus_device.object_path
Either an exception or ``'/'`` as that's what other DBus APIs do in cases like this. On the other hand I think returning ``'/'`` would make more sense if the method was called like ``FindDevice()``. ``ResolveDevice()`` can consider the device not existing an exception.
--
To view this pull request on github, visit https://github.com/rhinstaller/blivet/pull/396#discussion_r61597106
mock doesn't pull in sane language packs on new rawhide chroots
Also, pocketlint (which will pull in polib) is required for 'make scratch'
--
To view this pull request on github, visit https://github.com/rhinstaller/anaconda/pull/612