Mini Shell

Direktori : /proc/self/root/lib/python3.6/site-packages/blivet/dbus/__pycache__/
Upload File :
Current File : //proc/self/root/lib/python3.6/site-packages/blivet/dbus/__pycache__/blivet.cpython-36.pyc

3

{)c�(�@s�ddlZddlZddlmZddlmZddlmZmZmZddlm	Z	m
Z
ddlmZddl
mZdd	lmZd
dlmZd
dlmZmZmZd
d
lmZd
dlmZd
dlmZdd�ZGdd�de�ZdS)�N�)�Blivet)�	callbacks)�DEVICE_TYPE_PARTITION�DEVICE_TYPE_LVM�DEVICE_TYPE_LVM_THINP)�DEVICE_TYPE_MD�DEVICE_TYPE_BTRFS)�StorageError)�Size)�ObjectID�)�
DBusAction)�BLIVET_INTERFACE�BLIVET_OBJECT_PATH�BUS_NAME)�
DBusDevice)�
DBusFormat)�
DBusObjectcCst|dd�d�}dd�|D�S)NcSs|jS)N)�id)�o�r�/usr/lib/python3.6/blivet.py�<lambda>'sz/sorted_object_paths_from_list.<locals>.<lambda>)�keycSsg|]
}|j�qSr)�object_path)�.0rrrr�
<listcomp>(sz1sorted_object_paths_from_list.<locals>.<listcomp>)�sorted)Zobj_list�objectsrrr�sorted_object_paths_from_list&sr csfeZdZdZ�fdd�Zdd�Zedd��Zedd	��Zed
d��Z	edd
��Z
d:dd�Zdd�Zd;dd�Z
dd�Zdd�Zdd�Zdd�Zd<dd�Zd=d d!�Zejjed"�d#d$��Zejjed"�d%d&��Zejjed'd(�d)d*��Zejjed+d,d-�d.d/��Zejjed,d0�d1d2��Zejjed,d0�d3d4��Zejjed"�d5d6��Zejjed7d,d-�d8d9��Z�Z S)>�
DBusBlivetz� This class provides the main entry point to the Blivet1 service.

        It provides methods for controlling the blivet service and querying its
        state.
    cs:tt|�j|�t�|_t�j|_|jj	|�|j
�dS)N)�superr!�__init__r�_blivetrr�_id�_manager�
add_object�_set_up_callbacks)�selfZmanager)�	__class__rrr#1s

zDBusBlivet.__init__cCsftjj|j�tjj|j�tjj|j�tjj|j	�tj
j|j�tjj|j
�tjj|j�dS)N)rZdevice_added�add�
_device_addedZdevice_removed�_device_removedZformat_added�
_format_addedZformat_removed�_format_removedZaction_added�
_action_addedZaction_removed�_action_removedZaction_executed�_action_executed)r)rrrr(8szDBusBlivet._set_up_callbackscCs|jS)N)r%)r)rrrrAsz
DBusBlivet.idcCstS)N)r)r)rrrrEszDBusBlivet.object_pathcCstS)N)r)r)rrr�	interfaceIszDBusBlivet.interfacecCs|j�tttttd�}|S)N)ZDevicesrrrrr	)�ListDevicesrrrrr	)r)Zpropsrrr�
propertiesMszDBusBlivet.propertiesTcCs~|jj|jj�}|r.|jr.|j||j|d�n|rJ|rJ|j||jdd�|jj|j�}|jj|�|rzd|_|jj|�dS)z; Update ObjectManager interface after a device is removed. )�keepFN)r&�get_object_by_id�formatr�presentr/�
remove_objectr')r)�devicer6Zremoved_fmt�removedrrrr-Ws

