a
    !cf                     @   sP  d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ dd	lmZ dd
lmZ ddlZddlZddl	ZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZedZdd Zdd Z eee
fddZ!dd Z"dd Z#dd Z$d ddZ%e&dkrLe%ej'dd dd dS )!z4
Entrance point for the yum command line interface.
    )print_function)absolute_import)unicode_literals)Conf)Cli)OptionParser)ucd)show_lock_owner)_Ndnfc                 C   s&   t jtjjddd t t|  dS )N Texc_info   )loggerlogr   loggingSUBDEBUGcriticalr   e r   0/usr/lib/python3.9/site-packages/dnf/cli/main.py
ex_IOError2   s    r   c                 C   s6   t jtjjddd | jd ur2t tdt|  dS )Nr   Tr   	Error: %sr   )	r   r   r   r   r   valuer   r
   r   r   r   r   r   ex_Error8   s    
r   c              
   C   s  zPt j  t jj|  }t|| ||W  d    W S 1 sB0    Y  W n t jjy } z$t	|j
 t|j W Y d }~dS d }~0  t jjy } zt	|j
 W Y d }~dS d }~0  t jj y } zW Y d }~dS d }~0  t jjy } zt|W  Y d }~S d }~0  tjyZ } z"t	tdt| W Y d }~dS d }~0  tjjy } z"t	tdt| W Y d }~dS d }~0  ty } zt|W  Y d }~S d }~0  ty } z*t	dt|jtd W Y d }~dS d }~0 0 d S )N   r   r   z{}: {}zTerminated.)r   Zi18nZsetup_stdoutcliZBaseCli_main
exceptionsZProcessLockErrorr   r   r   r	   pid	LockErrorDepsolveErrorErrorr   hawkey	Exceptionr
   r   libdnferrorIOErrorr   KeyboardInterruptformattype__name__)argsZ
conf_class	cli_classZoption_parser_classbaser   r   r   r   main?   s4    
4
r1   c              
   C   sj   | j   || }z|ttt||  W n0 ttfy^ } zt|W  Y d}~S d}~0 0 t	|| S )z2Run the dnf program from a command line interface.N)
Z_loggingZ	_presetupZ	configurelistmapr   r)   OSErrorr   cli_run)r0   r.   r/   Zoption_parserr   r   r   r   r   r   \   s    
r   c              
   C   s  zt d}W nH tyT } z0|jtjkr@ttd td W Y d }~nd }~0 0 |	  z| 
  W nF tjjy    Y n0 ttfy } zt|W  Y d }~S d }~0 0 | jjrzt| |}W n tjjy } zt| d}| jjs|jjddr|tdd7 }| jjjrR|s@|td	d
7 }n|tdd
7 }| jjjr| jjd}|tjjkr|s|tdd7 }n|tdd7 }|rtd|  W Y d }~n
d }~0 0 |r|S | j   | jj!S )N.z8No read/execute access in current directory, moving to //r   T)Z	availablez?try to add '{}' to command line to replace conflicting packagesz--allowerasingz.try to add '{}' to skip uninstallable packagesz--skip-brokenz' or '{}' to skip uninstallable packagesbestz7try to add '{}' to use not only best candidate packagesz--nobestz0 or '{}' to use not only best candidate packagesz({}))"openr)   errnoZEACCESr   r   r
   oschdircloserunr   r    r"   r4   r   demands	resolvingr#   r   allow_erasingZ_goalZproblem_conflictsr+   r0   Zconfstrictr8   Z_get_priorityZPRIO_MAINCONFIGinfocommandZrun_transactionZsuccess_exit_status)r   r0   fr   retmsgZprior   r   r   r5   m   s\     





r5   c              
   C   s  |j du r&|| jj ttd | j  g }| jj	durN|
| jj	 z|j|d W n tjjy } ztt| W Y d}~dS d}~0  tjjy } z*| j|D ]}t| qW Y d}~dS d}~0  ty } zt|W  Y d}~S d}~0 0 ttd dS )z9Perform the depsolve, download and RPM transaction stage.NzDependencies resolved.)Zdisplayr   z	Complete!r   )Ztransactionresolver?   rA   r   rC   r
   rD   Zrun_resolvedZtransaction_displayappendZdo_transactionr   r   ZCliErrorr(   r   r    ZTransactionCheckErrorZget_error_outputr   r)   r   )r   r0   ZdisplaysexcerrrG   r   r   r   r   r@      s(    

r@   Fc                 C   s   t | }|rt| |S )ap  Call one of the multiple main() functions based on environment variables.

    :param args: command line arguments passed into yum
    :param exit_code: if *exit_code* is True, this function will exit
       python with its exit code when it has finished executing.
       Otherwise, it will return its exit code.
    :return: the exit code from dnf.yum execution
    )r1   sysexit)r.   	exit_codeZerrcoder   r   r   	user_main   s    

rO   __main__r   T)rN   )F)(__doc__Z
__future__r   r   r   Zdnf.confr   Zdnf.cli.clir   Zdnf.cli.option_parserr   Zdnf.i18nr   Zdnf.cli.utilsr	   r
   Zdnf.clir   Zdnf.exceptionsZdnf.loggingZdnf.utilr:   r%   Zlibdnf.errorr'   r   r;   Zos.pathrL   Z	getLoggerr   r   r   r1   r   r5   r@   rO   r-   argvr   r   r   r   <module>   sB   
5

