Mini Shell

Direktori : /lib/python3.6/site-packages/blivet/tasks/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/blivet/tasks/__pycache__/fsmkfs.cpython-36.pyc

3

{)c%)�@s�ddlZddlZddlmZddlmZmZmZddlm	Z	ddlm
Z
ddlmZdd	lmZeej
�Gd
d�dej��Zeej
�Gdd
�d
eje��ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGd d!�d!e�ZGd"d#�d#e�ZGd$d%�d%e�ZGd&d'�d'e�ZGd(d)�d)eje�Z dS)*�N)�
add_metaclass�)�FSError�FSWriteLabelError�FSWriteUUIDError)�util�)�availability)�fstask)�taskc@s0eZdZejdd�Zejdd�Zejdd�ZdS)�
FSMkfsTaskzwhether this task labels)�doczwhether this task can set UUIDz*whether this task can set nodiscard optionN)�__name__�
__module__�__qualname__�abc�abstractproperty�	can_label�can_set_uuid�
can_nodiscard�rr�/usr/lib/python3.6/fsmkfs.pyr#src@s�eZdZdZdZejdd�Zejdd�Zejdd�Z	ej
dd��Zed	d
��Z
edd��Zed
d��Zedd��Zedd��Zedd��Zddd�Zdd�Zddd�ZdS)�FSMkfsz?An abstract class that represents filesystem creation actions. Zmkfsz&Option for setting a filesystem label.)r
z-Option for setting nodiscrad option for mkfs.zoptions for creating filesystemcCst�dS)z�Return a list of arguments for setting a filesystem UUID.

           :param uuid: the UUID to set
           :type uuid: str
           :rtype: list of str
        N)�NotImplementedError)�self�uuidrrr�
get_uuid_args9szFSMkfs.get_uuid_argscCs
|jdk	S)z� Whether this task can label the filesystem.

            :returns: True if this task can label the filesystem
            :rtype: bool
        N)�label_option)rrrrrEszFSMkfs.can_labelcCs
|jdk	S)z�Whether this task can set the UUID of a filesystem.

           :returns: True if UUID can be set
           :rtype: bool
        N)r)rrrrrNszFSMkfs.can_set_uuidcCs
