ó -x0Nc@sXdZddlZddlZddlZddlmZddljZddlj Z ddl j j ZddljjZddljjZdefd„ƒYZdefd„ƒYZdefd „ƒYZd efd „ƒYZd efd „ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZ defd„ƒYZ!dS(sØProvides a set of publishing interfaces for interacting with a pkg(5) repository. Note that only the Transaction class should be used directly, though the other classes can be referred to for documentation purposes.iÿÿÿÿN(t EmptyDicttTransactionErrorcBs)eZdZd„Zd„Zd„ZRS(s4Base exception class for all Transaction exceptions.cOs3tj||Œ|r&|d|_n||_dS(Ni(t Exceptiont__init__tdatat_args(tselftargstkwargs((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyR-scCs t|ƒS(N(tstr(R((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyt __unicode__3scCs t|jƒS(N(R R(R((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyt__str__9s(t__name__t __module__t__doc__RR R (((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyR*s  t TransactionRepositoryConfigErrorcBseZdZRS(s„Used to indicate that the configuration information for the destination repository is invalid or is missing required values.(R R R(((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyR=stTransactionRepositoryURLErrorcBs eZdZd„Zd„ZRS(sÁUsed to indicate the specified repository URL is not valid or is not supported (e.g. because of the scheme). The first argument, when initializing the class, should be the URL.cOstj|||ŽdS(N(RR(RRR((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyRHscCsƒd|jkr5tdƒi|jdd6|jd6Sd|jkrUtdƒ|jStdƒi|jd6|jjddƒd6S( Ntschemes2Unsupported scheme '%(scheme)s' in URL: '%(url)s'.turltnetlocsMalformed URL: '%s'.s*Invalid repository URL: '%(url)s': %(msg)stmsgt(Rt_Rtget(R((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyR Ks   (R R RRR (((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyRBs tTransactionOperationErrorcBseZdZd„ZRS(s¨Used to indicate that a transaction operation failed. The first argument, when initializing the class, should be the name of the operation that failed.cCsd|jkratdƒi|jd6|jjddƒd6|jdd6|jjddƒd6S|jjddƒr²tdƒi|jd6|jdd6|jjddƒd6S|jrétdƒi|jd6|jjddƒd6Std ƒ|jjddƒS( NtstatussO'%(op)s' failed for transaction ID '%(trans_id)s'; status '%(status)s': %(msg)stopttrans_idRRs:'%(op)s' failed for transaction ID '%(trans_id)s': %(msg)ss8'%(op)s' failed; unable to initiate transaction: %(msg)ss"Unable to initiate transaction: %s(RRRRtNone(R((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyR \s"        (R R RR (((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyRVst!TransactionRepositoryInvalidErrorcBseZdZRS(srUsed to indicate that the specified repository is not valid or can not be found at the requested location.(R R R(((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyRrst!UnsupportedRepoTypeOperationErrorcBseZdZd„ZRS(s…Used to indicate that a requested operation is not supported for the type of repository being operated on (http, file, etc.).cCs.tdƒi|jd6|jjddƒd6S(NsLUnsupported operation '%(op)s' for the specified repository type '%(type)s'.RttypeR(RRRR(R((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyR {s  (R R RR (((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyRwstNullTransactioncBsneZdZededdddd„Zd„Zd„Zee d„Z d„Z d„Z e d„ƒZRS( sPProvides a simulated publishing interface suitable for testing purposes.c Cs1||_||_||_||_||_dS(N(t create_repot origin_urltpkg_namet progtrackR( RR"R!R#t repo_propsRtxporttpubR$((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyR…s     cCsUy|jd|jƒWn7tjk rP}tdd|jdt|ƒƒ‚nXdS(seAdds an action and its related content to an in-flight transaction. Returns nothing.tfmritaddRRN(tvalidateR#tactionst ActionErrorRRR (Rtactionte((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyR)Žs  cCsDtjj|ƒs@tdd|jdttdƒ|ƒƒ‚ndS(sžAdds an additional file to the inflight transaction so that it will be available for retrieval once the transaction is closed.tadd_fileRRs;The file to be added is not a file. The path given was %s.N(tostpathtisfileRRR R(Rtpth((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyR/šs cCs.|rd}d}n|j}d}||fS(s¥Ends an in-flight transaction. Returns a tuple containing a package fmri (if applicable) and the final state of the related package.t ABANDONEDt PUBLISHEDN(RR#(Rtabandontadd_to_catalogtpkg_fmrit pkg_state((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pytclose¥s   cCstj|jdƒS(saStarts an in-flight transaction. Returns a URL-encoded transaction ID on success.R(turllibtquoteR#(R((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pytopen³scCs |jƒS(sƒStarts an in-flight transaction to append to an existing manifest. Returns a URL-encoded transaction ID on success.(R=(R((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pytappend¸scCsdS(sXInstructs the repository to refresh its search indices. Returns nothing.N((((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyt refresh_index½sN(R R RtFalseRRRR)R/tTrueR:R=R>t staticmethodR?(((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyR s     tTransportTransactioncBsweZdZed ed d d d d„Zeed„Zd„Zd„Z ee d„Z d„Z d„Z d„ZRS( s;Provides a publishing interface that uses client transport.c Cs×tj|dddƒ\} } } } } }||_||_| |_| dkrctj| ƒ} n| |_||_||_||_ | dkr¬|j d|d|ƒn'| dkrÓ|rÓt dd| ƒ‚ndS(Nthttptallow_fragmentsitfileR%R!R( turlparseR#RRR;tunquoteR1R$t transportt publishertcreate_file_repoR(RR"R!R#R%RR&R'R$RRR1tparamstquerytfragment((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyRÇs *           cCso|jj|jƒrdS|r‰ytj|jddƒWq‰tjk rOq‰tjtj fk r…}t ddt |ƒƒ‚q‰Xnytj d|d|jƒ}Wnªtk rÙ}t ddtdƒ|ƒ‚n|tjk r}tt |ƒƒ‚nUtjk r'}tt |ƒƒ‚n.tj k rT}t ddt |ƒƒ‚nX|jj|j|ƒdS(NtversioniRt propertiestrootsTAn error occurred while trying to initialize the repository directory structures: %s(RItpublish_cache_containsRJtsrtrepository_createR1tRepositoryExistsErrortapxt ApiExceptiontRepositoryErrorRRR t RepositorytEnvironmentErrorRtcfgt ConfigErrorRtRepositoryInvalidErrorRtpublish_cache_repository(RR%R!R.trepo((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyRKßs2    cCs»y|jƒWn7tjk rG}tdd|jdt|ƒƒ‚nXy/|jj|jd|d|jd|j ƒWn=t j k r¶}t|ƒ}tdd|jd|ƒ‚nXdS(seAdds an action and its related content to an in-flight transaction. Returns nothing.R)RRR-R$N( R*R+R,RRR RIt publish_addRJR$RVtTransportError(RR-R.R((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyR)s   cCsªtjj|ƒs@tdd|jdttdƒ|ƒƒ‚ny&|jj|j d|d|jƒWn=t j k r¥}t|ƒ}tdd|jd|ƒ‚nXdS(sžAdds an additional file to the inflight transaction so that it will be available for retrieval once the transaction is closed.R/RRs;The file to be added is not a file. The path given was %s.R3N( R0R1R2RRR RRItpublish_add_fileRJRVRa(RR3R.R((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyR/s   cCsé|rqy(|jj|jd|jƒ\}}Wqßtjk rm}t|ƒ}tdd|jd|ƒ‚qßXnny.|jj|jd|jd|ƒ\}}Wn=tjk rÞ}t|ƒ}tdd|jd|ƒ‚nX||fS(säEnds an in-flight transaction. Returns a tuple containing a package fmri (if applicable) and the final state of the related package. If 'abandon' is omitted or False, the package will be published; otherwise the server will discard the current transaction and its related data. 'add_to_catalog' tells the depot to add a package to the catalog, if True. RR6RR7R:( RItpublish_abandonRJRRVRaR Rt publish_close(RR6R7tstateR(R.R((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyR:-s"       cCs®d}y.|jj|jdtjƒd|jƒ}Wn=tjk rs}t |ƒ}t dd|j d|ƒ‚nX||_ |j dkr§t ddt dƒƒ‚n|j S(saStarts an in-flight transaction. Returns a URL-encoded transaction ID on success.tclient_releaseR#R=RRs8Unknown failure; no transaction ID provided in response.N( RRIt publish_openRJtos_utiltget_os_releaseR#RVRaR RRR(RRR.R((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyR=Ns     cCs®d}y.|jj|jdtjƒd|jƒ}Wn=tjk rs}t |ƒ}t dd|j d|ƒ‚nX||_ |j dkr§t ddt dƒƒ‚n|j S(sƒStarts an in-flight transaction to append to an existing manifest. Returns a URL-encoded transaction ID on success.RfR#R>RRs8Unknown failure; no transaction ID provided in response.N( RRItpublish_appendRJRhRiR#RVRaR RRR(RRR.R((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyR>fs     cCsad}y|jj|jƒWn=tjk r\}t|ƒ}t|d|jd|ƒ‚nXdS(sXInstructs the repository to refresh its search indices. Returns nothing.tindexRRN(RItpublish_refresh_indexesRJRVRaR RR(RRR.R((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyR?~s  N(R R RR@RRRRKR)R/RAR:R=R>R?(((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyRCÄs  &  !  t Transactionc BsQeZdZied6ed6ed6ed6Zedededddd„Z RS(s\Returns an object representing a publishing "transaction" interface to a pkg(5) repository. The class of the object returned will depend upon the scheme of 'origin_url', and the value of the 'noexecute' parameter. The 'noexecute' parameter, when provided, will force the returned Transaction to simulate all of the requested operations acting as if they succeeded. It is intended to be used for testing of client publication tools. Each publishing operation requires different information, and as such the following parameters should be provided to the class constructor as noted: 'pkg_name' should be a partial FMRI representing the desired name of a package and its version when opening a Transaction. Required by: open. 'trans_id' should be a URL-encoded transaction ID as returned by open. Required by: add and close if open has not been called. RFRDthttpstnullc Cs„tj|dddƒ\} } } } }}| jƒ} |rEd} n| dkrn| s_| rntdƒ‚n| |jkr’t|d| ƒ‚n| jdƒr½| r½t|ddƒ‚n| jdƒr(| rët|d d | ƒ‚n| jd ƒrd | jd ƒ} q(| s(t|ƒ‚q(ntj| | | | ||fƒ}|j| |d |d |d|d|d|d|d| ƒS(NRDREiRos+Caller must supply transport and publisher.RRRFRsQ'%s' contains host information, which is not supported for filesystem operations.t/R!R#R%RR&R'R$( RGtlowerRt_Transaction__schemesRt startswithRtlstript urlunparse(tclsR"R!R#R%Rt noexecuteR&R'R$RRR1RLRMRN((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyt__new__¬s6*         N( R R RRCR RrR@RRRx(((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyRmŒs  ("RR0R;RGtpkg.miscRt pkg.actionsR+t pkg.configtconfigR[tpkg.portable.utiltportabletutilRhtpkg.server.repositorytservert repositoryRStpkg.client.api_errorstclientt api_errorsRVRRRRRRRtobjectR RCRm(((s=/usr/lib/python2.7/vendor-packages/pkg/publish/transaction.pyts$    CÈ