3
 a                 @   s   d dl mZ G dd deZG dd deZG dd deZG dd	 d	eZG d
d deZG dd deZG dd deZ	G dd deZ
G dd deZdS )    )statusc               @   s$   e Zd ZdZdZeddddZdS )UserFacingErrorz
    An exception to be raised when an execution-ending error is encountered.

    :param msg:
        Takes a single parameter, which is the user-facing error message that
        should be emitted before exiting non-zero.
       N)msgreturnc             C   s
   || _ d S )N)r   )selfr    r   5/usr/lib/python3/dist-packages/uaclient/exceptions.py__init__   s    zUserFacingError.__init__)__name__
__module____qualname____doc__	exit_codestrr
   r   r   r   r	   r      s   r   c               @   s   e Zd ZdZdS )BetaServiceErrorz
    An exception to be raised trying to interact with beta service
    without the right parameters.

    :param msg:
        Takes a single parameter, which is the beta service error message that
        should be emitted before exiting non-zero.
    N)r   r   r   r   r   r   r   r	   r      s   r   c               @   s   e Zd ZdZdZdS )NonAutoAttachImageErrorz>Raised when machine isn't running an auto-attach enabled imager   N)r   r   r   r   r   r   r   r   r	   r       s   r   c                   s$   e Zd ZdZdZ fddZ  ZS )AlreadyAttachedErrorzDAn exception to be raised when a command needs an unattached system.r   c                s$   t  jtjj|jd d d d S )Nr   name)Zaccount_name)superr
   r   ZMESSAGE_ALREADY_ATTACHEDformatZaccounts)r   cfg)	__class__r   r	   r
   +   s    zAlreadyAttachedError.__init__)r   r   r   r   r   r
   __classcell__r   r   )r   r	   r   &   s   r   c                   s*   e Zd ZdZeeed fddZ  ZS )LockHeldErrora  An exception for when another ua operation is in progress

    :param lock_request: String of the command requesting the lock
    :param lock_holder: String of the command that currently holds the lock
    :param pid: Integer of the process id of the lock_holder
    )lock_requestlock_holderpidc                s4   |}dj |d}|tjj ||d7 }t j| d S )Nz#Unable to perform: {lock_request}.
)r   )r   r   )r   r   ZMESSAGE_LOCK_HELDr   r
   )r   r   r   r   r   )r   r   r	   r
   ;   s    zLockHeldError.__init__)r   r   r   r   r   intr
   r   r   r   )r   r	   r   3   s   r   c                   s    e Zd ZdZ fddZ  ZS )MissingAptURLDirectivez@An exception for when the contract server doesn't include aptURLc                s   t  jtjj|d d S )N)entitlement_name)r   r
   r   Z!MESSAGE_MISSING_APT_URL_DIRECTIVEr   )r   r    )r   r   r	   r
   I   s    zMissingAptURLDirective.__init__)r   r   r   r   r
   r   r   r   )r   r	   r   F   s   r   c                   s&   e Zd ZdZdd fddZ  ZS )NonRootUserErrorz7An exception to be raised when a user needs to be root.N)r   c                s   t  jtj d S )N)r   r
   r   ZMESSAGE_NONROOT_USER)r   )r   r   r	   r
   T   s    zNonRootUserError.__init__)r   r   r   r   r
   r   r   r   )r   r	   r!   Q   s   r!   c                   s.   e Zd ZdZejfedd fddZ  ZS )UnattachedErrorz>An exception to be raised when a machine needs to be attached.N)r   r   c                s   t  j| d S )N)r   r
   )r   r   )r   r   r	   r
   [   s    zUnattachedError.__init__)	r   r   r   r   r   ZMESSAGE_UNATTACHEDr   r
   r   r   r   )r   r	   r"   X   s   r"   c                   s*   e Zd ZdZeedd fddZ  ZS )SecurityAPIMetadataErrorzDAn exception raised with Security API metadata returns invalid data.N)r   issue_idr   c                s&   t  jd| d tjj|d  d S )NzError: 
)Zissue)r   r
   r   Z#MESSAGE_SECURITY_ISSUE_NOT_RESOLVEDr   )r   r   r$   )r   r   r	   r
   b   s    z!SecurityAPIMetadataError.__init__)r   r   r   r   r   r
   r   r   r   )r   r	   r#   _   s   r#   N)uaclientr   	Exceptionr   r   r   r   r   r   r!   r"   r#   r   r   r   r	   <module>   s   