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 :  /proc/self/root/lib/python2.7/site-packages/redhat_support_tool/helpers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pyc
�
��Tc@s6dZddlmZmZddlmZmZddljZddl	j
Z
ddlZddlZddl
ZddljjZddljjZddlZddlZddlZddlZddlZddlZeZyddlZddlZWn
eZnXeZyddlmZeZWnddl Z nXdZ!ea"da$ej%d�Z&d�Z'd	�Z(d
�Z)d�Z*d�Z+d
�Z,d�Z-d�Z.d�Z/d�Z0d�Z1d�Z2d�Z3d�Z4d�Z5d�Z6d�Z7d�Z8d�Z9ed�Z:d�Z;d�Z<dS(s8
A helper module with various global utility functions.
i����(tRequestErrortConnectionError(tEmptyValueErrort_N(tsha256s%Keith Robertson <kroberts@redhat.com>s"redhat_support_tool.helpers.commoncCstS(s
    Is redhat-support-tool being run as an interactive shell?

    Example of interactive:
     Welcome to the Red Hat Support Tool.
     Command (? for help):

     Example of non-interactive:
       redhat-support-tool addcomment -c 123456 Here are the logs...
    (t_interactive(((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pytis_interactive=scCs
|adS(s!
    Set the operating mode.
    N(R(tboolean((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pytset_interactiveKscCs
|adS(s(
    Save the dictionary of plugins
    N(t_plugins(tplugins((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pytset_plugin_dictSscCstS(s.
    Get the dictionary of loaded plugins
    (R	(((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pytget_plugin_dict[scCsE|r=y)tj|�jtj��jd�SWqAdSXndSdS(sv
    Given an ISO8601 datetime, convert to local.

    Returns:
     Empty string if there is a conversion error.
    s%a %b %d %H:%M:%S %Z %YtN(tparsertparset
astimezonettzttzlocaltstrftime(tiso8601((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pytiso8601tolocalbscCsd}y#tj�}|jj�}|SWn�tk
ro}td�t|�}|GHtj	t
j|��n�tk
r�}td�|j
}|GHtj	t
j|��netk
r�td�}|GHtj	t
j|��n.td�}|GHtj	t
j|��nXdS(sH
    A utility function to get the available products from the API.
    s	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 find productsN(tNonet	apihelpertget_apitproductstlistRRtstrtloggertlogtloggingtWARNINGRtreasonR(tapitproductsArytevetmsgtrerr((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pytget_productsss4	

cCsiy4x-t|�D]\}}d|d|fGHqWWn.td�}|GHtjtj|��nXdS(Ns %-3s %-75sis$ERROR: problem parsing the versions.(t	enumerateRRRRR(tversionsArytindextvalR$((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pytprint_versions�scCsoy:x3t|�D]%\}}d|d|j�fGHqWWn.td�}|GHtjtj|��nXdS(Ns %-3s %-75sis$ERROR: problem parsing the products.(R'tget_nameRRRRR(R"R)R*R$((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pytprint_products�s!cCsd}y#tj�}|jj�}|SWn�tk
rr}td�t|�}|GHtj	t
j|�|�n�tk
r�}td�|j
}|GHtj	t
j|��netk
r�td�}|GHtj	t
j|��n.td�}|GHtj	t
j|��nXdS(sD
    A utility function to get the available type from the API.
    s	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 find typeN(RRRtvaluestgetTypeRRRRRRRRR R(R!ttypeAryR#R$tre((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pyt	get_types�s4		

cCsiy4x-t|�D]\}}d|d|fGHqWWn.td�}|GHtjtj|��nXdS(Ns %-3s %-75sis!ERROR: problem parsing the types.(R'RRRRR(ttypesAryR)R*R$((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pytprint_types�scCs+d}y6tj�}|jj�}|ddd�}|SWn�tk
r�}td�t|�}|GHtj	t
j|��n�tk
r�}td�|j
}|GHtj	t
j|��netk
r�td�}|GHtj	t
j|��n.td�}|GHtj	t
j|��nXdS(sJ
    A utility function to get the available severities from the API.
    Ni����s	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 find severities(RRRR.tgetSeverityRRRRRRRRR R(R!t
severitiesAryR#R$R1((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pytget_severities�s6	

cCs�tjd�}yYxRt|�D]D\}}|j|�}d|dt|j�d�j�fGHqWWn.td�}|GHtj	t
j|��nXdS(Ns	\((.+?)\)s %-3s %-75siis&ERROR: problem parsing the severities.(R1tcompileR'tsearchRtgroupststripRRRRR(R6tregexR)R*trR$((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pytprint_severities�s1cCsd}y#tj�}|jj�}|SWn�tk
ro}td�t|�}|GHtj	t
j|��n�tk
r�}td�|j
}|GHtj	t
j|��netk
r�td�}|GHtj	t
j|��n.td�}|GHtj	t
j|��nXdS(sH
    A utility function to get the available statuses from the API.
    s	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 find statusesN(RRRR.t	getStatusRRRRRRRRR R(R!tstatusesAryR#R$R1((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pytget_statusess4	

cCsiy4x-t|�D]\}}d|d|fGHqWWn.td�}|GHtjtj|��nXdS(Ns %-3s %-75sis$ERROR: problem parsing the statuses.(R'RRRRR(R@R)R*R$((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pytprint_statuses'scCsd}y#tj�}|jj�}|SWn�tk
ro}td�t|�}|GHtj	t
j|��n�tk
r�}td�|j
}|GHtj	t
j|��netk
r�td�}|GHtj	t
j|��n.td�}|GHtj	t
j|��nXdS(sF
    A utility function to get the available groups from the API.
    s	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 find groupsN(RRRR:RRRRRRRRRR R(R!t	groupsAryR#R$R1((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pyt
get_groups2s4	

cCsoy:x3t|�D]%\}}d|d|j�fGHqWWn.td�}|GHtjtj|��nXdS(Ns %-3s %-75sis"ERROR: problem parsing the groups.(R'R,RRRRR(RCR)R*R$((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pytprint_groupsSs!cCs^d}t�rZtrZtjj�rZd}tjtjtj	d�}t
j||�}n|S(s&
    A utility function to return information about the terminal as a tuple

    returns:
     - tuple consisting of (height, width, xpixels, ypixels); or
     - None if not interactive, or output is not a tty

    Note:
      xpixels and ypixels is unused in the kernel, and will return 0
    t4Ht iNs        (RRt_terminfosupporttsyststdouttisattytfcntltioctlttermiost
TIOCGWINSZtstructtunpack(tretttiocgwinsz_fmtt
rawwinsize((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pytget_terminfo^scs�fd�}|S(Ncs
�|_|S(N(t__doc__(tfunction(tdoctext(sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pyt	docstringws	((RXRY((RXsF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pyt
set_docstringvscCs�t�rtd�}ntd�}d}i}t|j�}t�}|r[|d}nd}d|kr�|j�}xM|D]B}||j�}	t|	�jd||j	��}	|	||<q�Wnx_|D]W}
|
d d	kr�t
||
�}|j}tj
|�r'|r'|||
d<q'q�q�Wtd
�|j�D��}
H|GHdt|t|��GHt|j��}x_|D]W}d|
|d
|df}tj||dd|
d�}x|D]}|GHq�WqWdS(Ns(Documented commands (type help <topic>):s(Documented commands (<topic> -h,--help):t=iiPt_get_pluginss%progithelp_css|]}t|�VqdS(N(tlen(t.0tk((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pys	<genexpr>�ss%su%-*s %-sitsubsequent_indentRG(RRtdirt	__class__RUR\tget_descRtreplaceR,tgetattrRVtinspecttismethodtmaxtkeysR^tsortedt	iteritemsttextwraptwrap(tclsobjtHEADERtrulert	help_dicttfuncstterminfot	termwidthtplugin_dicttplugintusagetfunctitemRYtlongest_cmdt	tuple_aryttpltoutputtoutput_wrappedtline((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pytdo_help}sF		


	

cGs�d}x�|D]�}t|�}||||}}|dkrM|d}n|dks�||krq|tks�||kr
|tkr
|}q
q
W|S(Nii(RR^tTruetFalse(twidthtmosttargstlongest_lineR�tlinelentdivtmod((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pyt
get_linecount�s


cCs+d}g}tjj|�}tj|�j}tjdd�}tj|�}|j|j	}||kr<t
d�|GHx�tr8tt
d��}	t
|	�j�}	tjj|	�}yWtj|�tj|�}|j|j	}||krt
d�||fGHnwWqtk
r4t
d�|GHqXqWnt|�}
x�tr&d}d}tr{t�}t
d	�}ntj�}t
d
�}|
j|�}
|
s�Pntjj|d||f�}t|d�}|j|
�|j|
�|ji|d
6||j�d6�|d7}qKW|S(Nitsuffixs.rhsts.Not enough space available in /tmp to split %ss:Please provide an alternative location to split the file: s3Not enough space available in %s, %d bytes requireds Unable to create directory at %sR
s
SHA256: %ssSHA1: %ss%s.%03dtwtfileR$(tostpathtbasenametstattst_sizettempfiletmkdtemptstatvfstf_bavailtf_frsizeRR�t	raw_inputRR;t
expandusertmkdirtOSErrortopenRt_sha256supportRtshatnewtreadtjointwritetupdatetappendt	hexdigest(t	file_patht
chunk_sizet	chunk_numtchunkst	file_namet	file_sizettempdirttempdir_statvfsttempdir_freeR�tin_fileR$tshasumtdatatout_filenametout_file((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pyt
split_file�sZ	

	
		


cCs�tj�}|jdd�r?td�}tj|�|GHnU|jdd�r�tj|jdd�tj�r�td�}tj|�|GHndS(s�Check SSL configuration options

    Will print warnings for various potentially unsafe situations as a means
    to alert of possible Man-in-the-Middle vectors, or SSL communication is
    likely to fail.toptiont
no_verify_sslsWarning: no_ssl_verify is enabled in the Red Hat Support Tool configuration, this may allow other servers to intercept communications with Red Hat.  If you have a transparent SSL proxy server, you can trust it's Certificate Authority using: 'config ssl_ca <filepath>'tssl_cas�Warning: Red Hat Support Tool is unable to access the designated Certificate Authority certificate for server verification at %s.  Please correct/replace this file, otherwise functionality may be limited.N(	tconfighelpertget_config_helpertgetRRtwarnR�taccesstR_OK(tcfgR$((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pyt	ssl_check�s
"
(=RVt(redhat_support_lib.infrastructure.errorsRRt(redhat_support_tool.helpers.confighelperRRtdateutil.parserRtdateutil.tzRRgR�tos.patht%redhat_support_tool.helpers.apihelperthelpersRR�R1RRPRIR�RmR�RHRLRNR�R�thashlibRR�t
__author__RRR	t	getLoggerRRRRRRR&R+R-R2R4R7R>RARBRDRERURZR�R�R�R�(((sF/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/common.pyt<module>sj

						!			!		"	
	!		!				1	8

https://t.me/AnonymousX5 - 2025