KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /proc/21573/root/usr/lib/yum-plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/21573/root/usr/lib/yum-plugins/fastestmirror.pyo
mò
ÐEOc@sQdZdkZdkZdkZdkZdkZdkZdkZdkZdk	l
Z
dZe
fZe
adahadadae
adadaeae
aeƒZd„Zd	„Zd
„Zd„Zd„Z d
„Z!d„Z"d„Z#d„Z$dfd„ƒYZ%dei&fd„ƒYZ'd„Z(e)djoe(ƒndS(s|
B{FastestMirror} is a Yum plugin which sorts each repository's mirrorlist
according to connection speed prior to download.
N(s	TYPE_COREs2.5iti
icCsÙ|idddtƒa|iddddƒa|iddddƒa|idddd	ƒa|idd
dd	ƒa	|idddd
ƒa|idddtƒa
tiitƒotƒtjo
tand
S(sD
    This function initiliazes the variables required for running B{fastestmirror}
    module. The variables are initiliazed from the main section of the plugin file.

    There are no parameteres for this function. It uses global variables to
    communicate with other functions.

    This function refers:
        - L{get_hostfile_age}

    @param verbose : Verbosity of output.
    @type verbose : Boolean
    @param socket_timeout : The default timeout for a socket connection.
    @type socket_timeout : Integer
    @param hostfilepath : Absolute path to the plugin's cache file.
    @type hostfilepath : String
    @param maxhostfileage : Maximum age of the plugin's cache file.
    @type maxhostfileage : Integer
    @param loadcache : Fastest Mirrors to be loaded from plugin's cache or not.
    @type loadcache : Boolean

    tmaintverbosetdefaulttsocket_timeoutithostfilepaths/var/cache/yum/timedhoststmaxhostfileagei
t
maxthreadstexcludet
downgrade_ftpN(tconduittconfBooltFalseRtconfIntRt
confStringRRRtNoneRtTrueR	tostpathtexiststget_hostfile_aget	loadcache(R
((t%/usr/lib/yum-plugins/fastestmirror.pyt	init_hookBs#cCs8tiitƒo!|iddƒtitƒndS(s”
    This function cleans the plugin cache file if exists. The function is called
    when C{yum [options] clean [plugins | all ]} is executed.
    is#Cleaning up list of fastest mirrorsN(RRRRR
tinfotunlink(R
((Rt
clean_hookhscCs|idƒdidƒdS(Nt/it@iÿÿÿÿ(tmirrortsplit(R((Rt<lambda>rscCsOtii|ƒp)yttdƒ}tSWq<tSq<Xnti	|ti
ƒS(Ntw(RRRtfnametfileRthostfileRRtaccesstW_OK(R!R#((Rt_can_write_resultstscCs<d}x/|D]'}|idƒoq
n|d7}q
WdS(s- Count the number of urls, which aren't ftp. isftp:iN(tnumturlsturlt
startswith(R(R)R'((Rt_len_non_ftp~scs|iƒ\}}|iiipttƒodSnt	o|i
ddƒn3to|i
ddƒtƒn|i
ddƒh}|iƒ}g}x||iƒD]n}|it	joqªntot|iƒdjoqªnt|iƒdjoqªn|i|iƒqªWt|ƒiƒ}x¾|iƒD]°}|it	joq;nto5t|iƒdjot|idtƒ|_q;nt|iƒdjoq;nt|ƒ|jo#t|iƒiƒ|t|ƒ<nto|xy|t|ƒD]c‰t ‡d†ti!d	d
ƒi"ƒƒo5|i
ddt#ˆƒƒ|t|ƒi$ˆƒqÿqÿWn|t|ƒ|_t|iƒo1|i
ddt|ƒt#|id
ƒfƒnd|_%|i&ƒ|i'ƒt	i(|iƒq;Wt)ot*i+dƒntpt-ƒndS(s}
    This function is called after Yum has initiliazed all the repository information.

    If cache file exists, this function will load the mirror speeds from the file,
    else it will determine the fastest mirrors afresh and write them back to the cache
    file.

    There are no parameteres for this function. It uses global variables to
    communicate with other functions.

    This function refers:
        - L{read_timedhosts()}
        - L{FastestMirror.get_mirrorlist()}
        - L{write_timedhosts()}

    @param loadcache : Fastest Mirrors to be loaded from plugin's cache file or not.
    @type loadcache : Boolean
    Nis"Checking for new repos for mirrorss*Loading mirror speeds from cached hostfilesDetermining fastest mirrorsitreversecs|tˆƒjS(N(texpthostR(R-(R(RRÄst,t sExcluding mirror: %ss	 * %s: %sitpriority(.R
t
getCmdLinetoptstcommandst_basetconftcacheR&Rt
done_reposRRtread_timedhoststrepomirrorstgetRepostrepostall_urlstlistEnabledtrepotidR	R+R(tlentextendt
FastestMirrortget_mirrorlisttsortedRtstrRRtfiltertreplaceRR.tremovetfailovermethodtcheckt	setupGrabtaddtdone_sock_timeouttsockettsetdefaulttimeoutRtwrite_timedhosts(R
R<RR=R:R?R4R3((RRtpostreposetup_hook‡sj

##1	

cCsmySttƒ}x6|iƒD](}|iƒ\}}t|ƒt	|<qW|i
ƒWntj
onXdS(sû
    This function reads the time and hostname from the plugin's cache file and
    store them in C{timedhosts}.

    There are no parameteres for this function. It uses global variables to
    communicate with other functions.

    This function is referred by:
        - L{postreposetup_hook()}

    @param timedhosts : A list of time intervals to reach different hosts
    corresponding to the mirrors. The index of the list are hostnames.
    C{timedhosts[host] = time}.
    @type timedhosts : List
    N(R"RR#t	readlinestlineRR.ttimetfloatt
timedhoststclosetIOError(R#R.RURT((RR9Õs
cCscyIttdƒ}x)tD]!}|id|t|fƒqW|iƒWntj
onXdS(sì
    This function writes the plugin's cache file with the entries in the
    C{timedhosts} list.

    There are no parameteres for this function. It uses global variables to
    communicate with other functions.

    This function is referred by:
        - L{postreposetup_hook()}

    @param timedhosts : A list of time intervals to reach different hosts
    corresponding to the mirrors. The index of the list are hostnames.
    C{timedhosts[host] = time}.
    @type timedhosts : List
    R s%s %s
N(R"RR#RWR.twriteRXRY(R#R.((RRQïscCs2tiitiitƒƒ}tiiƒ|iS(s¤
    This function returns the current age of the plugin's cache file.

    There are no parameteres for this function. It uses global variables to
    communicate with other functions.

    This function is referred by:
        - L{init_hook()}

    @param hostfilepath : Absolute path to the plugin's cache file.
    @type hostfilepath : String
    @rtype: Integer
    @return: The age of the plugin's cache file.
    N(	tdatetimet
fromtimestampRRtgetmtimeRt	timestamptnowtdays(R^((RRsRCcBsMtZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	RS(sÃ
    This is the helper class of B{fastestmirror} module. This class does
    all the processing of the response time calculation for all the mirrors
    of all the enabled Yum repositories.
    cCs||_h|_g|_dS(s¾
        This is the initiliazer function of the B{L{FastestMirror}} class.

        @param mirrorlist : A list of mirrors for an enabled repository.
        @type mirrorlist : List
        N(t
mirrorlisttselftresultstthreads(RbRa((Rt__init__"s		cCs:t|dƒp&tiƒ|_tatit	ƒndS(Nt
_results_lock(
thasattrRbt	threadingtLockRfRRNRORPR(Rb((Rt
_init_lock.s
cCs%t|dƒo|iiƒndS(NRf(RgRbRftacquire(Rb((Rt
_acquire_lock5scCs%t|dƒo|iiƒndS(NRf(RgRbRftrelease(Rb((Rt
_release_lock8scCsm|iƒg}|iiƒD]\}}|||fq~}|iƒg}|D]}||dqU~S(sü
        This function pings/polls all the mirrors in the list
        C{FastestMirror.mirrorlist} and returns the sorted list of mirrors
        according to the increasing response time of the mirrors.

        This function refers:
            - L{FastestMirror._poll_mirrors()}

        This function is referred by:
            - L{postreposetup_hook()}
            - L{main()}

        @rtype: List
        @return: The list of mirrors sorted according to the increasing
        response time.
        iN(
Rbt
_poll_mirrorst_[1]Rctitemstktvtmirrorstsorttx(RbRtRpRsRvRr((RRD<s

6
cCs¬xT|iD]I}t|iƒtjo7|idiƒo|idiƒn|id=n|idƒo
d}n
t
|ƒ}to*|idƒo|i||dƒq
n|t
jo;t
|}tod||fGHn|i|||ƒq
|d
jo|i||dƒq
|iƒt||ƒ}|iƒ|ii|ƒq
WxNt|iƒdjo7|idiƒo|idiƒn|id=qZWd	S(s
        This function uses L{PollThread} class to ping/poll individual mirror
        in parallel.

        This function refers:
            - L{PollThread.run()}

        This function is referred by:
            - L{FastestMirror.get_mirrorlist()}
        isfile:s	127.0.0.1sftp:IþçvHs%s already timed: %ss::1t	localhostN(s	127.0.0.1s::1Rw(RbRaRRARdRtisAlivetjoinR*tmhostR.R	t_add_resultRWtresultRRjt
PollThreadt
pollThreadtstarttappend(RbR~RzRR|((RRoRs<







cCsI|iƒtod||fGHn||i|<|t|<|iƒdS(s”
        This function is called by L{PollThread.run()} to add details of a
        mirror in C{FastestMirror.results} dictionary.

        This function is referred by:
            - L{PollThread.run()}

        @param mirror : The mirror that was polled for response time.
        @type mirror : String
        @param host : The hostname of the mirror.
        @type host : String
        @param time : The response time of the mirror.
        @type time : Integer
        @param timedhosts : A list of time intervals to reach different hosts
        corresponding to the mirrors. The index of the list are hostnames.
        @type timedhosts : List
        s * %s : %f secsN(	RbRlRR.RURcRRWRn(RbRR.RU((RR{s


(
t__name__t
__module__t__doc__ReRjRlRnRDRoR{(((RRCs						-R}cBs tZdZd„Zd„ZRS(s•
    B{PollThread} class implements C{threading.Thread} class. This class
    provides the functionalities to ping/poll the mirrors in parallel.
    cCs¹tii|ƒ||_||_t|ƒ|_ti|ƒd}|djo
d|_	nX|djo
d|_	n>|djo
d|_	n$|djo
d	|_n
d
|_	dS(s1
        It is initiliazer function for B{L{PollThread}} class. This function
        initiliazes the service ports for different webservices.

        @param parent : The parent class.
        @type parent : Class
        @param mirror : The mirror of a repository.
        @type mirror : String
        ithttpiPthttpsi»tftpiR"s	127.0.0.1iþÿÿÿN(
RhtThreadReRbtparentRR.turlparsetuServicetport(RbRˆRRŠ((RRežs			







cCs`y|itjo.t|i}tod|i|fGHqnÂ|idjo
d}n¨tititiƒ}t	i
|idƒ}|djo.t|i|dƒ|_
|i| |_ntiƒ}|i|i|i
fƒtiƒ|}|iƒ|ii|i|i|ƒWn:tod|iGHn|ii|i|id	ƒnXd
S(sà
        The C{threading.Thread.run()} function is being overridden here.
        This function pings/polls a mirror and add the details of that
        mirror to the C{FastestMirror.results} dictionary.

        The response time of any mirror is '99999999999' if any exception
        occurs during polling.

        This function refers:
            - L{FastestMirror._add_result()}

        This function is referred by:
            - L{FastestMirror._poll_mirrors()}
        s%s already timed: %ss	127.0.0.1s::1Rwit:is * %s : deadIÿçvHN(s	127.0.0.1s::1s	localhost(RbR.RWR|RROtAF_INETtSOCK_STREAMtsocktstringtfindtuPorttintR‹RUttime_beforetconnectRXRˆR{R(RbRR’R”R|((Rtrun¸s,



 (RR‚RƒReR–(((RR}˜s	cCsitattiƒdjo!dtidGHtidƒntid}dtt|ƒi	ƒƒGHdS(sõ
    This is the main function for B{fastestmirror} module.

    This function explains the usage of B{fastestmirror} module. Also parses
    the command line arguments.

    This function refers:
        - L{FastestMirror.get_mirrorlist()}
    is+Usage: %s <mirror1> [mirror2] ... [mirrorN]iiÿÿÿÿsResult: N(
RRRAtsystargvtexitRaRFRCRD(Ra((RRßs	
t__main__(*RƒRR—RURORR‰R[Rhtyum.pluginst	TYPE_COREtrequires_api_versiontplugin_typeRRRRWRRRRRRRR	RNtsetR8RRR.R&R+RRR9RQRRCR‡R}RR(R[R&RRRR+R9RR8RRR—R.RœROR}RRRCR‰RhRQRURRž((Rt?&sH								
			&	
		
			N			}G	


Anon7 - 2021