|jdk	S)z�Whether this task can set nodiscard option for a filesystem.

           :returns: True if nodiscard can be set
           :rtype: bool
        N)�nodiscard_option)rrrrrWszFSMkfs.can_nodiscardcCsX|jdkrgS|jjdkrgS|jj|jj�r<|j|jjgStd|jj|jjf��dS)z� Any labeling options that a particular filesystem may use.

            :returns: labeling options
            :rtype: list of str
        NztChoosing not to apply label (%s) during creation of filesystem %s. Label format is unacceptable for this filesystem.)r�fs�labelZlabel_format_okr�type)rrrr�_label_options`s
zFSMkfs._label_optionscCs |jdkrgS|jjsgS|jS)z� Any nodiscard options that a particular filesystem may use.

            :returns: nodiscard options
            :rtype: list of str
        N)rrZ_mkfs_nodiscard)rrrr�_nodiscard_optionts

zFSMkfs._nodiscard_optioncCsT|jdks|jjdkrgS|jj|jj�r8|j|jj�Std|jj|jjf��dS)z�Any UUID options that a particular filesystem may use.

           :returns: UUID options
           :rtype: list of str
           :raises: FSWriteUUIDError
        NzrChoosing not to apply UUID (%s) during creation of filesystem %s. UUID format is unacceptable for this filesystem.)rrrZuuid_format_okrr!)rrrr�
_uuid_options�szFSMkfs._uuid_optionsNFc	Csz|pg}t|t�std��|r$|jng}|r2|jng}|r@|jng}tj|jj	pRd�}||j
|||||jjgS)aRGet a list of format options to be used when creating the
           filesystem.

           :param options: any special options
           :type options: list of str or None
           :param bool label: if True, label if possible, default is False
           :param bool set_uuid: whether set UUID if possible, default is False
        z!options parameter must be a list.�)�
isinstance�listrr"r$r#�shlex�splitr�create_options�argsZdevice)	r�optionsr �set_uuid�	nodiscardZ
label_optionsZuuid_optionsrr*rrr�_format_options�s	
zFSMkfs._format_optionscCst|j�g|j||||�S)a�Return the command to make the filesystem.

           :param options: any special options
           :type options: list of str or None
           :param label: whether to set a label
           :type label: bool
           :param set_uuid: whether to set an UUID
           :type set_uuid: bool
           :param nodiscard: whether to run mkfs with nodiscard option
           :type nodiscard: bool
           :returns: the mkfs command
           :rtype: list of str
        )�str�extr/)rr,r r-r.rrr�
_mkfs_command�szFSMkfs._mkfs_commandc	Cs~|j}|rtdj|���|pg}|j||||�}ytj|�}Wn*tk
rh}zt|��WYdd}~XnX|rztd|��dS)a�Create the format on the device and label if possible and desired.

           :param options: any special options, may be None
           :type options: list of str or NoneType
           :param bool label: whether to label while creating, default is False
           :param bool set_uuid: whether to set an UUID while creating, default
                                 is False
        �
Nzformat failed: %s)Zavailability_errorsr�joinr2rZrun_program�OSError)	rr,r r-r.Z
error_msgs�cmd�ret�errr�do_task�s
zFSMkfs.do_task)NFFF)NFFF)rrr�__doc__�descriptionrrrrr+�abstractmethodr�propertyrrrr"r#r$r/r2r9rrrrr+s"			
rc@s0eZdZejZdZdgZdd�Ze	dd��Z
dS)�	BTRFSMkfsNz--nodiscardcCsd|gS)Nz-Ur)rrrrrr�szBTRFSMkfs.get_uuid_argscCsgS)Nr)rrrrr+�szBTRFSMkfs.args)rrrr	ZMKFS_BTRFS_APPr1rrrr=r+rrrrr>�s
r>c@s6eZdZejZdZddgZgZdd�Z	e
dd��ZdS)	�
Ext2FSMkfsz-Lz-Er.cCsd|gS)Nz-Ur)rrrrrr�szExt2FSMkfs.get_uuid_argscCs|j|jjrd|jjgngS)Nz-T)�_optsrZ	fsprofile)rrrrr+�szExt2FSMkfs.argsN)rrrr	Z
MKE2FS_APPr1rrr@rr=r+rrrrr?�sr?c@seZdZddgZdS)�
Ext3FSMkfsz-tZext3N)rrrr@rrrrrA�srAc@seZdZddgZdS)�
Ext4FSMkfsz-tZext4N)rrrr@rrrrrB�srBc@s.eZdZejZdZdZdd�Ze	dd��Z
dS)�	FATFSMkfsz-nNcCsd|jdd�gS)Nz-i�-r%)�replace)rrrrrr�szFATFSMkfs.get_uuid_argscCsgS)Nr)rrrrr+szFATFSMkfs.args)rrrr	ZMKDOSFS_APPr1rrrr=r+rrrrrC�s
rCc@s*eZdZejZdZdZdZe	dd��Z
dS)�GFS2MkfsNcCsdddddgS)Nz-j�1z-pZlock_nolockz-Or)rrrrr+
sz
GFS2Mkfs.args)rrrr	Z
MKFS_GFS2_APPr1rrrr=r+rrrrrFs
rFc@s*eZdZejZdZdZdZe	dd��Z
dS)�HFSMkfsz-lNcCsgS)Nr)rrrrr+szHFSMkfs.args)rrrr	ZHFORMAT_APPr1rrrr=r+rrrrrHs
rHc@s*eZdZejZdZdZdZe	dd��Z
dS)�HFSPlusMkfsz-vNcCsgS)Nr)rrrrr+#szHFSPlusMkfs.args)rrrr	ZMKFS_HFSPLUS_APPr1rrrr=r+rrrrrIs
rIc@s*eZdZejZdZdZdZe	dd��Z
dS)�JFSMkfsz-LNcCsdgS)Nz-qr)rrrrr+.szJFSMkfs.args)rrrr	ZMKFS_JFS_APPr1rrrr=r+rrrrrJ(s
rJc@s*eZdZejZdZdZdZe	dd��Z
dS)�NTFSMkfsz-LNcCsddgS)Nz-Fz-fr)rrrrr+9sz
NTFSMkfs.args)rrrr	Z
MKNTFS_APPr1rrrr=r+rrrrrK3s
rKc@s.eZdZejZdZdZdd�Ze	dd��Z
dS)�ReiserFSMkfsz-lNcCsd|gS)Nz-ur)rrrrrrDszReiserFSMkfs.get_uuid_argscCsddgS)Nz-fr)rrrrr+GszReiserFSMkfs.args)rrrr	ZMKREISERFS_APPr1rrrr=r+rrrrrL?s
rLc@s0eZdZejZdZdgZdd�Ze	dd��Z
dS)�XFSMkfsz-Lz-KcCsdd|gS)Nz-mzuuid=r)rrrrrrQszXFSMkfs.get_uuid_argscCsdgS)Nz-fr)rrrrr+TszXFSMkfs.argsN)rrrr	ZMKFS_XFS_APPr1rrrr=r+rrrrrMLs
rMc@s.eZdZejZdZddgZdZe	dd��Z
dS)�F2FSMkfsz-lz-tr.NcCsgS)Nr)rrrrr+_sz
F2FSMkfs.args)rrrr	Z
MKFS_F2FS_APPr1rrrr=r+rrrrrNYs
rNc@s0eZdZedd��Zedd��Zedd��ZdS)�UnimplementedFSMkfscCsdS)NFr)rrrrrfszUnimplementedFSMkfs.can_labelcCsdS)NFr)rrrrrjsz UnimplementedFSMkfs.can_set_uuidcCsdS)NFr)rrrrrnsz!UnimplementedFSMkfs.can_nodiscardN)rrrr=rrrrrrrrOdsrO)!rr(Zsixr�errorsrrrr%rr	r
r�ABCMetaZFSTaskrZBasicApplicationrr>r?rArBrCrFrHrIrJrKrLrMrNZUnimplementedTaskrOrrrr�<module>s4
+