PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB`  $^c@sdZddlZddlZddlZddlZddlmZddlmZddlm Z ddl m Z dZ dZ d ZejeZd efd YZd efd YZdS(sA common framework for command-line admin tools, e.g. install scripts Handles common operations like option parsing and logging iN(t OptionGroup(tversion(tconfig(tstandard_logging_setupiiit ScriptErrorcBs,eZdZdddZedZRS(sBAn exception that records an error message and a return value ticCs8|dkrd}ntt|j|||_dS(NR(tNonetsuperRt__init__trval(tselftmsgR ((s7/usr/lib/python2.7/site-packages/ipapython/admintool.pyR-s  cCs t|S(N(tstr(R ((s7/usr/lib/python2.7/site-packages/ipapython/admintool.pyR 3s(t__name__t __module__t__doc__RtpropertyR (((s7/usr/lib/python2.7/site-packages/ipapython/admintool.pyR*st AdminToolcBseZdZdZdZdZdZeZ e dZ e e dZ e dZe dZe dZdZdZe dZd Zd d Zd e d Zd ZdZdZdZRS(s~Base class for command-line admin tools To run the tool, call the main() classmethod with a list of command-line arguments. Alternatively, call run_cli() to run with command-line arguments in sys.argv, and call sys.exit() with the return value. Some commands actually represent multiple related tools, e.g. ``ipa-server-install`` and ``ipa-server-install --uninstall`` would be represented by separate classes. Only their options are the same. To handle this, AdminTool provides classmethods for option parsing and selecting the appropriate command class. A class-wide option parser is made by calling add_options. The options are then parsed into options and arguments, and get_command_class is called with those to retrieve the class. That class is then instantiated and run. Running consists of a few steps: - validating options or the environment (validate_options) - setting up logging (setup_logging) - running the actual command (run) Any unhandled exceptions are handled in handle_error. And at the end, either log_success or log_failure is called. Class attributes to define in subclasses: command_name - shown in logs log_file_name - if None, logging is to stderr only usage - text shown in help description - text shown in help See the setup_logging method for more info on logging. c CsMtjdtjd|jdtjd|j}||_|j|dS(sACreate an option parser shared across all instances of this classRtusaget formattert descriptionN( RtIPAOptionParserRtVERSIONRt IPAFormatterRt option_parsert add_options(tclstparser((s7/usr/lib/python2.7/site-packages/ipapython/admintool.pyt make_parsercs   c Cst|d}|jdddddtddd d |rh|jd d dddtddd d n|jdddddtddd d|jdddddddd d|j|dS(sAdd command-specific options to the option parser :param parser: The parser to add options to :param debug_option: Add a --debug option as an alias to --verbose sLogging and output optionss-vs --verbosetdesttverbosetdefaulttactiont store_truethelpsprint debugging informations-ds--debugs alias for --verbose (deprecated)s-qs--quiettquietsoutput only errorss --log-filetlog_filetmetavartFILEslog to the given fileN(Rt add_optiontFalseRtadd_option_group(RRt debug_optiontgroup((s7/usr/lib/python2.7/site-packages/ipapython/admintool.pyRls   cCstj|jtjdS(sKRun this command with sys.argv, exit process with the return value N(tsystexittmaintargv(R((s7/usr/lib/python2.7/site-packages/ipapython/admintool.pytrun_cliscCss||jkr,|j|j|j|s cCsdS(s*Ask for missing options interactively Similar to validate_options. This is separate method because we want any validation errors to abort the script before bothering the user with prompts. Any options that might be asked for should also be validated here. N((R ((s7/usr/lib/python2.7/site-packages/ipapython/admintool.pyR?stwcCsitj}xF|jD];}t|tjr|jtjkr|j|PqqW|j d|dS(s%Set up logging :param _to_file: Setting this to false will disable logging to file. For internal use. If the --log-file option was given or if a filename is in self.log_file_name, the tool will log to that file. In this case, all messages are logged. What is logged to the console depends on command-line options: the default is INFO; --quiet sets ERROR; --verbose sets DEBUG. Rules of thumb for logging levels: - CRITICAL for fatal errors - ERROR for critical things that the admin must see, even with --quiet - WARNING for things that need to stand out in the log - INFO to display normal messages - DEBUG to spam about everything the program does - a plain print for things that should not be log (for example, interactive prompting) To log, use a module-level logger. Logging to file is only set up after option validation and prompting; before that, all output will go to the console only. t log_file_modeN( tloggingt getLoggerthandlerst isinstancet StreamHandlertstreamR,tstderrt removeHandlerR<(R RPt root_loggerthandler((s7/usr/lib/python2.7/site-packages/ipapython/admintool.pyR@s  c Cs|rd}n$|jjr*|jj}n |j}|jjrTd}t}t}n'd}t}|jjrut}nt}t|d|d|d|d||rt j d|n|st j dndS( Ns$%(name)s: %(levelname)s: %(message)ss %(message)stconsole_formattfilemodetdebugRs Logging to %ssNot logging to a file( RR5R$t log_file_nameRR=R(R#RtloggerR](R RPR;R^R[RR]((s7/usr/lib/python2.7/site-packages/ipapython/admintool.pyR<s*        cCsvt|tr%|j|jp!dfSt|trft|jtrSd|jfSt|jdfSt|dfS(sMGiven an exception, return a message (or None) and process exit code iN( RTRR R t SystemExittcodetintRR (R RH((s7/usr/lib/python2.7/site-packages/ipapython/admintool.pyRDs cCs6tjd|j|j|jtjdtjdS(sNActual running of the command This is where the hard work is done. The base implementation logs the invocation of the command. If this method returns (i.e. doesn't raise an exception), the tool is assumed to have run successfully, and the return value is used as the SystemExit code. s0%s was invoked with arguments %s and options: %ssIPA version %sN(R_R]RMR6R:RtVENDOR_VERSION(R ((s7/usr/lib/python2.7/site-packages/ipapython/admintool.pyRAs cCstjddjtj|tjd|jt|j||r]tjd|nd|j}|j r|dkr|d|j 7}ntjd|dS(Ns%sRs(The %s command failed, exception: %s: %ssThe %s command failed.is See %s for more information( R_R]tjoinRIt format_tbRMttypeR terrorR^(R RJRGRHt backtracetmessage((s7/usr/lib/python2.7/site-packages/ipapython/admintool.pyRE,s"  cCstjd|jdS(NsThe %s command was successful(R_tinfoRM(R ((s7/usr/lib/python2.7/site-packages/ipapython/admintool.pyRF9sN(R RRRRMR^RRtdictR1t classmethodRR(RR0R.R3RR4R>R?R@R<RDRARERF(((s7/usr/lib/python2.7/site-packages/ipapython/admintool.pyR8s,#     $  (RRQR,RKRItoptparseRt ipapythonRRtipapython.ipa_log_managerRtSUCCESStSERVER_INSTALL_ERRORtSERVER_NOT_CONFIGUREDRRR R_t ExceptionRtobjectR(((s7/usr/lib/python2.7/site-packages/ipapython/admintool.pyts