dbfdg 3 ([Qhf @sjdZdZddlZddlZddlZddlmZddlmZdZ dZ ej 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.9.2N)ArgumentParser) SosListOptionz/usr/share/localesoscCs tjt|S)N)gettextdgettext gettext_app)msgr /usr/lib/python3.6/__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. cCs&||_ddl}ddl}ddl}ddl}|jjdgf|jjddgf|j j gf|j j gfd|_ y ddl}|jjdgf|j d<Wnptk r}zTddl}dt|jkr|jjgf|j d<n$d t|jkr|jjgf|j d<nWYdd}~XnXd }xT|j jD]F\}}|d }|jd|d j|}|dj} |d |d| d7}qWd} | |} d} t| | d|_|jjddt|jj dddd|_!d|j!_"xv|j jD]h\} }|j!j#| |d d| d} d| d| _$| jddt|j%| |dj&| d| j'| dqW|jj(|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 SoSReportr Z SoSCleanerrZ SoSHelperrZ SoSUpload _componentsZ sos.collectorrZ SoSCollectorModuleNotFoundErrorZ sos.missingstrrZmissingZMissingCollectZMissingPexpectitemsinsertjoindescrr registerrZadd_subparsersZ subparsersZrequiredZ add_parserr_add_common_optionsZadd_parser_optionsZ set_defaults parse_argsargs_init_component)selfr,rerrZ _com_stringZcomvaluer_comr(Z usage_stringrcompZ_com_subparserr r r __init__/sb       z SoS.__init__c Cs|jd}|jddddd|jdtdd d d d |jd dddd|jddddddd|jddddddd|jdddddd|jdddd d!td"d#|jd$d%d&d'd(d)d|jd*d+d,d-d.d/gd0d1|j}|jd2ddd3d|jd4d5d6|jd7d8d6dS)9z@Adds the options shared across components to the parser zGlobal Optionsz--batchF store_truezDo not prompt interactively)defaultrrz --config-fileZstoreZ config_filez/etc/sos/sos.confz$specify alternate configuration file)typerrr5rz--debugdebugz6enable interactive debugging using the python debugger)rrrz-qz--quietquietzonly print fatal errors)rrr5rz-sz --sysrootZsysrootNz!system rootdir path (default='/')z --tmp-dirZtmp_dirz%specify alternate temporary directoryz-tz --threadsZthreadszNumber of threads to use)rrr5r6rz-vz --verbosecount verbosityrzincrease verbosityz-zz--compression-typeZcompression_typeautoZgzipZxzzcompression 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)Zadd_argument_group add_argumentr$intZadd_mutually_exclusive_group)r.r Z global_grpZ encrypt_grpr r r r*xsH         zSoS._add_common_optionscCs|jj}||jkr"td|dyB|j|d}|jrNtjdk rNtd||j|j|j |_ WnLtk r}z0td|d||jj r|t j dWYdd}~XnXdS) 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)r,rr"printZ root_requiredosgetuid Exceptionr r! _componentr7sysexit)r.r1Z_to_loadr/r r r r-s zSoS._init_componentcCs|jjdS)N)rDexecute)r.r r r rGsz SoS.executeN)__name__ __module__ __qualname____doc__r3r*r-rGr r r r r &s I/r )rK __version__rArErargparserZ sos.optionsrZ gettext_dirrbindtextdomainr Z_sosr r r r r s