o
    O6uf¦   ã                   @   sŠ   d Z dZddlZddlZddlZddlmZ ddlmZ dZ	dZ
e e
e	¡ dd	„ ZeZze W n ey;   eZY nw G d
d„ dƒZdS )zu
This module houses the i18n setup and message function. The default is to use
gettext to internationalize messages.
z4.7.2é    N)ÚArgumentParser)ÚSosListOptionz/usr/share/localeÚsosc                 C   s   t  t| ¡S ©N)ÚgettextÚdgettextÚgettext_app)Úmsg© r
   ú./usr/lib/python3/dist-packages/sos/__init__.pyÚ_default   s   r   c                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚSoSaR  Main entrypoint for sos from the command line

    Upon intialization, this class loads the basic option parser which will
    include the options shared by support components/subcommands. This is also
    where all subcommands present in the local installation are discovered,
    loaded, and if a matching one is found, intialized.
    c              
   C   s  || _ dd l}dd l}dd l}|jjdgf|jjddgf|jj	g fdœ| _
zdd l}|jjdgf| j
d< W n5 tyj } z)dd l}d|jv rP|jjg f| j
d< nd	|jv r_|jjg f| j
d< n‚ W Y d }~nd }~ww d
}| j
D ]'}| j
| d }| d|¡ d |¡}| j
| d j}|d|d›|› d�7 }qpd}	|	| }	d}
t|	|
d�| _| j ddt¡ | jjdddd�| _d| j_| j
D ]7}| jj|| j
| d d|› �d�}d|› d�|_| ddt¡ |   |¡ | j
| d j!|d� |j"|d� qÀ| j #| j ¡| _$|  %¡  d S )Nr   ÚrepÚcleanerÚmask)ÚreportÚcleanÚhelpÚ	collectorÚcollectzsos.collectorÚpexpectÚ é   z, ú	z<30Ú
z6%(prog)s <component> [options]

Available components:
z1See `sos <component> --help` for more information)ÚusageÚepilogÚactionÚextendÚ	componentzsos component to run)ÚdestÚmetavarr   Tzsos )ÚaliasesÚprogz
 [options])Úparser)r   )&ÚcmdlineÚ
sos.reportÚsos.cleanerÚsos.helpr   Ú	SoSReportr   Ú
SoSCleanerr   Ú	SoSHelperÚ_componentsÚsos.collectorr   ÚSoSCollectorÚModuleNotFoundErrorÚsos.missingr	   ÚmissingÚMissingCollectÚMissingPexpectÚinsertÚjoinÚdescr   r$   Úregisterr   Úadd_subparsersÚ
subparsersÚrequiredÚ
add_parserr   Ú_add_common_optionsÚadd_parser_optionsÚset_defaultsÚ
parse_argsÚargsÚ_init_component)Úselfr@   r   ÚerrÚ_com_stringÚcomr"   Ú_comr6   Úusage_stringr   ÚcompÚ_com_subparserr
   r
   r   Ú__init__5   sj   
ýÿ

€ö

ý
ý
zSoS.__init__c              	   C   s  |  d¡}|jddddd� |jdtdd	d
dd� |jddddd� |jddddddd� |jddddddd� |jdddddd� |jdddd d!td"d#� |jd$d%d&d'd(d)d� |jd*d+d,g d-¢d.d/� | ¡ }|jd0ddd1d� |jd2d3d4� |jd5d6d4� dS )7z@Adds the options shared across components to the parser
        zGlobal Optionsz--batchFÚ
store_truezDo not prompt interactively)Údefaultr   r   z--config-fileÚstoreÚconfig_filez/etc/sos/sos.confz$specify alternate configuration file)Útyper   r    rL   r   z--debugÚdebugz6enable interactive debugging using the python debugger)r   r    r   z-qz--quietÚquietzonly print fatal errors)r   r    rL   r   z-sz	--sysrootÚsysrootNz!system rootdir path (default='/')z	--tmp-dirÚtmp_dirz%specify alternate temporary directoryz-tz	--threadsÚthreadsé   zNumber of threads to use)r   r    rL   rO   r   z-vz	--verboseÚcountÚ	verbosityr   zincrease verbosityz-zz--compression-typeÚcompression_type)ÚautoÚgzipÚxzzcompression technology to use)r    Úchoicesr   z	--encryptz_Encrypt the archive, either prompting for a password/key or referencing an environment variablez--encrypt-keyz(Encrypt the archive using a GPG key-pair)r   z--encrypt-passz$Encrypt the archive using a password)Úadd_argument_groupÚadd_argumentÚstrÚintÚadd_mutually_exclusive_group)rB   r$   Ú
global_grpÚencrypt_grpr
   r
   r   r<   |   s`   

ÿ
ý
ÿ
þ
þ
þ
þ
þýþÿ
ÿzSoS._add_common_optionsc              
   C   sº   | j j}|| j ¡ vrtd|› d�ƒ z!| j| d }|jr(t ¡ dks(tdƒ‚|| j	| j | j
ƒ| _W dS  ty\ } ztd|› d|› �ƒ | j jrL|‚t d¡ W Y d}~dS d}~ww )	znDetermine which component has been requested by the user, and then
        initialize that component.
        zUnknown subcommand 'z' specifiedr   z*Component must be run with root privilegeszCould not initialize 'z': r   N)r@   r   r,   ÚkeysÚprintÚroot_requiredÚosÚgetuidÚ	Exceptionr$   r%   Ú
_componentrP   ÚsysÚexit)rB   rF   Ú_to_loadrC   r
   r
   r   rA   «   s   €üzSoS._init_componentc                 C   s   | j  ¡  d S r   )rj   Úexecute)rB   r
   r
   r   rn   ¾   s   zSoS.executeN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rJ   r<   rA   rn   r
   r
   r
   r   r   ,   s    G/r   )rr   Ú__version__rg   rk   r   Úargparser   Úsos.optionsr   Úgettext_dirr   Úbindtextdomainr   Ú_sosr/   Ú	NameErrorÚImportErrorr   r
   r
   r
   r   Ú<module>   s$   ÿ