a >hg @sjdZdZddlZddlZddlZddlmZddlmZdZ dZ e e e dd Z e Z Gd d d ZdS) zu This module houses the i18n setup and message function. The default is to use gettext to internationalize messages. z4.10.1N)ArgumentParser) SosListOptionz/usr/share/localesoscCs tt|SN)gettextdgettext gettext_app)msgr 0/usr/lib/python3.9/site-packages/sos/__init__.py_defaultsr c@s0eZdZdZddZddZddZdd Zd S) SoSaRMain 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 Cs ||_ddl}ddl}ddl}ddl}|jjdgf|jjddgf|j j gf|j j gfd|_ z ddl}|jjdgf|j d<Wnrty}zZddl}dt|jvr|jjgf|j d<n$d t|jvr|jjgf|j d<nWYd}~n d}~00d }|j D]F\}}|d }|d|d |}|dj} |d |d| d7}qd} | |} d} t| | d|_|jddt|jj dddd|_!d|j!_"|j D]h\} }|j!j#| |d d| d} d| d| _$| ddt|%| |dj&| d| j'| dq|j(|j|_)|*dS)NrZrepcleanermask)reportZcleanhelpupload collectorZcollectz sos.collectorZpexpectz,  z<30 z6%(prog)s [options] Available components: z1See `sos --help` for more information)usageepilogactionextend componentzsos component to run)destmetavarrTzsos )aliasesprogz [options])parser)r)+cmdlineZ sos.reportZ sos.cleanerZsos.helpZ sos.uploadrZ SoSReportrZ SoSCleanerrZ SoSHelperrZ SoSUpload _componentsZ sos.collectorrZ SoSCollectorModuleNotFoundErrorZ sos.missingstrr missingZMissingCollectZMissingPexpectitemsinsertjoindescrr!registerradd_subparsersZ subparsersrequired add_parserr_add_common_optionsZadd_parser_options set_defaults parse_argsargs_init_component)selfr2rerrZ _com_stringZcomvaluer_comr*Z usage_stringrcompZ_com_subparserr r r __init__/sj        z SoS.__init__c Cs|d}|jddddd|jdtdd d d d |jd dddd|jddddddd|jddddddd|jdddddd|jdddd d!td"d#|jd$d%d&d'd(d)d|jd*d+d,gd-d.d/|}|jd0ddd1d|jd2d3d4|jd5d6d4dS)7z@Adds the options shared across components to the parser zGlobal Optionsz--batchF store_truezDo not prompt interactively)defaultrrz --config-filestoreZ config_filez/etc/sos/sos.confz$specify alternate configuration file)typerrr;rz--debugdebugz6enable interactive debugging using the python debugger)rrrz-qz--quietquietzonly print fatal errors)rrr;rz-sz --sysrootZsysrootNz!system rootdir path (default='/')z --tmp-dirZtmp_dirz%specify alternate temporary directoryz-tz --threadsthreadszNumber of threads to use)rrr;r=rz-vz --verbosecount verbosityrzincrease verbosityz-zz--compression-typeZcompression_type)autogzipxzzcompression technology to use)rchoicesrz --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)rz--encrypt-passz$Encrypt the archive using a password)add_argument_group add_argumentr%intadd_mutually_exclusive_group)r4r!Z global_grpZ encrypt_grpr r r r/xs`         zSoS._add_common_optionsc Cs|jj}||jvr"td|dz@|j|d}|jrLtdksLtd||j|j|j |_ WnNty}z6td|d||jj r|t dWYd}~n d}~00dS) znDetermine which component has been requested by the user, and then initialize that component. zUnknown subcommand 'z ' specifiedrz*Component must be run with root privilegeszCould not initialize 'z': rN)r2rr#printZ root_requiredosgetuid Exceptionr!r" _componentr>sysexit)r4r7Z_to_loadr5r r r r3s zSoS._init_componentcCs|jdSr)rPexecute)r4r r r rSsz SoS.executeN)__name__ __module__ __qualname____doc__r9r/r3rSr r r r r &s I/r )rW __version__rMrQrargparserZ sos.optionsrZ gettext_dirrbindtextdomainr Z_sosr r r r r  s