Ñò ¤2êOc@soddkZddkZddkZddkZddkiZdefd„ƒYZdefd„ƒYZdS(iÿÿÿÿNt RepoChoosercBseeZdZd„Zd„Zd„Zd„Zd„Zd„Ze i d„Z d„Z d „Z RS( s}An object that contains repo statistics. It applies algorithms to choose an optimal set of repos for a given publisher, based upon the observed repo statistics. The RepoChooser object is a container for RepoStats objects. It's used to return the RepoStats in an ordered list, which helps the transport pick the best performing destination.cCs h|_dS(N(t_RepoChooser__rsobj(tself((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyt__init__*scCs |i|S(N(R(Rtkey((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyt __getitem__/scCs ||ijS(N(R(RR((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyt __contains__2scCs:|io|iSti|i|iƒ}|pdS|S(s.Gets the proxy that was used at runtime for a given RepoStats object. This may differ from the persistent configuration of any given TransportRepoURI. We do not use the ds.runtime_proxy value, since that may include cleartext passwords.t-(tsystemtproxytmisctget_runtime_proxyturl(RtdsR ((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyt __get_proxy5s c Csµd}d}ti|dƒx‘|iiƒD]€}ti|id ƒ}ti|iƒ}|i|ƒ}ti||i||i |i |i |||i |i |if ƒq-WdS(s$Write the repo statistics to stdout.s7%-41.41s %-30s %-6s %-4s %-4s %-8s %-10s %-5s %-7s %-4ss7%-41.41s %-30s %-6s %-4s %-4s %-8s %-10s %-5s %-6f %-4stURLtProxytGoodtErrtConntSpeedtSizetUsedtCSpeedtQuals%(num).0f %(unit)s/sN( RRRRRRRRRR(R tmsgRtvaluest bytes_to_strttransfer_speedt bytes_xfrt_RepoChooser__get_proxyR tsuccesstfailurest num_connecttusedt connect_timetquality(RthfmttdfmtR tspeedstrtsizestrR ((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pytdumpFs   cCs§g}xg|D]_}|iƒ}||ijo|i|}nt|ƒ}||i|<|i||fƒq Wtg}|D]}|dio ||q~q~~ƒS(s-Walk a list of TransportRepoURIs and return the number that have been visited as an integer. If a repository is in the list, but we don't know about it yet, create a stats object to keep track of it, and include it in the visited count.i(RRt RepoStatstappendtlenR"(Rt repouri_listtfound_rstruriRtrst_[1]tx((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pytget_num_visitedYs   c Cs×g}d}d}d}d}d}d} xª|D]¢} | iƒ} | |ijog|i| } | idjo|| i7}|d7}n| idjo|| i7}|d7}qÓq1t| ƒ} | |i| ©streverse( RRRRR#R*R+t origin_speedt origin_cspeedt _err_decaytsorttTrue(RR-t origin_listR.R6t origin_counttorigin_avg_speedR7t origin_ccounttorigin_avg_cspeedtouriRR0R/((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyt get_repostatsmsN              cCs h|_dS(sClear all statistics count.N(R(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pytclear®scCs(x!|iiƒD]}|iƒqWdS(sreset each stats objectN(RRtreset(Rtv((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyRC³s(t__name__t __module__t__doc__RRRRR)R3R tEmptyIRARBRC(((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyR!s      A R*cBsFeZdZd„Zd„Zd„Zeeed„Zd„Zd„Z d„Z e d„ƒZ e d „ƒZ e d „ƒZe d „ƒZe d „ƒZe d „ƒZe d„ƒZe d„ƒZe d„ƒZe d„ƒZe d„ƒZe d„ƒZe d„ƒZe d„ƒZe d„ƒZe d„ƒZRS(svAn object for keeping track of observed statistics for a particular TransportRepoURI. This includes things like observed performance, availability, successful and unsuccessful transaction rates, etc. There's one RepoStats object per transport destination. This allows the transport to keep statistics about each host that it visits.cCsÔ|iidƒ|_ti|iƒd|_|i|_|i|_ |i |_ d|_ d|_ d|_d|_d|_d|_d|_d|_d|_t|_d|_d|_d|_d|_dS(s¡Initialize a RepoStats object. Pass a TransportRepoURI object in repouri to configure an object for a particular repository URI.t/igN(turitrstript_RepoStats__urlturlparseturlsplitt_RepoStats__schemetpriorityt_RepoStats__priorityR t_RepoStats__proxyRt_RepoStats__systemR8t_RepoStats__failed_txt_RepoStats__content_errt_RepoStats__decayable_errt_RepoStats__timeout_errt_RepoStats__total_txt_RepoStats__consecutive_errorst_RepoStats__connectionst_RepoStats__connect_timetFalset_RepoStats__usedt_RepoStats__bytes_xfrt_RepoStats__seconds_xfrR6R7(Rtrepouri((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyRÃs&                cCs d|_dS(s–Set the count of consecutive errors to zero. This is done once we know a transaction has been successfully completed.iN(RY(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pytclear_consecutive_errorsáscCs9|ip t|_n|id7_|i|7_dS(s'Record amount of time spent connecting.iN(R]R:RZR[(Rttime((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pytrecord_connectionès  cCs–|ip t|_n|id7_|o"|id7_|id7_n*|o|id7_n|id7_|o|id7_ndS(smRecord that an operation to the TransportRepoURI represented by this RepoStats object failed with an error. Set decayable to true if the error is a transient error that may be decayed by the stats framework. Set content to true if the error is caused by corrupted or invalid content.iN(R]R:RYRVR8RURTRW(Rt decayabletcontentttimeout((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyt record_errorñs  cCs9|ip t|_n|i|7_|i|7_dS(sARecord time and size of a network operation to a particular TransportRepoURI, represented by the RepoStats object. Place the number of bytes transferred in the bytes argument. The time, in seconds, should be supplied in the seconds argument.N(R]R:R^R_(Rtbytestseconds((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pytrecord_progress s  cCs*|ip t|_n|id7_dS(sgRecord that an operation to the URI represented by this RepoStats object was initiated.iN(R]R:RX(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyt record_txs  cCsUd|_d|_d|_d|_d|_d|_d|_d|_d|_dS(s8Reset transport stats in preparation for next operation.giN( R^R_RTRURVR8RXRYR6(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyRC!s        cCs|iS(s'Return the number of bytes transferred.(R^(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyR3scCsE|idjo'|io|idjodSdSn|i|iS(s*The average connection time for this host.igð?g(RZR]RWR[(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyR#9s cCs|iS(sUReturn the number of successive errors this endpoint has encountered.(RY(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pytconsecutive_errorsEscCs|i|i|iS(s‡Return the number of failures that the client has encountered while trying to perform operations on this repository.(RTRURV(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyR Ls cCs|iS(s™Return the number of content errors that the client has encountered while trying to perform operation on this repository.(RU(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pytcontent_errorsTscCs|iS(s¥Return the number of times that the host has had a connection established. This is less than or equal to the number of transactions.(RZ(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyR!\scCs|idjodS|iS(s3Return the priority of the URI, if one is assigned.iN(RQtNone(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyRPdscCs|iS(s4Return the scheme of the RepoURI. (e.g. http, file.)(RO(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pytschememsc sd‰d‰d}d}d}d}d}d}d}|id jo |i}n|}|id jo |i} n|} ‡‡fd †} | |ƒ||id |i|d ttid |ƒƒ||i| d ||id ||i |i d } t| ƒS( s*Return the quality, as an integer value, of the repository. A higher value means better quality. This particular implementation of quality() contains a random term. Two successive calls to this function may return different values.ii idiBiôièi †iicsCd}|i}|djodS|ˆjoˆˆ|dSdS(Nii(RX(Rttx(tCusedtNused(s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyt unused_bonus—s   gü©ñÒMbP?i( R6R7R^R_tinttrandomtgaussR#RURTR8( RtCspeedt Cconn_speedtCerrort Ccontent_errt Crand_maxt Cospeed_nonet Cocspeed_nonetospeedtocspeedRstq((RrRqs@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyR$ss&   ._cCs|iS(sfReturn the total amount of time elapsed while performing operations against this host.(R_(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyt seconds_xfrÉscCs|i|i|i|iS(s‡Return the number of successful transaction that this client has performed while communicating with this repository.(RXRTRURV(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyRÐscCs)|idjodSt|i|iƒS(sbReturn the average transfer speed in bytes/sec for operations against this uri.ig(R_tfloatR^(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyRÙscCs|iS(seReturn the URL that identifies the repository that we're keeping statistics about.(RL(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyR ãscCs|iS(s?Return the default proxy being used to contact the repository that we're keeping statistics about. Note that OS environment variables, "http_proxy", "https_proxy", "all_proxy" and "no_proxy" values will override this value in pkg.client.transport.engine.(RR(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyR êscCs|iS(sÆReturn whether these statistics are being used to track the system publisher, in which case, we always use the proxy provided rather than proxy environment variables.(RS(R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyRôscCs|iS(sgA boolean value that indicates whether the URI has been used for network operations.(R](R((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyR"üs(RERFRGRRaRcR\RgRjRkRCtpropertyRR#RlR RmR!RPRoR$RRRR R RR"(((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyR*ºs0       V   ( tostdatetimeRuRMtpkg.miscR tobjectRR*(((s@/usr/lib/python2.6/vendor-packages/pkg/client/transport/stats.pyts    ™