• File: __init__.pyo
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyo
  • Date Modified: 03/28/2024 3:28 PM
  • File size: 24.49 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

fc@s*ddlmZddlmZmZddlmZddlmZddl	Z	ddl
Z
ddlZddlZddlj
jZddlZddlZddlZdZdefdYZd	efd
YZdefdYZd
efdYZdee	jfdYZdS(i(tdeque(tOptionParsertOption(t_(t
set_docstringNs%Keith Robertson <kroberts@redhat.com>t
DisplayOptioncBs#eZdZdZdZdZRS(s
    A simple container class that holds the text to be displayed
    in a numbered menu and the name of the function that should
    be called when the user selects that numbered menu option.
    cCs||_||_dS(N(tdisplay_textt
function_name(tselfRR((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyt__init__+s	N(t__name__t
__module__t__doc__tNoneRRR	(((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyR"stObjectDisplayOptioncBseZdZdZdZRS(s
    A simple container class that holds the text to be displayed
    in a numbered menu and the name of the function that should
    be called when the user selects that numbered menu option.
    cCs tj|||||_dS(N(RR	t
stored_obj(RRRR((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyR	8sN(R
RRR
RR	(((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyR0st
HiddenCommandcBseZdZdZRS(s
    A marker interface for plug-ins that you do not want to show
    to the user.  Simply inherit from this class multiple-inhertance
    style
    cCsdS(N((R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyt__initCs(R
RRt_HiddenCommand__init(((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyR=stPlugincBseZdZdZdZdZdZdZdZ	e
dZe
dZe
dZ
e
dZdZdZdZd	Zd
Ze
dZe
dZe
d
Ze
dZe
dZRS(si
    The base class for plugins.

   Attributes:
    plugin_name  The variable is used by redhat-support-tool
                 as the command which is displayed to the user.
                 Example: Setting 'plugin_name = foobar' will
                 create an executable command named 'foobar'.
                 Example:
                  Welcome to the Red Hat Support Tool.
                  Command (? for help): foobar
                  Command (? for help): help foobar


    _args        The positional arguments on the command line left over
                 from running OptionParser.  Should be used by
                 subclasses to see what the user supplied.
                 Example: addcomment -c 123456 positional_arguments_here

    _options     A dictionary containing the options that were supplied
                 by the user.
                 Example:  addcomment -c 123456 positional_arguments_here
                 results in _options = {'comment': '123456'}

    _line        The unaltered STDIN line from the user


    Methods to override:
     - get_usage (required)
     - get_desc (required)
     - get_epilog (required)
     - get_options (optional depending on your command)
     - validate_args (recommended)
     - postinit (optional)
     - non_interactive_action (required)
     - config_help
     - config-set-option
     - config-get-option
    cCs)d|_d|_d|_|jdS(N(R
t_linet_argst_optionst_init_parser(R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyR	vs			cCsdS(s
        The usage statement that will be printed by OptionParser.

        Example:
            - %prog -c CASENUMBER [options] <comment text here>
        Important: %prog is a OptionParser built-in.  Use it!
        sOVERRIDE ME: Plugin::get_usage((tcls((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyt	get_usages	cCsdS(s
        The description statement that will be printed by OptionParser.

        Example:
            - 'Use the '%s' command to add a comment to a case.'             % cls.plugin_name
        sOVERRIDE ME: Plugin::get_desc((R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pytget_descs	cCsdS(s
        The epilog string that will be printed by OptionParser.  Usually
        used to print an example of how to use the program.

        Example:
         Examples:
          - %s -c 12345678 Lorem ipsum dolor sit amet, consectetur adipisicing
          - %s -c 12345678
        t((R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyt
get_epilogscCsdS(sO
        Subclasses that need command line options should override this method
        and return an array of optparse.Option(s) to be used by the
        OptionParser.

        Example:
         return [Option("-f", "--file", action="store",
                        dest="filename", help='Some file'),
                 Option("-c", "--case",
                        action="store", dest="casenumber",
                        help='A case')]

         Would produce the following:
         Command (? for help): help mycommand

         Usage: mycommand [options]

         Use the 'mycommand' command to find a knowledge base solution by ID
         Options:
           -h, --help  show this help message and exit
           -f, --file  Some file
           -c, --case  A case
         Example:
          - mycommand -c 12345 -f abc.txt

        N(R
(R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pytget_optionsscCstjr0|dkrtj||_qntjd|_tjj	stj|}xQt
|D]@\}}d|krk||ddkrk|jj|PqkqkWn|jj
|j\|_|_||_t|j|_dS(s
        Use this method to parse the arguments supplied by the user.

        This method will parse the given arguments from STDIN via
        the OptionParser.  It will set _args, _options, and _line
        so that subclasses can use them to see what the user provided.
        is.tar.it	sosreportN(tcommontis_interactiveR
tshlextsplitRtsystargvtstdintisattyt	enumeratetappendt_parsert
parse_argsRRtvars(Rtlinetparamstcounttout((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyR*s !	cCsdS(s
        A helper method that will be called by the framework logic after the
        plugin has been instantiated and the args have been processed by
        the base class's OptionParser.  You should place any logic in here
        to test for the requisite number of arguments, etc.

        Throws:
         An exception if _args or _options lack the requisite amount of data
         for the command to operate.

        Returns:
         Nothing

        Example:
        if len(self._args) <= 0:
            msg = _("ERROR: %s requires a knowledge base solution ID. "
                    "Try 'help %s' for more information.") %                         (self.plugin_name,
                         self.plugin_name)
            print msg
            raise Exception(msg)
        N((R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyt
validate_argsscCsdS(s
        This method is called immediately after the validate_args
        method.  The intent is to place logic in here that
        is executed *after* you know that you have the requisite
        args from the user but aren't ready to send anything to
        STDOUT yet.

        This is useful for subclasses that have interactive and
        non-interactive behavior and want to co-locate some init
        logic.
        N((R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pytpostinitscCsdS(s
        This method should be called prior to validate_args, and can
        be used to inject an object from an ObjectDisplayOption by
        LaunchHelper.
        N((Rtobj((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyt
insert_obj
scCs	dGHdS(s_
        This method will be called by redhat-support-tool when the user
        issues the command in a non-interactive mode.

        It will be called after the constructor, postinit, and validate_args.

        All plugin's should implement this method.

        Example:
         redhat-support-tool addcomment -c 12345 'Problem solved!'
        sOVERRIDE ME: Plugin::actionN((R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pytnon_interactive_actionscCs|jr|jS|jjS(s^Returns the plugin's name as a string. This should return a
        lowercase string.
        (tplugin_nameR
tlower(R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pytget_name$s	c	Cstjd dkrjdt_dt_td|jd|jd|jd|j|_	n<d	t_td|jd|jd|j|_	|j
r|j	j|j
nt|j	d
t
|ddS(
NiicSs|jS(N(tepilog(Rt	formatter((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyt<lambda>4scSs|jS(N(tdescription(RR9((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyR:6stusageR;tprogR8cSs|jS(N(R;(RR9((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyR:=sterrort_print_opt_parse_error(ii(R#tversion_infoRt
format_epilogtformat_descriptionRRR7RR)Rtadd_optionstsetattrtgetattr(R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyR0s"	cCs	|GHdS(s
        A utility function to override OptionParser's annoying
        habit of calling sys.exit on invalid parameters.
        N((Rtmsg((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyR?NscCsN|j|jjtjd dkrJ|jdkrJ|jGHndS(sO
        This function will display OptionParser help for the command.
        iiRN(ii(RR)t
print_helpR#R@R(R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pytshow_command_helpVs

%cCsdS(s
        If your plugin stores any options that can be set by the user
        override this function and return a string containing the options,
        one per line, with the option name and a description, including
        any default values.

        Example:

        return " %-10s: %-67s
" % ('url',
            _('The support services URL.  Default=%s') % self.DEFAULT_URL)

        R((R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pytconfig_helpesN(R
RRR
R5RRR)RR	tclassmethodRRRRR*R0R1R3R4R7RR?RHRI(((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyRGs*'							tInteractivePlugincBseZdZedZedZedZedZedZeZ	eZ
eZeZeZ
dZeZeZeedZdZd	Zd
ZdZdZd
ZdZdZdZdZeeddZdZ eeddZ!eeddZ"eeddZ#dZ$dZ%eeddZ&dZ'RS(sw
    A helper class for plug-ins that need an interactive sub-menu.

    Some plug-ins require an interactive sub-menu (see example 1).
    These plug-ins should inherit from this class and implement the methods
    marked by '# Override this'.  These classes should also
    override the similarly marked methods in Plugin.

    Plug-ins that are subclasses of InteractivePlugin will have their
    superclass's 'cmdloop' function called when the user is running
    redhat-support-tool interactively.  This will allow the user
    to select the options that you have provided.

    Methods to override:
     - get_sub_menu_options (requied)
     - get_intro_text (optional)
     - get_prompt_text (optional)
     - get_more_options (optional)

    Example 1:
     $ redhat-support-tool
    Welcome to the Red Hat Support Tool.
    Command (? for help): <-- This is the main menu
    Command (? for help): listcases

    Type the number of the case to view or 'e' to return to the main menu.
     0   [Closed]              This is just a test
     1   [Waiting on Red Hat]  Test case for strata
     Select a case: <-- This is a sub-menu
    s3Make a selection or 'e' to return to the main menu.sSelection: sEnd of options.sY%s of %s entries printed. Type 'm' to see more, or 'r' to start from the beginning again.sAMore entries may be available. Type 'm' to try and retrieve more.icCs{tjj|tj||dks8||jkrJ|j|_n|dkse||jkrw|j	|_
ndS(s
        Arguments:
         intro_text  - Command specific intro-text which is used when the
                       sub-menu is displayed.
         prompt      - Command specific prompt(eg. Show case:, Select section:,
                       etc.)
        N(tcmdtCmdR	RR
tDEFAULT_INTRO_TEXTtget_intro_textt
intro_texttDEFAULT_PROMPTtget_prompt_texttprompt(RRPRS((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyR	s

cCsdS(s
        Override this method to tell this base class what your sub-menu
        options are.

        Sub-class implementations should return a collections.deque containing
        DisplayOption objects.  Items are printed in the order in which they
        are added.

        Example 1:
         deque.append(DisplayOption('Display Option 1', 'function1')
         deque.append(DisplayOption('Display Option 2', 'function1')

         Produces:
          Make a selection or type 'e' to return to the main menu.
          0   Display Option 1
          1   Display Option 2
          Selection:

        Example 2: A sub-menu:
         $ redhat-support-tool
        Welcome to the Red Hat Support Tool.
        Command (? for help): <-- This is the main menu
        Command (? for help): listcases

        Type the number of the case to view or 'e' to return to the main menu.
         0   [Closed]              This is just a test
         1   [Waiting on Red Hat]  Test case for strata
         Select a case: <-- This is a sub-menu
        N(R
(R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pytget_sub_menu_optionsscCs|jS(s^
        If you want to supply a sub-menu intro text (see example)
        other than the default and you don't want to supply it via
        the constructor.  Override this.

        Example:
        Command (? for help): listcases

        Select a case. <-- This is the submenu intro
         0   [Closed]              This is just a test
        (RN(R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyROscCs|jS(sm
        If you want to supply custom a sub-menu prompt (see example)
        other than the default and you don't want to supply it via
        the constructor.  Override this.

        Example:
        Command (? for help): listcases

        Select a case.
         0   [Closed]              This is just a test
        Selection: <-- this is the prompt
        (RQ(R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyRRs
cCstS(s
        If you want to support fetching of additional records for display
        in the submenu, override this method.

        If there are additional entries get_sub_menu_options() will be
        called to obtain the updated deque() object.

        Returns True if additional entries are available
        Returns False if unsupported, or no additional entries are available
        (tFalse(Rtnum_options((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pytget_more_optionsscCs	tj}t}|j}|j}t}|rPt}|d}|d}nd}d}ttt|}||d}	tj|t|j	tj|t|j
}
|
tj|t|j|j|j
}|
tj|t|j|j|j
}t||||kr<|j||}|j}n|t|krZ|j
GHdS|rq||d}
n	tj}
ttj||d|
|d}g}|j|j	xtj|tj|D]\}}|r_d|||	|jf}tj||dd	|d}t|t|||krBPq|j||d|_qd
|||jf}|j|qWx|D]}|GHqW|jt|kr|j|jdt|fGHn2|jdt|kr|r|jGHn|j
GHdS(s
        This method will call get_sub_menu_options an print them
        to stdout as a selectable list for the user. Generally,
        no need to override this.
        iiiiPiNs
 % *s %-*stsubsequent_indentt s	 % *s %-s(Rtget_terminfoRURTt_sub_menu_indextTruetlentstrt
get_linecountRPRStpartial_entriestmore_entries_maybetend_of_entriesRWR#tmaxinttlistt	itertoolstisliceR(tizipR.Rttextwraptwraptextend(Rtterminfotpaginatetdisplay_opt_dequet
currentpostmoreresultst
termheightt	termwidtht	idx_widtht	opt_widthtintro_prompt_sizetmin_header_sizetmax_header_sizet
lines_to_filltiter_entriest
outputbufftdisplay_opttidxtoutputtoutput_wrappedR,((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyt_print_submenus	

	


		

	

	cCstd|GHdS(NsF%s is an invalid selection. Type 'help' to see valid selections again.(R(RR,((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyt_invalidws	cCsdS(ss
        Override the default implementation of emptyline so
        that the last command isn't repeated.
        N(R
(R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyt	emptyline{scCsKd}yt|}Wnt|j}nX|dksJ|dkrNdS|dks|dks|dks|dks|d	ks|jd
s|jdr|S|t|jkr6|dkr6|d
}|j}t|||j}||||jr2d
|_	|j
t|_ndS|j|dSdS(NitetqtEOFthelpRtmtrt?tshellt!ii(
tintR^tstript
startswithR]RTRERtopts_updatedR[R~RUR(RR,tnumRmtfunc((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pytprecmds6$
		

cCsL|s5|jr%d|_|jqHtj|ntjj||dS(Ni(thelp_is_optionsR[R~Rtdo_helpRLRM(RR,((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyRs		
cCs|jdS(N(R~(RR,((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pytdo_mssShow more options if available.cCsHdjtdgGHdS(Ns
s(Prints additional results. if available.(tjoinR(R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pythelp_mscCsd|_|jdS(Ni(R[R~(RR,((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pytdo_rs	sRestart display of options.cCsHdjtdgGHdS(Ns
s+Restarts display of results from the start.(RR(R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pythelp_rssReturn to previous menu.cCsHdjtdgGHdS(Ns
s8Exit this subcommand shell. CTRL-D and CTRL-C also work.(RR(R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pythelp_escCsH|jdS(N(R(R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pythelp_qscCsHdS(NR((RR,((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pytdo_EOFscCstj|j}|GHdS(N(tostpopentread(RR,R|((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pytdo_shellss-Execute a shell command. You can also use '!'cCs.HdjdtdtdddgGHdS(Ns
s
shell COMMANDs-Execute a shell command. You can also use '!'sExample:s	 shell lss !ls(RR(R((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyt
help_shells			cCs dt|jkrtSdS(NR(R^RR\(RR,((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pytdefaults((R
RRRRNRQtDEFAULT_END_OF_ENTRIEStDEFAULT_PARTIAL_ENTRIEStDEFAULT_MORE_ENTRIES_MAYBERPRSRbR`RaR[R\RRURR	RTRORRRWR~RRRRRRRRRRRRRRR(((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyRKvsF	!				k			 						(tcollectionsRtoptparseRRt(redhat_support_tool.helpers.confighelperRt"redhat_support_tool.helpers.commonRRLtgettextReRthelpersRR!R#Rht
__author__tobjectRRRRRMRK(((sH/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/__init__.pyt<module>s$

0