PSc1@s+ddkZddklZddklZddklZddklZddk l Z yddk Z Wne e fj onXddkZddkZddkZddkZddkZddkZddkZddkZddkZddkZddkZddkZddkZddkZddkZddkZddkZddk Z ddk!Z!ddk"Z"e#e_$e#e_%ddk&Z&ddk'Z'ddk(Z(ddk)i*Z*ddk+i,Z-ddk.i/Z/ddk0i1Z1ddk2i3Z3ddk4i5Z5ddk6Z(ddk7i8Z8ddk9i:i;Z<ddk=i:i>Z>ddk?i:i@ZAddkBZ(ddkClDZDlEZElFZFdeGfd YZHd eGfd YZId eIfd YZJddZKdeJfdYZLdefdYZMdefdYZNdeGfdYZOdS(iN(t HandlerTool(t serve_file(t formatdate(t SimplePlugin(t_HTTPErrorTemplate(tQueryt ParseErrortBooleanQueryExceptiontDummycBseZdZRS(s.Dummy object used for dispatch method mapping.(t__name__t __module__t__doc__(((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyRXst_DepotcBseZdZRS(s4Private, abstract, base class for all Depot classes.(R R R (((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyR ]st DepotHTTPcBseZdZddddddddd d d d d ddddgZdddddddd ddg ZdddddgZdCZdCZdCdZ dZ e dZ dZ dCdZdZdZeidZeiiddDgdZdZhed6e_d Zhed6e_d!Zhed6e_d"Zhed6e_d#Zhed6e_e d$Zd%Zhed6ed&6dEdFdGdHgd.6e_d/Z hed6e _d0Z!he"d16d2d36ed6e!_eiiddIdJdKgd4Z#eiiddLdMdNgd5Z$eiiddOdPdQgd6Z%eiiddRdSdTgd7Z&eiiddUdVdWgd8Z'd9Z(he"d16d2d36ed&6dXdYdZgd.6e(_d:Z)eiidd[d\d]gd;Z*eiidd^gd<Z+eiidde,i-fgd=Z.eiidde,i-fgd>Z/d?Z0eiidde,i-fgd@Z1eiidd_gdBZ2RS(`sThe DepotHTTP object is intended to be used as a cherrypy application object and represents the set of operations that a pkg.depotd server provides to HTTP-based clients.tversionstsearchtcatalogtinfotmanifesttfilelisttfiletopentappendtclosetabandontaddtp5it publishertindextstatustadminc Cs]tii|_||_||_d|_d|_||_|i dd}|i dd}|oTt i i |pt i i ||}n||_t i i |id|_nd|_d|_|i dd}|p)ti}titi|dtn||_ti||i|ip |i o;|i|_|ii dd p|ii dqn'|i!o|i"|_n |i#|_h}xp|i dd D]\}d |jo|i$d d \} } n |} d } |i%| g|| i&| qWh|_'xt(i)|t(i*D]\} } t+i,d| } | pq@n| i-d } | i-d} | |ijoq@n| |jo)| || jpd || joq@n|i.| t/| pq@nt| i0d<| |i'jo|i'| i&t/| nt1}t2|| |t/| g|i'| t6i;|_?|i?i<dS(sInitialize and map the valid operations for the depot. While doing so, ensure that the operations have been explicitly "exposed" for external usage. request_pub_func, if set is a function that gets called with cherrypy.request.path_info that returns the publisher used for a given request. itpkgt content_roottpkg_roottwebt writable_roott ignore_errorsRtprefixt disable_opst/it*s (.*)_(\d+)itexposedt.t_serror_page.defaulttsignal_handlertgracefulN(@RtnrlocktNRLockt_locktcfgtrepotflist_requeststflist_file_requeststrequest_pub_funct get_propertytostpathtisabstjoinR tweb_roottNonettempfiletmkdtemptatexittregistertshutiltrmtreetTruettmp_roottfacetinitt write_configtmirrortroottREPO_OPS_MIRRORtops_listtremovet read_onlytREPO_OPS_READONLYtREPO_OPS_DEFAULTtrsplitt setdefaultRtvopstinspectt getmemberstismethodtretmatchtgrouptsupportstintt__dict__Rtsetattrt publisherstreplacetgetattrtcherrypytconfigtupdatetdefault_error_pagethasattrtenginet subscribetrefreshtBackgroundTaskPlugint_DepotHTTP__bgtask(tselfR2tdconfR5R R!RDR&tentrytoptvertnametfunctmtopattrtpubtpubattr((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyt__init__s                           cCsGy|ii|iiWn&tij otiddnXdS(sQueues a background task to update search indexes. This method is a protected helper function for depot consumers.s<Skipping indexing; another operation is already in progress.tINDEXN(RitputR2t refresh_indextQueuetFullR`tlog(Rj((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyt_queue_refresh_indexs  cKs@ti}x,dD]$}||ijo|i|=qqWt|S(sThis function is registered as the default error page for CherryPy errors. This sets the response headers to be uncacheable, and then returns a HTTP response that is identical to the default CherryPy message format.s Cache-ControltPragma(s Cache-ControlR}(R`tresponsetheadersR(tkwargsR~tkey((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyRc s  cCs|io|itiiSy&tiiididd}Wntj odSX||ijo|djo|SdS(sPrivate helper function to retrieve the publisher prefix for the current operation from the request path. Returns None if a publisher prefix was not found in the request path. The publisher is assumed to be the first component of the path_info string if it doesn't match the operation's name. This does mean that a publisher can't be named the same as an operation, but that isn't viewed as an unreasonable limitation. R'itfeedN( R5R`trequestt path_infotstriptsplitt IndexErrorR<RO(Rjtreq_pub((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyt _get_req_pub.s c Cse|i}|p|iiidd}nd }|oOy|ii|}Wntj o }qX|i}|o |i}qn|d jo d}n|d jot ||f}nt i i } |djp|djp |djo,| t ||f}t ||f}n | |}t i i } d|| ds N(R:(RRmtvers((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pys s i,i,(t _DepotHTTP__set_response_expiresRtVERSIONR:RRt iteritems(RjRR((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyt versions_0s  cs:ti}d|id<|idddy|d}Wntj o d }nXtt|dtdti dd d d g}y"|i i |d |i Wn|t ij o$}titit|nKt ij o;}tid t|titit|nXfd }|S(sTBased on the request path, return a list of token type / FMRI pairs.stext/plain; charset=utf-8s Content-typeRiQitcase_sensitivet return_typet num_to_returnt start_pointRssRequest failed: %sc 3sxtD]\}}x|D]\}}}|\}}}ti|i}t|tiio+d|ii|i ||i |fVq d|||i |ii|i fVq Wq WdS(Ns %s %s %s %s ( t enumeratetactionstfromstrtrstript isinstancet attributetAttributeActiontattrstgettkey_attrRo( titresRRtvalstfmri_strtfvtlineta(tres_list(s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pytoutputs  N(R`R~RRRR<RRtFalsetRETURN_ACTIONSR2RRtsrepot RepositorySearchUnavailableErrorRRtSERVICE_UNAVAILABLEtRepositoryErrorR{R(RjRR~ttokentquery_args_lstRR((Rs6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pytsearch_0s*     sresponse.streamc sg}y|dg}Wntj onX|p|i}n1|io#titid||fn|ptitiny"|ii|d|iWnt t fj o$}titit |n}t i j o$}titit |nKt ij o;}tidt |titit |nXtdjoZy0di}ti|gdgWqtj otiti_dSXnti}d|id<|id d d fd }|S( sgBased on the request path, return a list of packages that match the specified criteria.isargs:%s, params:%sRssRequest failed: %siNstext/plain; charset=utf-8s Content-typeRiQc3sttidVxtD]\}}x|D]\}}}|tijo:|\}}}d|||ti||ifVq2|tijo|}d|||fVq2q2WqWdS(Nis%s %s %s %s %s s %s %s %s ( RRtVALIDATION_STRINGRRturllibtquoteRtRETURN_PACKAGES(RRRRRRRR(R(s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyRXs     (RtvaluesR`RRRR2RRRRRRRRRR{RRtnextt itertoolstchaint StopIterationt NO_CONTENTR~RRR(RjtargsRt query_str_lstRttmpR~R((Rs6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pytsearch_1!sF        cs ti}yiidi}WnJtij o;}tidt|ti t i t|nXti }d|i d[/]/admin/0?cmd=refresh-index Available commands are: rebuild Discard search data and package catalogs and rebuild both. rebuild-indexes Discard search data and rebuild. rebuild-packages Discard package catalogs and rebuild. refresh Update search and package data. refresh-indexes Update search data. (Add packages found in the repository to their related search indexes.) refresh-packages Update package data. (Add packages found in the repository to their related catalog.) tcmdR trebuildRst build_catalogt build_indexsrebuild-indexessrebuild-packagesRgRxsrefresh-indexessrefresh-packagess&Unknown or unsupported operation: '%s's:Another operation is already in progress; try again later.N(RRiRwR2R(RRCRt add_contentRxR`RRRRyRzR(RjRRR'((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pytadmin_0s<             cGsyti|dd}Wntj o d}nXy|ii|Wn3tij o$}ti t i t |nXdS(syAborts an in-flight transaction for the Transaction ID specified in the request path. Returns no output.iR N( RRRR<R2RRRR`RRRR(RjRR R((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyt abandon_09s c Gsyti|dd}Wntj o d }nXy|d}Wntj o d }nX|tijo#titi t d|nti }t d|i iD}x|D]}||ido||ido{y>ti||}t|tp tn||||]7\}}|iido|iddVqqWdS(sx-ipkg-setattrt=iN(tlowert startswithR(Rthdrtval((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pys gs  t[t]s9The specified Action attribute value, '%s', is not valid.sContent-Lengthspkg.sizesRequest failed: %sN( RRRR<RttypesR`RRRR+RtdictRtitemsR0tendswithtastt literal_evalRtlistRRZRtrfileRt ActionErrorR{R2RRR( RjRR t entry_typeRRRR2tdatatsizetactionR((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pytadd_0OsT   (    c Gsyti|dd}Wntj od}nXti}ti}t|ii dd}|djoti t i t dn|i}y|ii|||Wn3tij o$}ti t i t|nXd|id<|iS(sAdds a file to an in-flight transaction for the Transaction ID specified in the request path. The content is expected to be in the request body. Returns no output.iR sContent-Lengthsfile/1 must be sent a file.t0N(RRRR<R`RR~RZRRRRRR+R<R2tadd_fileRRRtbody(RjRR RR~R@R?R((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyt __upload_files$        c Gsy|d}Wntj o d}nXyc|djo&|ii|iid|in-d|}ti|tit i |Wn+t i j otit i dnXdS(sProvides an administrative interface for search indexing. Returns no output if successful; otherwise the response body will contain the failure details. iR RgRssUnknown index subcommand: %ss:Another operation is already in progress; try again later.N(RRiRwR2RxRR`R{RRRRyRzR(RjRR'terr((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pytindex_0s      cGsy|ii}WnAtj o5}tid|titit|nXg}|D] }||q_~}t |djo6|ddjo%|d|jo|dcd7Wtid t#|id S(s Initialize.tnastyt nasty_levelt nasty_sleepg?sNASTY Depot StartedsNASTY nasty=%d, nasty_sleep=%dstools.nasty_before.onstools.nasty_before.nasty_depoti iisNASTY Depot Error List: %sN($R RuRERFR2RGtrequested_filestrequested_catalogstrequested_manifestsRZR6RRt NASTY_CYCLEt nasty_cyclet maxroll_adjR`R{RRRt nasty_beforeRCRRtREQUEST_TIMEOUTt BAD_GATEWAYtGATEWAY_TIMEOUTRRRterrlistRtrangeRR(RjR2RkterrorstxtnR((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyRu's>                  cCs|ii|id|i|_d|iti|iti|i|_|idjot i dn|i|idjot i dn|ii dS(NiisNASTY nastiness at minisNASTY nastiness at max( R0RRRtNASTY_MULTIPLIERtmathtsintpiRR`R{R(Rj((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyRgs   idcCs>t||i}tid|}||ijotStS(s7Randomly returns true when the server should misbehave.i(RZRRRRRCR(RjRR((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyRs cCs|iddS(sNastiness sometimes.Ri(R(Rj((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyt need_nasty_2scCs|iddS(sNastiness less often.Ri(R(Rj((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyt need_nasty_3scCs|iddS(sNastiness very rarely.Ri N(R(Rj((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyt need_nasty_4scCs6ti|i}tid|ti|dS(s&Raise an http error from self.errlist.sNASTY: Random HTTP error: %dN(RRRR`R{R(Rjtcode((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyRscCs(tid|iti|idS(sSleep for a few seconds.sNASTY: sleep for %d secsN(R`R{RRtsleep(Rj((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyRscGsyt|d}Wn+ttfj otitinX|djp |djotitintid|||_dS(Niids%Nastiness set to %d by client request( RZRRR`RRRR{R(RjRR((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyRs stools.nasty_before.onRs Content-Typestext/plain; charset=utf-8c Gs|ioOtidti}ti|_tiddddddg|i d %s/%ds css<x5|].\}}d|did|DfVqWdS(s%s %sRcssx|]}t|VqWdS(N(R(RR((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pys s N(R:(RRmR((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pys s (RR`R{R~Rt UNAUTHORIZEDRRRRRRRRRRRRRZt normalvariateRR:( RjRR~RRmRtverlenRtoldv((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyRsV                  stools.nasty_before.maxrollcGstitidS(sProvide a full version of the catalog, as appropriate, to the requesting client. Incremental catalogs are not supported for v0 catalog clients.N(R`RRR(RjR((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyRs sresponse.streamc Gs,y|ii}WnAtj o5}tid|titit|nXg}|D] }||q_~}|ptiti t dnt |djo6|ddjo%|d|jo|dcd7N} || t| || d}qW||_n|i||_|iS(shA method that imitates the functionality of serve_file(), but behaves in a nasty manner.s Content-TypeRLiisContent-Lengths NASTY serve_file: truncated filesapplication/datas!NASTY serve_file: prepend garbagesNASTY!sNASTY serve_file: flip bitsiii(RR`R~RR7tstattst_sizeRtEnvironmentErrorRRRRRRRRCR`RERR{RRZtabstgaussRtmaxtordRtchr(RjRt content_typet already_nastyR~tfsttfilesztnfileREtncorruptRtptchartbit((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyRCsX        !    !  "'$ (s Content-Typestext/plain; charset=utf-8(s Content-Typesapplication/data(sPragmasno-cache(s Cache-Controlsno-cache, must-revalidate(sExpiresi(R R R RRRuRRRRRRRR`RRRRRRRRRCRRRRRRR(((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyRsR @        A   =  w  / &  t DNSSD_PlugincBs2eZdZdZdZdZdZRS(s/Allow a depot to configure DNS-SD through mDNS.cCsti||dtjod|_d|_dSdti|_|i|_d|_ |d|_ d|_ t |_|do|d o d }nd }d ti|i f}ti||d d d f|_dS(s|Bus is the cherrypy engine and gconf is a dictionary containing the CherryPy configuration. t pybonjourcSsdS(N(R<(((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pytscSsdS(N(R<(((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyRsNspkg(5) mirror on %ss _pkg5._tcpsserver.socket_portsserver.ssl_certificatesserver.ssl_private_keythttpsthttps%s:%sR (RRutglobalststarttexitRt gethostnameRot wanted_nametregtypetportR<tsd_hdlRtreg_oktgetfqdnturlparset urlunsplitturl(Rjtbustgconftprototnetloc((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyRus"          cCsu|tijo!|iidti|nt|_||_|i|ijo|iid|indS(sCallback invoked by service register function. Arguments are determined by the pybonjour framework, and must not be changed. s Error in DNS-SD registration: %ss"DNS-SD service name changed to: %sN( RtkDNSServiceErr_NoErrorRR{t BonjourErrorRCRRoR(RjRtflagst error_codeRoRtdomain((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pytreg_cbs    cCss|iidti}|i|ds+Returns an object representing a configuration interface for a a pkg(5) depot server. The class of the object returned will depend upon the specified configuration target (which is used as to retrieve and store configuration data). 'target' is the optional location to retrieve existing configuration data or store the configuration data when requested. The location can be None, the pathname of a file, or an SMF FMRI. If a pathname is provided, and does not exist, it will be created if needed. 'overrides' is a dictionary of property values indexed by section name and property name. If provided, it will override any values read from an existing file or any defaults initially assigned. 'version' is an integer value specifying the set of configuration data to use for the operation. If not provided, the version will be based on the target if supported. If a version cannot be determined, the newest version will be assumed. Rtaddresstcfg_filetallowedR s R tdebugRs hash=sha256shash=sha1+sha256shash=sha512_256shash=sha1+sha512_256R&t image_roots t inst_roott ll_mirrort log_accesststderrtstdouttnonet log_errorsRRHR!R'Rt proxy_basetreadonlytsocket_timeouttsort_file_max_sizet value_mapt ssl_cert_filet ssl_dialogstbuiltintsmfs t ssl_key_filetthreadsR#tpkg_buitfeed_descriptiont feed_iconsweb/_themes/pkg-block-icon.pngt feed_logosweb/_themes/pkg-block-logo.pngt feed_namespackage repository feedt feed_windowit pkg_securetssl_key_passphraseRRRi#icCs||p tid|id|d|S|ido#ti|d|id|d|Sti|d|id|d|S(Nt definitionst overridesRssvc:(R1tConfigt_DepotConfig__defsR0Rt FileConfig(tclsRR4R((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyt__new__{ sN(R R R R1tPropertySectiontPropListt PropDefinedtPropertytPropBooltPropIntt PropPubURItindexertSORT_FILE_MAX_SIZER6R<Rt EmptyDictR9(((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyR( sh                           "(PR`tcherrypy._cptoolsRtcherrypy.lib.staticRt email.utilsRtcherrypy.process.pluginsRtcherrypy._cperrorRRtOSErrort ImportErrorRR?R9RRRRRSRRR7RRVRAt simplejsonRRR R=RRRR<tpwdtgrpRRyRt pkg.actionsRt pkg.configRaR1tpkg.fmriRt pkg.indexerRAt pkg.manifestRtpkg.miscRt pkg.nrlocktpkg.p5iRtpkg.server.catalogtserverRRtpkg.server.faceREtpkg.server.repositoryRRt pkg.versiontpkg.server.query_parserRRRtobjectRR R RRRRhR(((s6/usr/lib/python2.6/vendor-packages/pkg/server/depot.pyts|                             #p^?