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/21585/root/usr/lib64/python2.4/site-packages/sabayon/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/21585/root/usr/lib64/python2.4/site-packages/sabayon/cache.pyc
mς
»fEOc@sΜdkZdkZdkZdkZdkZdkZdkZdkZd„Zd„Z	dfd„ƒYZ
dad„Z
d„Zd„Zeiedƒd	„Zd
„ZedjoeƒndS(NcGstiti||ƒdS(N(tutiltdebug_printtDEBUG_CACHEtfmttargs(RR((t3/usr/lib64/python2.4/site-packages/sabayon/cache.pytdprintscCs
tiƒS(N(Rtget_home_dir(((RRstcacheRepositorycBs\tZdZed„Zd„Zd„Zd„Zd„Zed„Z	d„Z
d„ZRS(	sThis is a remote resource cache, based on Python native urllib2
       and implementing a local cache for remote resources. It will 
       provide access to copies of the resources if unavailable and
       try to transfer only files remotely modified from the cache.cCs.d}d|_d|_d|_||_dS(N(tNonetinfotselft	directorytcatalogtroottorig_directory(RRR
((Rt__init__&s
			cCs#yΐti|ƒ}ti|dƒp|dtiƒjotd|ƒ|pdSnyFdk	}|i
|tƒti|ƒtd|ƒti|ƒ}WqΏtd|ƒdSqΏXnWn\td|ƒy-ti|ƒtd|ƒti|ƒ}Wqtd|ƒdSqXnX|S(NiisFile %s is not a directorysRecreated directory %ssFailed to create directory %ssFailed to check directory %ssCreated directory %s(
toststatRR
tS_ISDIRtgetuidRt
remove_oldR	tshutiltrmtreetTruetmkdir(RRRR
R((Rt__ensure_directory.s2,
	






cCs|i}|djo-|i|tƒ}|djo
d}qCn|djoG|itƒdtƒ}|o#tƒd}|i|tƒ}q—n|djot
dƒd|_dSn
||_ti|dƒti
titijoZt
d|ƒy%ti|ti
titiƒWqMt
d|ƒd|_dSqMXn|idjot
dƒdSn|id}yti|dtiƒ|_Wnt
d|ƒd|_nX|idjoX|iiƒ}|p|id	jo$t
d
ƒ|iiƒd|_q$||_n|idjp#|idjp|iidjo&yti|idƒWq}q}XndS(Ns	/.sabayons/.sabayon/profile_cachesRunning with cache deactivatedisWrong mode for %ssFailed to chmod %s, ignoreds/catalog.xmlsFailed to load catalog from %sR
sDiscarding corrupted catalog(RRRR	t"_cacheRepository__ensure_directorytFalseR
RRtparent_infoRRtS_IMODEtS_IRUSRtS_IWUSRtS_IXUSRRtchmodtcatalogfiletlibxml2treadFiletXML_PARSE_NOBLANKSR
tgetRootElementRtnametfreeDoctchildrentunlink(RR
R#RRR((Rt__check_directoryIsZ	





		+
%
	






3cCs.ti|ddƒ}ti|ddƒ}|S(s7Function to convert an URL to a local name in the caches//t_t/N(tstringtreplacetURL(RR1((Rt
__URL_mappingscCsΑ|idjp#|idjp|iidjo*yti|idƒWnnXdSn|idjoP|idjo@t|iddƒ}|i
|iiddƒƒ|iƒndS(s&Save the on disk catalog in XML formats/catalog.xmlNtwtformati(
RR
R	RR*RR+Rtopentftwritet	serializetclose(RR6((Rt__save_catalog‡s3 cCsž|djodSnd}|idjo7tidƒ|_|iidddƒ|_d}n|idjodSny|ii	d|ƒd}Wn
d}nX|djoY|iidddƒ}|id|ƒ|djo
d	}n|id
|ƒd}nr|i
dƒ|jo[|djo4||i
d
ƒjo|id
|ƒd}q{q|id
d	ƒd}n|djo|iƒndS(sBUpdate the catalog of resources in the cache with an updated entryNis1.0R
is/catalog/entry[@URL = '%s']tentryR1tt	timestamp(R1R	tmodifiedRR
R$tnewDoctnewChildRt	xpathEvaltchildtsetPropR=tpropt_cacheRepository__save_catalog(RR1R=RBR>((Rt__update_catalog–s<









cCs­|idjodSny|iid|ƒd}WndSnX|id|i|ƒ}yt	i
|ƒ}Wn,td|ƒ|i
ƒ|iƒdSnX|idƒS(sαlookup an entry in the catalog, it will return a tuple of the
	   file path and the timestamp if found, None otherwise. If the
	   file is referenced in the cache but has not timestamp then it
	   will return an empty string.s/catalog/entry[@URL = '%s']iR.s"Local cache file for %s disapearedR=N(RRR	RAR1RBRt_cacheRepository__URL_mappingtfilenameRRR
Rt
unlinkNodetfreeNodeRD(RR1R
RHRB((Rt__catalog_lookup»s 


c
Cs"d
}y.ti|ƒ}|d|jo
|}nWn
|}nX|d
jo@|ddjod
Sny|SWqtd|ƒd
SqXnŽ|iƒ|id|i	|ƒ}
|i|ƒ}d
}yAti|ƒ}|d
jo!|djo|id|ƒnWntd|ƒd
SnXyYtiƒ}|i|ƒ}y|iid}Wn
d
}nX|iƒ}|iƒWnCtd	ƒyti|
ƒ}|
SWqΕtd
|
ƒd
SqΕXnXy:t|
dƒ}	|	i|ƒ|	iƒ|i ||ƒWntd|
ƒd
SnX|
Sd
S(sφGet a resource from the cache. It may fetch it from the network
	   or use a local copy. It returns a Python file liek open() would.
	   If passed a filename it will accept it if absolute.
	   The return value is an absolute path to a local file.iiR.sFailed to read %sR<sIf-Modified-SincesFailed to create request for %ss
last-modifieds+Resource not available or older using cachesFailed to find cache file %sR3sFailed to write cache file %sN(!R	tfileturlparseR1tdecompRRt!_cacheRepository__check_directoryRRGRHt _cacheRepository__catalog_lookupR=t
last_modifiedturllib2tRequesttrequestt
add_headertbuild_openertopenerR5t
datastreamtheaderstdicttreadtdataR9RRR
tfdR7t _cacheRepository__update_catalog(
RR1R
R=RTRQRXRWRLR]RHR\RN((Rtget_resourceΠsj










(t__name__t
__module__t__doc__R	RRRORGRER^RPR_(((RR!s		8		%	cCs+tdjotƒatitƒntS(N(t
default_cacheR	RR$tsetEntityLoadertlibxml2_entity_loader(((Rtget_default_caches

	cCsYtd||ƒtƒ}|i|ƒ}yt|ƒ}td|ƒWn
d}nX|S(Ns&Cache entity loader called for %s '%s's"Cache entity loader resolved to %s(
RR1tIDRft	the_cacheR_RLR5R]R	(R1RgtctxtRhR]RL((RRes	
cCsdS(N((tctxtstr((Rtlibxml2_no_error_callback%sR<cCstƒtitƒdS(N(RfR$RdRe(((Rt
initialize*scs•dk‰dk‰dk}dk‰dk}dk}	dˆif‡d†ƒY‰‡‡‡d†}d}|i
|tƒˆi|ƒt
|ddƒidƒ|i||fƒ}d}
|i
|
tƒt|
ƒ}|i|dƒ}|djpt‚t
|ƒiƒ}|djpt‚td	ƒ|id
ƒ}|djpt‚tdƒ|	idƒ|id
ƒ}|djpt‚t
|ƒiƒ}|djpt‚tdƒ|id
ƒ}|djpt‚t
|ƒiƒ}|djpt‚tdƒ~t|
ƒ}|id
ƒ}|djpt‚t
|ƒiƒ}|djpt‚tdƒ|i
|tƒ|i
|
tƒdS(Nttest_http_handlercstZ‡d†Zd„ZRS(Ncsˆii|ƒdS(N(tSimpleHTTPServertSimpleHTTPRequestHandlertdo_GETR(R(Ro(RRq8scGsdS(N((RR4R((Rtlog_message;s(R`RaRqRr((Ro(RRn7scsKˆi|ƒd}ˆi|ˆƒ}td|ƒ|i	ƒtdƒdS(NR<i@sstarting HTTP on %ssstopping HTTP server(R<i@(
Rtchdirtwwwtserver_addresstBaseHTTPServert
HTTPServerRnthttpdRthandle_request(RtRxRu(RnRvR(Rtrun_http_server>s

s/tmp/sabayon_http_tests/fooR3tcontents/tmp/cache_testsabsolute local path okaytfoosrelative path okayf0.5shttp://localhost:8000/foosfirst HTTP access okayssecond cached HTTP access okays!New cache cached HTTP access okay(RvRoRRtthreadttimeRpRnRzRtRRRR5R7tstart_new_threadtservertdirRtcacheR_R6R	tAssertionErrorR[R\Rtsleep(RtR‚R6R}RoRnR€RzR\R~RvRRR((RoRnRvRRtrun_unit_tests/sX						






t__main__(RRRMRRRR/R$tStringIORRRR	RcRfReRltregisterErrorHandlerRmR…R`(RfRRR/R‡R…R$RmRRRRMRRlReRR((Rt?s&										λ					H


Anon7 - 2021