zDBusBlivet._device_removedcCs6|jj|j�}|rd|_nt||j�}|jj|�dS)z9 Update ObjectManager interface after a device is added. TN)r&r7rr9rr')r)r;�addedrrrr,gs
zDBusBlivet._device_addedcCs@|jj|j�}|dkrdS|jj|�|r<d|_|jj|�dS)NF)r&r7rr:r9r')r)r;�fmtr6r<rrrr/rszDBusBlivet._format_removedcCs6|jj|j�}|rd|_nt||j�}|jj|�dS)NT)r&r7rr9rr')r)r;r>r=rrrr.}s
zDBusBlivet._format_addedcCs|jj|j�}|jj|�dS)N)r&r7rr:)r)�actionr<rrrr1�szDBusBlivet._action_removedcCst||j�}|jj|�dS)N)rr&r')r)r?r=rrrr0�szDBusBlivet._action_addedcCsF|jr8|jr|j|jdd�n|jr8|j|j|jdd�|j|�dS)NF)r6)Z
is_destroyZ	is_devicer-r;Z	is_formatr/r8r1)r)r?rrrr2�szDBusBlivet._action_executedFcs$dd�|jjD�}�fdd�|D�S)Ncss|]}t|t�r|VqdS)N)�
isinstancer)r�drrr�	<genexpr>�sz0DBusBlivet._list_dbus_devices.<locals>.<genexpr>csg|]}�s|jr|�qSr)r9)rrA)r<rrr�sz1DBusBlivet._list_dbus_devices.<locals>.<listcomp>)r&r)r)r<Zdbus_devicesr)r<r�_list_dbus_devices�szDBusBlivet._list_dbus_devicescCs`|jj|�}|dks t|t�r6tjjdtd|��|jrZ|rZtjjdtd|��|j	S)z; Return the StorageDevice corresponding to an object path. Nz%s.DeviceNotFoundz&No device found with object path "%s".z6Device with object path "%s" has already been removed.)
r&Zget_object_by_pathr@r�dbus�
exceptions�
DBusExceptionrr9Z_device)r)rr<�dbus_devicerrr�_get_device_by_object_path�sz%DBusBlivet._get_device_by_object_path)�dbus_interfacecCsX|jjdd�}x|D]}|j|dd�qWx|jjjD]}|j|�q8W|jj�dS)z9 Reset the Blivet instance and populate the device tree. NF)r;r6)r$Zdevicesr-�
devicetreeZactionsr1�reset)r)Zold_devicesr<r?rrr�Reset�s
zDBusBlivet.ResetcCstjd�dS)z Stop the blivet service. rN)�sys�exit)r)rrr�Exit�szDBusBlivet.ExitZao)rI�
out_signaturecCst|j��}tj|dd�S)zA Return a list of strings describing the devices in this system. r)Z	signature)r rCrDZArray)r)Zobject_pathsrrrr4�szDBusBlivet.ListDevices�sr)rI�in_signaturerPcCs<|jjj|�}|dkr,tjjdtd|��|jj|j	�j
S)zH Return a string describing the device the given specifier resolves to. Nz%s.DeviceLookupFailedz<No device was found that matches the device descriptor "%s".)r$rJZresolve_devicerDrErFrr&r7rr)r)�specr;rrr�
ResolveDevice�szDBusBlivet.ResolveDevice)rIrRcCs|j|�}|jjj|�dS)z. Remove a device and all devices built on it. N)rHr$rJZrecursive_remove)r)rr;rrr�RemoveDevice�s
zDBusBlivet.RemoveDevicecCs$|j|�|j|�}|jj|�dS)z, Clear a disk and create a disklabel on it. N)rUrHr$Zinitialize_disk)r)rr;rrr�InitializeDisk�s

zDBusBlivet.InitializeDiskcCsXy|jj�WnDtk
rR}z(tjjdt|jjfdt	|���WYdd}~XnXdS)z! Commit pending changes to disk. z%s.%sz9An error occured while committing the changes to disk: %sN)
r$Zdo_itr
rDrErFrr*�__name__�str)r)�errr�Commit�szDBusBlivet.Commitza{sv}cs��fdd�|jdg�D�}||d<|jdd�}|rD�j|�}||d<|jdd�}|dk	rdt|�|d<y�jjf|�}WnDtk
r�}z(tjjdt	|j
jfdt|���WYdd}~XnX|dkr�d}n�j
j|j�j}|S)	Ncsg|]}�j|��qSr)rH)r�p)r)rrr�sz&DBusBlivet.Factory.<locals>.<listcomp>�disksr;�sizez%s.%sz1An error occured while configuring the device: %s�/)�poprHrr$Zfactory_devicer
rDrErFrr*rWrXr&r7rr)r)�kwargsr\rGr;r]rYrr)r)r�Factory�s&
zDBusBlivet.Factory)T)T)F)F)!rW�
__module__�__qualname__�__doc__r#r(�propertyrrr3r5r-r,r/r.r1r0r2rCrHrDZservice�methodrrLrOr4rTrUrVrZra�
__classcell__rr)r*rr!+s0	



	


r!)rMrD�rrZ
devicefactoryrrrrr	�errorsr
r]r�utilrr?rZ	constantsrrrr;rr8r�objectrr r!rrrr�<module>s