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

fc@sddlmZddlmZmZddlmZmZddlm	Z	m
Z
ddlmZddl
mZmZddlZddljjZddljjZddljjZdZejd	Zd
efdYZdS(i(tdeque(tOptiont
SUPPRESS_HELP(tRequestErrortConnectionError(tEmptyValueErrort_(t	Constants(tInteractivePlugint
DisplayOptionNs&Spenser Shumaker <sshumake@redhat.com>s'redhat_support_tool.plugins.modify_caset
ModifyCasecBs=eZdZedZdZdZdZdZ	dZ
edZedZ
edZedZdZdZdZd	Zd
ZdZdZd
ZdZdZdZdZdZdZddZdZdZ dZ!dZ"dZ#dZ$dZ%RS(t
modifycasesModify casecCs
tdS(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!
        s%prog CASENUMBER(R(tcls((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyt	get_usage+s	cCstd|jS(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
        s9Use the '%s' command to modify a specific case by number.(Rtplugin_name(R((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pytget_desc6s	cCstd|jS(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
        s"Example:
  - %s <case number here>(RR(R((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyt
get_epilogBs	cCs0t}tjtjjddr6td}ntdddddtd	d
d"tdddd
dtdd
d"tdddddtdd
d"tddddd|d
d"tdddddtdd
d"tdddddtdd
d"tdddd dtd!d
d"gS(#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

        toptiontponiess the internal status for the cases-ts--typetdestttypethelpsthe type of casetdefaults-Ss
--severitytseveritysthe severity for the cases-ss--statuststatussthe status for the cases-is--internal-statustinternal_statuss-as--alternative-idtaidsaAn alternative-id for the cases-ps	--producttproducts&the product the case is opened againsts-vs	--versiontversions5the version of the product the case is opened againstN(	Rtcommontstr_to_booltconfighelpertget_config_helpertgetRRtNone(Rtpublic_opt_help((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pytget_optionsPs.!cCs
tdS(NsR
Type the number of the attribute to modify or 'e' to return to the previous menu.(R(tself((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pytget_intro_textscCs
tdS(NsSelection: (R(R%((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pytget_prompt_textscCs|jS(N(t
_submenu_opts(R%((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pytget_sub_menu_optionsscCstd|j}d|_|jr=dj|j|_ntjrttd}t|j	}|dkrt
nt|j	r||_q|GHt
|n|GHt
|dS(Ns!ERROR: %s requires a case number.tt s/Please provide a case number (or 'q' to exit): tq(RRt_caseNumbert_argstjoinRtis_interactivet	raw_inputtstrtstript	Exception(R%tmsgtline((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyt_check_case_numbers 	
		cCs|jdrt}xJtjD]<}|jdj|jkr t}||jd<Pq q W|std}|GHt|qndS(NRsERROR: Invalid type specified.(t_optionstFalseRt	get_typestlowertTrueRR4(R%tmatchtcasetypeR5((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyt_check_types

cCs|jdr}t}xJtjD]<}|jdj|jkr t}||jd<Pq q W|s}td}|GHq}ndS(NRs"ERROR: Invalid severity specified.(R8R9Rtget_severitiesR;R<R(R%R=RR5((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyt_check_severitys

cCs|jdrt}xJtjD]<}|jdj|jkr t}||jd<Pq q W|std}|GHt|qndS(NRs ERROR: Invalid status specified.(R8R9Rtget_statusesR;R<RR4(R%R=RR5((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyt
_check_statuss

cCs|jdrt}xJtjD]<}|jdj|jkr t}||jd<Pq q W|std}|GHt|qndS(NRs)ERROR: Invalid internal status specified.(R8R9Rtget_internal_statusesR;R<RR4(R%R=RR5((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyt_check_internal_statuss

cCs|jdrd|_tj|_t}x4|jD])}|j|jdkr5t}Pq5q5W|std}|GHt	|qndS(NRs ERROR: Invalid product provided.(
R8R"t_productsAryRtget_productsR9tget_nameR<RR4(R%tinArrayRR5((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyt_check_prods
	cCs|jdrd}|jddkr8|jj}n
|jd}|js`tj|_nx3|jD](}||jkrj|j}PqjqjW|jd|krt	d}|GHt
|qndS(NRRs ERROR: Invalid version provided.(R8R"t_casetget_productRFRRGRHtget_versionsRR4(R%tversionsRtprodR5((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyt
_check_vers

	cCs@|j|j|j|j|j|jdS(N(R7R?RARCRERJ(R%((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyt
validate_argss




cCst|_i|_d}y<tj}|jj|j|_	|j
|jWn.tk
r}t
dt|}|GHtjtj|ntk
r}t
d|j}|GHtjtj||jdkrtjnntk
rP}t
d}|GHt|jd}|dGHtjtj|n8tk
rt
d}|GHtjtj|nXdS(Ns	ERROR: %ss?Unable to fulfill request with support services API. Reason: %stUnauthorizedsZProblem connecting to the support services API.  Is the service accessible from this host?s, isProblem updating case(RR(t	_sectionsR"t	apihelpertget_apitcasesR!R-RKRPt_createDisplayOptsRRR2tloggertlogtloggingtWARNINGRtreasonRtremove_userRtsplitR4(R%tapiteveR5treterrmsgtemg((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pytpostinitsB	
	

	
cCsttjd}|jj|tj|j|<ttjd}|jj|tj|j|<ttjd}|jj|tj|j|<tj	t
jjddrttj
d}|jj|tj
|j|<nttjd}|jj|tj|j|<ttjd}|jj|tj|j|<ttjd}|jj|tj|j|<dS(Ntinteractive_actionRR(R	RtCASE_MODIFY_TYPER(tappendRStCASE_MODIFY_SEVERITYtCASE_MODIFY_STATUSRRRR R!tCASE_MODIFY_INTERNAL_STATUStCASE_MODIFY_AIDtCASE_MODIFY_PRODtCASE_MODIFY_VER(R%tdisp_opt((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyRW,s:						!								cCsi}|jdr-|jd|jdn|jdrT|jd|jdn|jdr{|jd|jdn|jdrtjtjjddr|jd|jdn|jd	r|jd
|jd	n|jdr@|jdr|jdn|jj}|jd|jdd|n|jdr|jdrg|jdn|jj	}|jd|jdd|n|jj|dS(
NRtcaseTypeRRRRRtinternalStatusRtalternateIdRR(
R8tupdateRRRR R!RKtget_versionRL(R%tdataRR((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pytnon_interactive_actionXs&



!

) 
) cCsGi}|jtjkrf|jrCi|jdd6}|jj|td|jjGHqCn|jtj	kr|j
rCi|jdd6}|jj|td|jjGHqCn}|jtjkrM|jrCi|jdd6}|jj|td|jjGH|jddkrJtdGHt
qJqCn|jtjkr|jrCi|jdd	6}|jj|td|jjGHqCn|jtjkr
|jrCi|jd
d6}|jj|td|jjGHqCn6|jtjkr|jrC|jd|jjkrj|jrji|jd
d
6}n|ji|jdd6|jj|td|jjGHqCn|jtjkrC|jrC|jdr|jdn|jj}i|jd
d
6|d6}|jj|td|jjGHqCndS(NRRosSuccessfully updated case %sRRtCloseds+Case closed, leaving the modify case menu.
RRpRRqRR(tdisplay_textRRft	_get_typeR8RKRrRtget_caseNumberRht
_get_severityRit_get_statusR4Rjt_get_internal_statusRkt_get_aidRlt	_get_prodRLt_get_verRm(R%tdisplay_optionRtR((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyRemsd						)	cCstj}tj|xtrttd}t|jdkrPtSyt	|}WntdGHnX|t
dt|dkr|dkr||d|jd<PqtdGHqWtS(Ns'Please select a type (or 'q' to exit): R,sERROR: Invalid type selection.iR*R(
RR:tprint_typesR<R1RR2R3R9tinttrangetlenR8(R%ttypesAryR6((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyRxs
	+cCstj}tj|xtrttd}t|jdkrPtSyt	|}WntdGHnX|t
dt|dkr|dkr||d|jd<PqtdGHqWtS(Ns+Please select a severity (or 'q' to exit): R,s"ERROR: Invalid severity selection.iR*R(
RR@tprint_severitiesR<R1RR2R3R9RRRR8(R%t
severitiesAryR6((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyRzs
	+cCstj}tj|xtrttd}t|jdkrPtSyt	|}WntdGHnX|t
dt|dkr|dkr||d|jd<PqtdGHqWtS(Ns)Please select a status (or 'q' to exit): R,s ERROR: Invalid status selection.iR*R(
RRBtprint_statusesR<R1RR2R3R9RRRR8(R%tstatusesAryR6((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyR{s
	+cCstj}tj|xtrttd}t|jdkrPtSyt	|}WntdGHnX|t
dt|dkr|dkr||d|jd<PqtdGHqWtS(Ns3Please select an internal status (or 'q' to exit): R,s)ERROR: Invalid internal status selection.iR*R(
RRDRR<R1RR2R3R9RRRR8(R%tinternalStatusesAryR6((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyR|s
	+cCsmxftrhttd}t|j}|dkr=tS|dkrZ||jd<PqtdGHqWtS(Ns2Please provide a alternative-id (or 'q' to exit): R,R*Rs'ERROR: Invalid alternative-id provided.(R<R1RR2R3R9R8(R%R6((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyR}s	
cCstj|_tj|jxtrttd}t|jdkrVt	Syt
|}WntdGHnX|tdt|jdkr|dkr|j|dj
|jd<Pq"tdGHq"WtS(Ns*Please select a product (or 'q' to exit): R,s!ERROR: Invalid product selection.iR*R(RRGRFtprint_productsR<R1RR2R3R9RRRRHR8(R%R6((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyR~s	.cCsMd}|jddkr2|jj|jd<n|jsMtj|_nx:|jD]/}|jd|jkrW|j}PqWqWWtj	|xt
rHttd}t
|jdkrtSyt|}WntdGHnX|tdt|jdkr:|dkr:||d|jd<PqtdGHqWt
S(NRs*Please select a version (or 'q' to exit): R,s!ERROR: Invalid version selection.iR*R(R"R8RKRLRFRRGRHRMtprint_versionsR<R1RR2R3R9RRR(R%RNRR6((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyRs.	
	.N(&t__name__t
__module__RRtALLR"R(RSR-RKRFtclassmethodR
RRR$R&R'R)R7R?RARCRERJRPRQRdRWRuReRxRzR{R|R}R~R(((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyR
"sB6					
		
	
					'	,	7						(tcollectionsRtoptparseRRt(redhat_support_lib.infrastructure.errorsRRt(redhat_support_tool.helpers.confighelperRRt%redhat_support_tool.helpers.constantsRtredhat_support_tool.pluginsRR	RZt%redhat_support_tool.helpers.apihelperthelpersRTt"redhat_support_tool.helpers.commonRRt
__author__t	getLoggerRXR
(((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/modify_case.pyt<module>s