Rc@sddkZddkZddkZddkZddkZddkZddkZddkZddk Z ddk Z ddk i Z ddk iiZddkiiZddkiiiZddkiZddkZ ddkiiZddk ii!Z"ddk#l$Z$ddk%l&Z&de'fdYZ(de(fdYZ)de)fd YZ*d e(fd YZ+d e(fd YZ,de'fdYZ-de'fdYZ.de.fdYZ/de.fdYZ0de.fdYZ1de'fdYZ2dS(iN(t formatdate(tN_t TransportRepocBseZdZddddZdddddZddddeedZddddZdddZ ddddZ dddZ dddZ ddd Z d Zd Zddd Zdddd ZdddZdddZddedZddddZdddZdddZdddZdddZdddZdddZddddZdZeddZedZ eddZ!edZ"RS(sThe TransportRepo class handles transport requests. It represents a repo, and provides the same interfaces as the operations that are performed against a repo. Subclasses should implement protocol specific repo modifications.cCs tdS(sPerform a search request.N(tNotImplementedError(tselftdatatheadertccanceltpub((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt do_search8scCs tdS(soGet the catalog from the repo. If ts is defined, request only changes newer than timestamp ts.N(R(RttsRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt get_catalog=sc Cs tdS(sEGet the files that make up the catalog components that are listed in 'filelist'. Download the files to the directory specified in 'destloc'. The caller may optionally specify a dictionary with header elements in 'header'. If a conditional get is to be performed, 'ts' should contain a floating point value of seconds since the epoch. Revalidate and redownload are used to control upstream caching behavior, for protocols that support caching. (HTTP)N(R( RtfilelisttdestlocRR t progtrackRt revalidatet redownload((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt get_catalog1Cs cCs tdS(sVGet a datastream from a repo. The name of the file is given in fhash.N(R(RtfhashtversionRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytget_datastreamRscCs tdS(sGet multiple files from the repo at once. The files are named by hash and supplied in filelist. If dest is specified, download to the destination directory that is given. Progtrack is a ProgressTrackerN(R(RR tdestRRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt get_filesXscCs tdS(sGet a manifest from repo. The name of the package is given in fmri. If dest is set, download the manifest to dest.N(R(RtfmriRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt get_manifest`scCs tdS(sGet manifests named in list. The mfstlist argument contains tuples (fmri, header). This is so that each manifest may have unique header information. The destination directory is spec- ified in the dest argument.N(R(RtmfstlistRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt get_manifestsgscCs tdS(sLGet publisher configuration information from the repository.N(R(RRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytget_publisherinfooscCs tdS(sGet status from the repository.N(R(RRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt get_statususcCs tdS(sReturn's the Repo's URL.N(R(R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytget_urlzscCstS(s!Returns the repo's RepositoryURI.(R(R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytget_repouri_keyscCs tdS(sNQuery the repo for versions information. Returns a fileobject.N(R(RRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt get_versionsscCs tdS(sThe publish operation that adds content to a repository. The action must be populated with a data property. Callers may supply a header, and should supply a transaction id in trans_id.N(R(RtactionRRttrans_id((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt publish_addscCs tdS(N(R(RR RR!((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytpublish_add_filescCs tdS(sThe 'abandon' publication operation, that tells a Repository to abort the current transaction. The caller must specify the transaction id in trans_id. Returns a (publish-state, fmri) tuple.N(R(RRR!((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytpublish_abandonscCs tdS(sThe close operation tells the Repository to commit the transaction identified by trans_id. The caller may specify add_to_catalog, if needed. This method returns a (publish-state, fmri) tuple.N(R(RRR!tadd_to_catalog((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt publish_closescCs tdS(sBegin a publication operation by calling 'open'. The caller must specify the client's OS release in client_release, and the package's name in pkg_name. Returns a transaction-ID.N(R(RRtclient_releasetpkg_name((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt publish_openscCs tdS(sVAttempt to rebuild the package data and search data in the repository.N(R(RRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytpublish_rebuildscCs tdS(s5Attempt to rebuild the search data in the repository.N(R(RRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytpublish_rebuild_indexesscCs tdS(s6Attempt to rebuild the package data in the repository.N(R(RRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytpublish_rebuild_packagesscCs tdS(sVAttempt to refresh the package data and search data in the repository.N(R(RRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytpublish_refreshscCs tdS(s5Attempt to refresh the search data in the repository.N(R(RRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytpublish_refresh_indexesscCs tdS(s6Attempt to refresh the package data in the repository.N(R(RRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytpublish_refresh_packagesscCs tdS(sYSend data about operation intent without actually downloading a manifest.N(R(RRRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyttouch_manifestscCs tdS(sBased on existing header contents, build a header that should be used for a subsequent retry when fetching content from the repository.N(R(RR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytbuild_refetch_headerscCsx|D]}|ipqn|p,tiiti|id|_qn|i|jotid|in||i|_qW|S(sWalk a list of transport errors, examine the url, and add a field that names the request. This request information is derived from the URL.isNo mapping found for URL %s( turltostpathtbasenameturlparseturlsplittrequestttxtTransportOperationError(terrorstmappingte((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt_annotate_exceptionss c Csd}|p|Sddkl}l}|ti|}d}g}t||p |}n|id}xa|D]Y}xP|iD]E}|i |i jo,|i }|dj o|d|7}qqqWqyW|S(snParse a html document that contains error information. Return the html as a plain text string.i(tDocumenttparsettps %sN( tNonetxml.dom.minidomR?R@t cStringIOtStringIOt isinstancetgetElementsByTagNamet childNodestnodeTypet TEXT_NODEt nodeValue( tcontenttmsgR?R@tdomt paragraphsRBtctvalue((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt_parse_html_errors&    cCsg}x|D]}|p?ti|}|d}tii|}|i|q n||jotid|n||}|i|q W|S(sxTake a list of urls and remove the protocol information, leaving just the information about the request.isNo mapping found for URL %s(R6R7R3R4R5tappendR9R:(turllistR<treqlisttututuptreq((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt_url_to_requests    c Csd}d}d}d}td}td}td}td}d } |id } x| D]} | ii} | |jo| t|7} qd| |jo| t|7} qd| |jo| t|7} qd| |jo| t|7} qdqdW| d jod S| S( s Decode the X-Ipkg-Error header which is appended by the module doing entitlement checks on the server side. Let the user know why they can't access the repository. tENTtLICtSVRtMNTs This account is not entitled to access this repository. Ensure that the correct certificate is being used and that the support contract for the product being accessed is still valid. s The license agreement required to access this repository has not been accepted yet or the license agreement for the product has changed. Please go to https://pkg-register.oracle.com and accept the license for the product you are trying to access. s Repository access is currently unavailable due to service issues. Please retry later or contact your customer service representative. sg Repository access rights can currently not be verified due to server maintenance. Please retry later. RAt,N(Rtsplittstriptuppert_RC( t error_headertENTITLEMENT_ERRORt LICENSE_ERRORt SERVER_ERRORt MAINTENANCEtentitlement_err_msgtlicense_err_msgtserver_err_msgtmaintenance_msgRNt error_codesR=tcode((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt_analyze_server_error0s8         N(#t__name__t __module__t__doc__RCR R tFalseRRRRRRRRRRR"R#R$R&R)R*R+R,R-R.R/R0R1t staticmethodR>RSRZRo(((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR2sF     tHTTPRepoc BsfeZdZdZd'd'd'd'edZd'ed'eedZd'd'edZ d'd'd'd'd'ed'd'dZ dZ dZ d'd'dZ d'd'd'd Zd'd'd'd'd Zd'd'd'd'eed Zd'd'd'd Zd'd'd Zd'd'dZd'd'dZd'd'd'dZd'd'dZd'd'dZdZdZd'd'dZdZd'd'd'dZd'd'dZd'd'dZd'd'edZd'd'd'dZ dZ!d'd'd'dZ"d'd'dZ#d'd'dZ$d'd'd Z%d'd'd!Z&d'd'd"Z'd'd'd#Z(d$Z)d'd'd'd%Z*d&Z+RS((cCs+|i|_||_||_d|_dS(sCreate a http repo. Repostats is a RepoStats object. Repouri is a TransportRepoURI object. Engine is a transport engine object. The convenience function new_repo() can be used to create the correct repo.N(R2t_urlt_repourit_engineRCt_verdata(Rt repostatstrepouritengine((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt__init__js   cCsd|i|ifS(NsHTTPRepo url: %s repouri: %s(RvRw(R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt__str__vs cCsS|ii|d|d|d|d|id|d|d|iid|iidS( Ntfilepatht progclassRtrepourlRt compressiblet runtime_proxytproxy(Rxtadd_urlRvRwRR(RR2RRRRtcompress((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt _add_file_urlzs   cCsL|ii||d|id|d|d|d|iid|iid|S(NRRRt failonerrorRRtsystem(RxRRvRwRR(RR2RRRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt _fetch_urls   c Cs@|ii||d|id|d|d|iid|iiS(NRRRRR(Rxtget_url_headerRvRwRR(RR2RRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt_fetch_url_headers  c Csa|ii|d|d|d|id|d|d|d|d|d | d |iid |ii S( NRRRRt data_fobjtdata_fpRRRRR(Rxt send_dataRvRwRR( RR2RRRRRRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt _post_urls   cCszyt|_|iWnytij oj}|itijoKti \}}}y|i |i|_ Wq|d|qXnnXWd|i XdS(sParse the response body found accessible using the provided filestream object and raise an exception if appropriate.N(Rst free_buffertreadR9tTransportProtoErrorRnthttplibt BAD_REQUESTtsystexc_infoRStdetailsRCtclose(RtfobjR=texc_typet exc_valuetexc_tb((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt__check_response_bodys  cCs ||_dS(sPCache the information about what versions a repository supports.N(Ry(Rtverdict((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytadd_version_datascCs|ii}t|dd }|o\|id oK|id| o6|iddgdjoti||d}nti||}|p|St ti|}t i ||dRZtfailurestsuccesstreset(RR R RR RRRRtbaseurlRURtheadersttsstrtfR2tfnR=R;R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRsT            cCsb|djp|djpt|id|d|}ti||}|i||d|S(sVGet a datastream from a repo. The name of the file is given in fhash.iisfile/%s/RR(tAssertionErrorRR6RR(RRRRRRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRBs!cCs%|id}|i||d|S(s.Get publisher information from the repository.s publisher/0/R(RR(RRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRNscCs+|id}|i||d|dtS(s(Get configuration from the system depot.s syspub/0/RR(RRR(RRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytget_syspub_infoTscCs%|id}|i||d|S(s-Get status/0 information from the repository.sstatus/0R(RR(RRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRbscCsO|i}|idd|}ti||}|i||dtd|S(s\Get a package manifest from repo. The FMRI of the package is given in fmri.s manifest/0/RRR(t get_url_pathRR6RRR(RRRRRtmfstRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRhs  c Cs|idd|}h}d}|o t}nx||D]t\}} |i} ti|| } ||| RZRRR(RRRRRRt urlmappingRRthRR2RRUR=R;R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRss<             c Cs[|id|d|}g}d} |o t} nxg|D]_} ti|| } |i| tii|| } |i | d| d| d|d|q=Wy&x|i i o|i i qWWnst ij od} |i i|t\}}|i|}|i|}|| _|| _|i inX|i i|}|i|S(sMGet multiple files from the repo at once. The files are named by hash and supplied in filelist. If dest is specified, download to the destination directory that is given. If progtrack is not None, it contains a ProgressTracker object for the downloads.sfile/%s/RRRRRN(RRCt FileProgressR6RRTR3R4RRRxRRR9RRRR>RZRRR(RR RRRRRRRURRR2RR=R;R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRs8          cCs|iS(sReturns the repo's url.(Rv(R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRscCs |iiS(siReturns the repo's TransportRepoURI key, used to uniquely identify this TransportRepoURI.(Rwtkey(R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRsc Cs|id}|i||d|dt}y|iddWntij op}|iti joQt i \}}}y"|i |idd|_ Wq|d|qXnnX|S(sQuery the repo for versions information. Returns a fileobject. If server returns 401 (Unauthorized) check for presence of X-IPkg-Error header and decode.s versions/0/RRtoctopuss X-IPkg-ErrorN(RRRst getheaderRCR9RRnRt UNAUTHORIZEDRRRoR( RRRRRR=RRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRs   cCs |idj S(s8Returns true if this repo knows its version information.N(RyRC(R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pythas_version_datasc s|id }d }d }|o t}n|id}d||if} ti|| } |io|i}nd}tfdt D} |o| i |n|i | d| d|d|dt d |d |} |i | d S( sThe publish operation that adds content to a repository. The action must be populated with a data property. Callers may supply a header, and should supply a transaction id in trans_id.sadd/0/s%s/%sRAc3s7x0|])\}}d|d||ffVqWdS(sX-IPkg-SetAttr%ss%s=%sN((t.0Rtk(tattrs(s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pys &s RRRRRRN(RRCRRtnameR6RRtdictRRRRst_HTTPRepo__check_response_body( RR RRR!RRRRt request_strRRR((Rs?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR" s*    csh|id}ti||}tfdtD}|o|i|n|i|d|d|}|i|dS(sThe publish operation that adds content to a repository. The action must be populated with a data property. Callers may supply a header, and should supply a transaction id in trans_id.sfile/1/c3s7x0|])\}}d|d||ffVqWdS(sX-IPkg-SetAttr%ss%s=%sN((RRR(R(s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pys =s RRN(RR6RRRRRR(RtpthRR!RRRR((Rs?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR#2s c Cs|id}ti||}|i|d|dt}zy;t|_|i|idd}|idd}Wnyt i j oj}|i t i joKti\} } } y|i|i|_Wq| d| qXnnXWd|iX||fS(sThe 'abandon' publication operation, that tells a Repository to abort the current transaction. The caller must specify the transaction id in trans_id. Returns a (publish-state, fmri) tuple.s abandon/0/RRtStates Package-FMRIN(RR6RRRsRRRRCR9RRnRRRRRSRR( RRR!RRRtstatetpkgfmriR=RRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR$Gs*     c CsBh}|pd|d             cCs(|io|iid|_ndS(N(Rt reset_searchRC(R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt__del__s  cCs;|ii|d|d|d|d|id|dtdS(NRRRRRR(RxRRvRs(RR2RRRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRsc Cs.|ii||d|idtd|d|S(NRRRR(RxRRvRs(RR2RRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRs c Cs(|ii||d|id|d|S(NRRR(RxRRv(RR2RRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRscCs'|ii|iid|idS(sPrivate helper function that records a protocol error that was raised by the class instead of the transport engine. It records both that a transaction was initiated and that an error occurred.t decayableN(Rt record_txt record_errorR(RR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt__record_proto_errors cCs ||_dS(sPCache the information about what versions a repository supports.N(Ry(RR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRsc st|dd }y|ii|d|Wntij oDtidti dt dd|i }|i ||nt ij oF}tidtidt|d|i }|i ||nStj oF}tidtidt|d|i }|i ||nXtdjoiy0di}ti|gdgWqtj o&|iiti|i qXnfd } | S( sPerform a search against repo.RRRRsSearch temporarily unavailable.Riic3sttiidVxtD]\}}x|D]\}}}|tiijo:|\}}}d|||ti||ifVq5|tii jo|}d|||fVq5q5Wq"WdS(Nis%s %s %s %s %s s %s %s %s ( RtsqptQuerytVALIDATION_STRINGRtRETURN_ACTIONSRRtrstriptRETURN_PACKAGES(RtresRt return_typetvalstfmri_strtfvtline(tres_list(s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytoutputs"   N(RRCRtsearchRt RepositorySearchUnavailableErrorR9RR tEAGAINRcRvR RtQueryExceptionR RRRRtnextt itertoolstchaint StopIterationRRtapxtNegativeSearchResult( RRRRRRRR=ttmpR*((R)s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR s8          c Csg} d } t|dd } |o t} nx|D]} y@tidd ti|ii| d| d d d f} Wn[t i j oL}t i dt idt|d|id| }|i||nX| i| tii|| }|i| d|d|d |d | q6Wy&x|iio|iiq+WWnst ij od}|ii| t\}}|i|}|i|}||_||_ |ii!nX|ii| }|i|S( s%Get the files that make up the catalog components that are listed in 'filelist'. Download the files to the directory specified in 'destloc'. The caller may optionally specify a dictionary with header elements in 'header'. If a conditional get is to be performed, 'ts' should contain a floating point value of seconds since the epoch. This protocol doesn't implment revalidate and redownload. The options are ignored.RRRRRR8RRRRN("RCRtProgressCallbackR6RRt pathname2urlRt catalog_1RtRepositoryErrorR9RR RRRvR RTR3R4RRRxRRRRRR>RZRRR(RR R RR RRRRRURRRR2R=RRR;R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRsH             c Cs t|dd}y@tiddti|ii|d|dddf}Wnti j oL}t i dt i dt|d|id|} |i| | n\tij oL}t i dt idt|d|id|} |i| | nX|i||d|S( sVGet a datastream from a repo. The name of the file is given in fhash.RRRRRR8RN(RRCR6RRR7RRRtRepositoryFileNotFoundErrorR9RR tENOENTRRvR R9RR( RRRRRRRRR=R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR@s      cCsy/|ii}ti}ti||WnVtj oJ}d|}tidt i d|d|i }|i ||nX|i d|S(s.Get publisher information from the repository.s3Unable to retrieve publisher configuration data: %sRRRi(Rtget_publishersRERFtp5itwriteRR9RR RRvR tseek(RRRtpubstbufR=RR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRUs    c Csti}yB|ii}ti||dtdddt|idWnVt j oJ}d|}t i dt i d|d |i}|i||nX|id |S( s-Get status/0 information from the repository.t ensure_asciitindentit sort_keyss s"Unable to retrieve status data: %sRRRi(RERFRRtjsontdumpRsRR>RR9RR RRvR R?(RRRRAtrstatusR=RR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRfs     c Cst|dd}y@tiddti|ii|d|dddf}Wnati j oR}t i dt i dt|d|idt|}|i||nX|i||d|S( seGet a manifest from repo. The fmri of the package for the manifest is given in fmri.RRRRRR8RN(RRCR6RRR7RtmanifestRR9R9RR RRRvR R( RRRRRRRR=R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRxs $  cCs+h}d }t|dd }|o t}ng}x |D]\} } y@tidd ti|ii| d|d d d f} Wnkt i j o\} t i dt idt| d|idt| } |i| |i| q<nX| || textendRZRRR(RRRRRRRRtpre_exec_errorsRRR2R=RRRUR;R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRsR   %            cCskg}d }t|dd } |o t}ng} xa|D]Y} y@tidd ti|ii| d| d d d f} Wnt i j oV} t i dt idt| d|id| }|i|| i|q<nft ij oV} t i dt idt| d|id| }|i|| i|q<nX|i| tii|| }|i| d|d|d |d |q<Wy&x|iio|iiqWWnt ij oq} |ii|t\}}|i|}|i | |i!|}|| _"|| _#|ii$nX|ii|}|i|}|| S( sMGet multiple files from the repo at once. The files are named by hash and supplied in filelist. If dest is specified, download to the destination directory that is given. If progtrack is not None, it contains a ProgressTracker object for the downloads.RRRRRR8RRRRN(%RCRRR6RRR7RRRR:R9RR R;RRvR RTR9RR3R4RRRxRRRRRR>RIRZRRR(RR RRRRRRURRRJRR2R=RRR;R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRs`                  cCs|iS(sReturns the repo's url.(Rv(R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRscCs |iiS(sXReturns a key from the TransportRepoURI that can be used in a dictionary(RwR(R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRscCsti}h dgd6dgd6dgd6dgd6dgd6dgd6ddgd 6dgd 6dgd 6ddgd 6dgd 6dgd6dgd6}|idti|idid|iDd|id|ii |S(sTQuery the repo for versions information. Returns a file-like object.t0tabandontaddRRTt1tcatalogRRRHtopenRR+tstatustversionsspkg-server %s s css2x+|]$\}}d|di|fVqWdS(s%s %st N(R(RRtvers((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pys ;s i( RERFR>tpkgtVERSIONRt iteritemsR?RR(RRRRAtvops((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR$s.                 cCs |idj S(s8Returns true if this repo knows its version information.N(RyRC(R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRBscCst|i_d}|ot}||}ny|ii||WnBtij o3}|o|int i t |n>X|o5t |i idd}|idd||ndS(s6The publish operation that adds an action and its payload (if applicable) to an existing transaction in a repository. The action must be populated with a data property. Callers may supply a header, and should supply a transaction id in trans_id.spkg.sizeiN(RsRRRCRRMRR9tabortR9R:RtintRRtprogress_callback(RR RRR!RR=tsz((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR"Gs cCsKy|ii||Wn-tij o}tit|nXdS(sRThe publish operation that adds a file to an existing transaction.N(Rtadd_fileRR9R9R:R(RRRR!R=((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR#bscCs\t|i_y|ii|}Wn-tij o}tit|nXd|fS(sThe abandon operation, that tells a Repository to abort the current transaction. The caller must specify the transaction id in trans_id. Returns a (publish-state, fmri) tuple.N( RsRRRLRR9R9R:RRC(RRR!t pkg_stateR=((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR$ks  cCsht|i_y"|ii|d|\}}Wn-tij o}tit|nX||fS(sThe close operation tells the Repository to commit the transaction identified by trans_id. The caller may specify add_to_catalog, if needed. This method returns a (publish-state, fmri) tuple.R%( RsRRRRR9R9R:R(RRR!R%tpkg_fmriR^R=((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR&{s cCsYt|i_y|ii||}Wn-tij o}tit|nX|S(sBegin a publication operation by calling 'open'. The caller must specify the client's OS release in client_release, and the package's name in pkg_name. Returns a transaction-ID string.( RsRRRPRR9R9R:R(RRR'R(R!R=((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR)s  cCsYt|i_y|ii||}Wn-tij o}tit|nX|S(N( RsRRRTRR9R9R:R(RRR'R(R!R=((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRs  c Csut|i_t|dd}y#|iid|dtdtWn-tij o}t i t |nXdS(sVAttempt to rebuild the package data and search data in the repository.RRt build_catalogt build_indexN( RsRRRRCRRRR9R9R:R(RRRRR=((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR*s c Csut|i_t|dd}y#|iid|dtdtWn-tij o}t i t |nXdS(s5Attempt to rebuild the search data in the repository.RRR`RaN( RsRRRRCRRRR9R9R:R(RRRRR=((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR+s c Csut|i_t|dd}y#|iid|dtdtWn-tij o}t i t |nXdS(s6Attempt to rebuild the package data in the repository.RRR`RaN( RsRRRRCRRRR9R9R:R(RRRRR=((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR,s cCsot|i_t|dd}y|iid|dtWn-tij o}t i t |nXdS(sVAttempt to refresh the package data and search data in the repository.RRt refresh_indexN( RsRRRRCt add_contentRRR9R9R:R(RRRRR=((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR-s  cCsQt|i_y|iiWn-tij o}tit|nXdS(s5Attempt to refresh the search data in the repository.N( RsRRRbRR9R9R:R(RRRR=((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR.s  cCsot|i_t|dd}y|iid|dtWn-tij o}ti t |nXdS(s6Attempt to refresh the package data in the repository.RRRbN( RsRRRRCRcRR9R9R:R(RRRRR=((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR/s  cCsQ|i p||ijodSx'|D]}||i|jo|Sq*WdS(sReturns version-id of highest supported version. If the version is not supported, or no data is available, -1 is returned instead.i(RRy(RRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRs cCstS(sNo-op for file://.(R(RRRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR0 scCs|S(sRPointless to attempt refetch of corrupt content for this protocol.((RR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR1sN((RpRqRrRCR}RRsRRRRR RR RRRRRRRRRRRR"R#R$R&R)RR*R+R,R-R.R/RR0R1(((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRjsT .     :BDL           t _ArchiveRepocBseZdZdZdZdZddddeedZddddZ dddZ ddddZ dddZ ddd Z d Zd Zddd Zd ZdZddddZdZRS(ssPrivate implementation of transport repository logic for repositories contained within an archive. c CsVd|_|i|_||_||_d|_||_ymti|ii ddd\}}}}}} t i |i t ii}tii|dd|_Wntiij oF} tidtidt| d|i} |i| | nStj oF} tidtidt| d|i} |i| | nXdS( sCreate a file repo. Repostats is a RepoStats object. Repouri is a TransportRepoURI object. Engine is a transport engine object. The convenience function new_repo() can be used to create the correct repo.RRitmodetrRRN(RCt_arcR2RvRwRxRyt_ArchiveRepo__statsR6RRRR!R3R4tsepRUtp5ptArchivetInvalidArchiveR9RR R Rt _ArchiveRepo__record_proto_errorRR( RRzR{R|RRR4RRRR=R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR}s*         cCs'|ii|iid|idS(sPrivate helper function that records a protocol error that was raised by the class instead of the transport engine. It records both that a transaction was initiated and that an error occurred.RN(RhRRR(RR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR;s cCs ||_dS(sPCache the information about what versions a repository supports.N(Ry(RR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRDsc  CsRt|dd} g} x3|D]+} yY|ii| |d| |o5titii|| } |i|| i nWqt i i j oV} t idtidt| d|id| }|i|| i|qqtj oV} t idtidt| d|id| }|i|| i|qqXqW| S(s%Get the files that make up the catalog components that are listed in 'filelist'. Download the files to the directory specified in 'destloc'. The caller may optionally specify a dictionary with header elements in 'header'. If a conditional get is to be performed, 'ts' should contain a floating point value of seconds since the epoch. This protocol doesn't implment revalidate and redownload. The options are ignored.RRRRRR8N(RRCRgtextract_catalog1R3tstatR4Rtrefresh_progresstst_sizeRURjtUnknownArchiveFilesR9RR R;RRvRmRTRR(RR R RR RRRRRR;RtfsR=R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRJs4         c Cst|dd}y|ii|d|SWntiij oL}tidt i dt |d|i d|}|i ||nYtj oL}tidt idt |d|i d|}|i ||nXdS(sVGet a datastream from a repo. The name of the file is given in fhash.RRRRRR8N(RRCRgtget_package_fileRURjRrR9RR R;RRvRmRR( RRRRRRRR=R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRps    cCsy/|ii}ti}ti||WnVtj oJ}d|}tidt i d|d|i }|i ||nX|i d|S(s.Get publisher information from the repository.s3Unable to retrieve publisher configuration data: %sRRRi(RgR<RERFR=R>RR9RR RRvRmR?(RRRR@RAR=RR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRs    c Csy|ii|dtSWntiij oL}tidti dt |d|i d|}|i ||nYt j oL}tidtidt |d|i d|}|i ||nXdS(seGet a manifest from repo. The fmri of the package for the manifest is given in fmri.trawRRRR8N(Rgtget_package_manifestRRURjtUnknownPackageManifestR9RR R;RRvRmRR(RRRRRR=R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRs   c CsOg}xB|D]:\}}yb|ii||d|i|o8titii||i}|idtnWq t i i j oV} t i dtidt| d|id|} |i| |i| q q tj oV} t i dtidt| d|id|} |i| |i| q q Xq W|S(sGet manifests named in list. The mfstlist argument contains tuples (fmri, header). This is so that each manifest may have unique header information. The destination directory is spec- ified in the dest argument.tfilenamet completionRRRR8(Rgtextract_package_manifestRR3RoR4Rtmanifest_fetch_progressRRURjRwR9RR R;RRvRmRTRR( RRRRRR;RRRsR=R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRs4          c CsUt|dd}g}x6|D].} y\|ii| g|d||o5titii|| } |id| i nWqt i i j oV} t idtidt| d|id| } |i| |i| qqtj oV} t idtidt| d|id| } |i| |i| qqXqW|S( sMGet multiple files from the repo at once. The files are named by hash and supplied in filelist. If dest is specified, download to the destination directory that is given. If progtrack is not None, it contains a ProgressTracker object for the downloads.RRiRRRR8N(RRCRgtextract_package_filesR3RoR4Rtdownload_add_progressRqRURjRrR9RR R;RRvRmRTRR( RR RRRRRRR;RRsR=R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRs4        cCs|iS(sReturns the repo's url.(Rv(R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRscCs |iiS(s!Returns the repo's RepositoryURI.(RwR(R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRscCsti}hdgd6dgd6dgd6ddgd6dgd6}|idti|id id |iDd |id |ii |S( sTQuery the repo for versions information. Returns a file-like object.RNRORKRRHRRRspkg-server %s s css2x+|]$\}}d|di|fVqWdS(s%s %sRSN(R(RRRT((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pys s i( RERFR>RURVRRWR?RhR(RRRRARX((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRs         cCs |idj S(s8Returns true if this repo knows its version information.N(RyRC(R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRscCsQ|i p||ijodSx'|D]}||i|jo|Sq*WdS(sReturns version-id of highest supported version. If the version is not supported, or no data is available, -1 is returned instead.i(RRy(RRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR s cCstS(sNo-op.(R(RRRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR0scCs|S(sTPointless to attempt refetch of corrupt content for this protocol.((RR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR1"sN(RpRqRrR}RmRRCRsRRRRRRRRRRRR0R1(((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRds& " %  "    tFileRepocBseZdZddZRS(sqFactory class for creating transport repository objects for filesystem-based repository sources. c Csy@ti|iddd\}}}}} } ti|}Wnbtj oV} tidtidt | d|i } |i |i d| i | nX| o3tii|itiiot|||St|||d|S(sReturns a new transport repository object based on the provided information. 'repostats' is a RepoStats object. 'repouri' is a TransportRepoURI object. 'engine' is a transport engine object. 'frepo' is an optional Repository object to use instead of creating one. The convenience function new_repo() can be used to create the correct repo.RRiRRRR(R6RRRRR9RR RRR2RRRR3R4tisfileR!RiRdR( tclsRzR{R|RRRR4RRRR=R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt__new__-s  *N(RpRqRrRCR(((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR~(sR6cBs2eZdZdZdZdZdZRS(s<This class bridges the interfaces between a ProgressTracker object and the progress callback that's provided by Pycurl. Since progress callbacks are per curl handle, and handles aren't guaranteed to succeed, this object watches a handle's progress and updates the tracker accordingly.cCs ||_dS(N(R(RR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR}]scCsdS(sDownload failed.N((R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRY`scCsdS(skThis download has succeeded. The size argument is the total size that the client received.N((Rtsize((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytcommitdscCs,t|ido|iiodSdS(sOCalled by pycurl/libcurl framework to update progress tracking.tcheck_cancelationii(thasattrRR(Rtdltottdlcurtultottulcur((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR[is(RpRqRrR}RYRR[(((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR6Vs    RcBs2eZdZdZdZdZdZRS(sThis class bridges the interfaces between a ProgressTracker's refresh code and the progress callback for that's provided by Pycurl.cCs/ti||d|_d|_t|_dS(Ni(R6R}tdltotalt dlcurrentRst completed(RR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR}ws  cCs$|iid|i t|_dS(snDownload failed. Remove the amount of bytes downloaded by this file from the ProgressTracker.N(RRpRCRRR(R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRY}scCsdS(N((RR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRscCst|ido|iiodS|i|jo ||_nt||i}|djo&|i|7_|iid|ndS(sOCalled by pycurl/libcurl framework to update progress tracking.RiiN(RRRRRZRRpRC(RRRRRt new_progress((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR[s  (RpRqRrR}RYRR[(((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRss    RcBs)eZdZdZdZdZRS(sThis class bridges the interfaces between a ProgressTracker's manifest fetching code and the progress callback for that's provided by Pycurl.cCsdS(snDownload failed. Remove the amount of bytes downloaded by this file from the ProgressTracker.N((R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRYscCs|iidtdS(s*Indicate that this download has succeeded.RyN(RR{R(RR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRscCs?t|ido|iiodS|iidtdS(sOCalled by pycurl/libcurl framework to update progress tracking.RiRyi(RRRR{Rs(RRRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR[s (RpRqRrRYRR[(((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRs  RcBs2eZdZdZdZdZdZRS(sThis class bridges the interfaces between a ProgressTracker object and the progress callback that's provided by Pycurl. Since progress callbacks are per curl handle, and handles aren't guaranteed to succeed, this object watches a handle's progress and updates the tracker accordingly. If the handle fails, it will correctly remove the bytes from the file. The curl callback reports bytes even when it doesn't make progress. It's necessary to keep additonal state here, since the client's ProgressTracker has global counts of the bytes. If we're unable to keep a per-file count, the numbers will get lost quickly.cCsAti||d|_d|_d|_d|_t|_dS(Ni(R6R}RRtultotalt ulcurrentRsR(RR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR}s     cCs8|iid|i |ii|i t|_dS(snDownload failed. Remove the amount of bytes downloaded by this file from the ProgressTracker.iN(RR}Rtupload_add_progressRRR(R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRYscCs3t||i}|iid|t|_dS(szIndicate that this download has succeeded. The size argument is the total size that we received. Compare this value against the dlcurrent. If it's out of sync, which can happen if the underlying framework swaps our request across connections, adjust the progress tracker by the amount we're off.iN(RZRRR}RR(RRt adjustment((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRscCst|ido|iiodS|iodS|i|jo ||_nt||i}|djo&|i|7_|iid|n|i|jo ||_nt||i }|djo#|i |7_ |ii |ndS(sOCalled by pycurl/libcurl framework to update progress tracking.Rii( RRRRRRZRR}RRR(RRRRRR((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR[s$     (RpRqRrR}RYRR[(((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyRs     t RepoCachecBsreZdZhed6ed6ed6Zhed6ZdZdZ dZ dZ dZ d d d ZRS( sAn Object that caches repository objects. Used to make sure that repos are re-used instead of re-created for each operation. The objects are keyed by TransportRepoURI.key() objects.RthttpthttpscCs||_h|_dS(s&Caller must include a TransportEngine.N(t_RepoCache__enginet_RepoCache__cache(RR|((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyR} s cCs|i|ijS(N(RR(RR{((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt __contains__ scCs h|_dS(s Flush the contents of the cache.N(R(R((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pyt clear_cache scCs|i}|tijotid|n|i|ijo|i|iSti||||i}||i|i<|S(s6Create a new repo server for the given repouri object.s%Scheme %s not supported by transport.(RRtsupported_schemesR9R:RRR(RRzR{Rtrepo((s?/usr/lib/python2.6/vendor-packages/pkg/client/transport/repo.pytnew_repo! s   cCs|i}|tijodS|i|ijo!|i|i}||_dSti||||id|}||i|isH           77.-J