ó }κ^c@sˆdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z dZ e fZ eaeadaiadadaeadadadadaeaeaeƒZd „Z d „Z!d „Z"d „Z#d „Z$d„Z%d„Z&d„Z'd„Z(ddd„ƒYZ)dej*fd„ƒYZ+d„Z,e-dkr„e,ƒndS(s| B{FastestMirror} is a Yum plugin which sorts each repository's mirrorlist according to connection speed prior to download. iÿÿÿÿN(t TYPE_COREs2.5iti icCst|dƒr|jdƒn|jdddtƒa|jdddtƒa|jddddƒa|j dd dd ƒa |jdd dd ƒa |jdd dd ƒa |j ddddƒa|j ddddƒa|j ddddƒa|jdddtƒadS(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 tregisterPackageNamesyum-plugin-fastestmirrortmaintverbosetdefaulttalways_print_best_hosttsocket_timeoutit hostfilepatht timedhoststmaxhostfileagei t maxthreadstexcludet include_onlytprefersno.prefer.mirrort downgrade_ftpN(thasattrRtconfBooltFalseRtTrueRtconfIntRt confStringRR R tNoneR R RR(tconduit((s%/usr/lib/yum-plugins/fastestmirror.pyt init_hookHs  cCs”tr0tddkr0|jjjdtantjjtƒr|jddƒytjtƒWqt k rŒ}|jdd|ƒqXndS(s” This function cleans the plugin cache file if exists. The function is called when C{yum [options] clean [plugins | all ]} is executed. it/is#Cleaning up list of fastest mirrorssCleanup failed: %sN( Rt_basetconftcachedirtostpathtexiststinfotunlinkt Exception(Rte((s%/usr/lib/yum-plugins/fastestmirror.pyt clean_hookpscCs|jdƒdjdƒdS(NRit@iÿÿÿÿ(tsplit(tmirror((s%/usr/lib/yum-plugins/fastestmirror.pyt€scCsJtjj|ƒs7yttdƒ}tSWq7tSXntj|tjƒS(Ntw( RRRtfileRRRtaccesstW_OK(tfnamethostfile((s%/usr/lib/yum-plugins/fastestmirror.pyt_can_write_results‚scCs:d}x-|D]%}|jdƒr(q n|d7}q W|S(s- Count the number of urls, which aren't ftp. isftp:i(t startswith(turlstnumturl((s%/usr/lib/yum-plugins/fastestmirror.pyt _len_non_ftpŒs  c s_tr0tddkr0ˆjjjdtantjjtƒrZtƒtkrZt a nˆj ƒ\}}ˆjjj sˆt tƒ rŒdStr¥ˆjddƒn0t rňjddƒtƒnˆjddƒi}ˆjƒ}g}xu|jƒD]g}|jtkrqúntr6t|jƒdkr6qúnt|jƒdkrQqún|j|jƒqúWt|ƒjƒ}x»|jƒD]­}|jtkrŸq„ntrØt|jƒdkrØt|jd t ƒ|_q„nt|jƒdkróq„nt|ƒ|kr't|jƒjƒ|t|ƒR?tlvl((Rs%/usr/lib/yum-plugins/fastestmirror.pytprereposetup_hook•sn!   "&& 0   cCskySttƒ}x6|jƒD](}|jƒ\}}t|ƒt|d|jGHn|jj|j|jd ƒ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::1R‚it:is * %s : deadlÿgí]N(R8R RRRUtAF_INETt SOCK_STREAMtstringtfindtintR”RetconnectRbR’R…R'(RpRŠtsocktuPortt time_before((s%/usr/lib/yum-plugins/fastestmirror.pytrunÝs*      (RŒRRŽRqR (((s%/usr/lib/yum-plugins/fastestmirror.pyR†½s cCsgtattjƒdkr;dtjdGHtjdƒntjd}dtt|ƒjƒƒ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 [mirror2] ... [mirrorN]iiÿÿÿÿsResult: N( RRRJtsystargvtexitRORLRM(Rm((s%/usr/lib/yum-plugins/fastestmirror.pyRs  t__main__((.RŽRR¡ReRUR™R“RgRsR6t yum.pluginsRtrequires_api_versiont plugin_typeRRRRRR RR RBR RR R RRRTtsetRERR$R8R/R4R_RFRWRARLR‘R†RRŒ(((s%/usr/lib/yum-plugins/fastestmirror.pyt(sP            (   d   ~G