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

fc@sddlmZmZddlmZmZddlmZddlmZddl	m
Z
ddljj
Z
ddljjZddljjZddlZdZdZejd	Zd
e
fdYZdS(i(tOptiont
SUPPRESS_HELP(tRequestErrortConnectionError(tEmptyValueError(t_(tPluginNs%Keith Robertson <kroberts@redhat.com>s&Spenser Shumaker <sshumake@redhat.com>s'redhat_support_tool.plugins.add_commentt
AddCommentcBseZdZdZedZedZedZedZ	dZ
dZdZdZ
d	Zd
ZRS(t
addcommentcCs
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 -c CASENUMBER <comment text here>(R(tcls((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_comment.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
        s0Use the '%s' command to add a comment to a case.(Rtplugin_name(R	((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_comment.pytget_desc2s		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
        sExamples:
- %s -c 12345678(RR(R	((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_comment.pyt
get_epilog>scCsd}t}tjtjjddr?td}ntddddd	td
dttdd
ddddd	tddttddddd	|ddddd|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

        cSsXtj|}|dkrHtd|||f}|GHt|n||j_dS(s
            Callback function for the public option that converts the string
            into an equivalent boolean value
            sVERROR: Unexpected argument to %s: %s
Valid values are true or false (default: %s true)N(tcommontstr_to_booltNoneRt	Exceptiontvaluestpublic(toptiontopt_strtvaluetparsertrettmsg((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_comment.pytpublic_opt_callbackisRtponiessaTrue or False.  Use this to toggle a public or private comment (default=True).  Example: -p falses-cs--casenumbertdestt
casenumberthelpsBThe case number from which the comment should be added. (required)tdefaults-os--obfuscatet	obfuscatetactiont
store_truesZObfuscate the comment by running it through soscleaner to clean hostnames and IP addressess-ps--publicRttypetstringtcallback(	RRRtconfighelpertget_config_helpertgetRRtFalse(R	Rtpublic_opt_help((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_comment.pytget_optionsLs	!cCs
||_dS(N(t_args(tselft
stored_obj((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_comment.pyt
insert_objscCstd|j}|jdstjrttd}t|j}|dkrhtnt|jr||jd<q|GHt|q|GHt|ndS(Ns!ERROR: %s requires a case number.Rs.Please provide a case number(or 'q' to exit): tq(	RRt_optionsRtis_interactivet	raw_inputtstrtstripR(R-Rtline((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_comment.pyt_check_case_numbers	

cCs=td|j}|jr}y5djg|jD]}t|d^q/|_Wq9tk
rydj|j|_q9Xntjr(g}y,tdGHxt	r|j
tqWWq9tk
r$t
dj|j|_|jdkr|GHt|n|jjd|_q9Xn|GHt|dS(Ns/ERROR: %s requires a some text for the comment.u tutf8s5Type your comment. Ctrl-d on an empty line to submit:s
tsutf-8(RRR,tjointunicodetcommentt	TypeErrorRR2tTruetappendR3tEOFErrorR4R5Rtdecode(R-RtiR<((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_comment.pyt_check_comments,	
		,
	
cCstjrtjtjjddr|jddkrtt	d}t
|jjdkrt
|jd<qt|jd<qn#|jddkrt|jd<ndS(NRRRs"Is this a public comment ([y]/n)? tn(RR2RR&R'R(R1RR3RR4R5tlowerR)R>(R-R6((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_comment.pyt_check_is_publics!cCs"|j|j|jdS(N(R7RCRF(R-((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_comment.pyt
validate_argss

c	Csd}ytj}|js5tdGHtn|jdrZtj|j|_n|j	j
d|jdd|jdd|j}|jj|}|dkrtd|jdGHtnWn.t
k
r}tdt|}|GHtjtj|ntk
ro}td	|j}|GHtjtj||jd
kritjnntk
r}td}|GHt|jd}|d
GHtjtj|n8tk
rtd}|GHtjtj|nXdS(Ns"ERROR: The comment has no content.R t
caseNumberRRttexts4ERROR: There was a problem adding your comment to %ss	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, isUnable to add comment(Rt	apihelpertget_apiR<RRR1Rtobfuscate_texttimtmakeCommenttcommentstaddRR4tloggertlogtloggingtWARNINGRtreasontremove_userRtsplit(	R-tapitcomtretValteveRtreterrmsgtemg((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_comment.pytnon_interactive_actionsR	

	
	

	
N(t__name__t
__module__RRR<tclassmethodR
RR
R+R/R7RCRFRGR`(((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_comment.pyR#s=				
	(toptparseRRt(redhat_support_lib.infrastructure.errorsRRt(redhat_support_tool.helpers.confighelperRRtredhat_support_tool.pluginsRt%redhat_support_tool.helpers.apihelperthelpersRKt"redhat_support_tool.helpers.commonRR&RTt
__author__t	getLoggerRRR(((sK/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_comment.pyt<module>s