~Z>dd l?m@Z@mAZAdd lBmCZCd ZDejEd d ZFdZGdZHdZIdZJdZKdZLdZMdZNdZOdZPdZQdZRdZSde:e6jTjUejVe6jTjWejXfZYdZZej[dej\Z]ej[dZ^dd d!gZ_d"Z`ead#Zbddead$Zdd%eefd&YZfd'Zgd(Zhddd)Zid*Zjd+d,Zkdd-Zld.Zmdeadddd/Zndiddd2Zod3epfd4YZqd5Zrd6Zsd7ZteuZvd8ewfd9YZxd:epfd;YZyddd<Zzddd=Z{d>Z|d?Z}d@Z~dAZdBZddCZdDZdEepfdFYZdGefdHYZexZdjZe/e&Be$Be%BZe'e$Be0Be%Be1BZe&e$Be%BZdJdKZdLZddMZdNZdOZdPZdQZdRZedSZdTdUZdVZeeeeeedfZewefZeueeZeaZdddWZdddXZdYZdZZd[Zd\epfd]YZd^eefd_YZd`epfdaYZdbZdcZddZeeZdeZeaeaddfZdgZdhZdS(ks6 Misc utility functions used by the packaging system. iN(t defaultdict(t itemgetter(tS_IFMTtS_IMODEtS_IRGRPtS_IROTHtS_IRUSRtS_IRWXUtS_ISBLKtS_ISCHRtS_ISDIRtS_ISFIFOtS_ISLNKtS_ISREGtS_ISSOCKtS_IWUSRtS_IXGRPtS_IXOTH(tVERSION(tglobal_settings(t DebugValues(timg_type_namestIMG_NONE(t PkgGzipFiles/var/tmptdaysissignature-policysIhttps://defect.opensolaris.org/bz/enter_bug.cgi?product=pkg&component=clisIhttps://defect.opensolaris.org/bz/enter_bug.cgi?product=pkg&component=guicCstditd6S(sThis function returns the standard traceback message. A function is necessary since the _() call must be done at runtime after locale setup.s This is an internal error in pkg(5) version %(version)s. Please log a Service Request about this issue including the information above and this message.tversion(t_R(((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytget_traceback_messageYscCsdS(s[Return a release note URL pointing to the correct release notes for this versions3https://support.oracle.com/rs?type=doc&id=2045311.1((((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytget_release_notes_urlcscCstjdtj|S(s4convert seconds since epoch to %Y%m%dT%H%M%SZ formats%Y%m%dT%H%M%SZ(ttimetstrftimetgmtime(tt((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyttime_to_timestampkscCstjtj|dS(s4convert %Y%m%dT%H%M%SZ format to seconds since epochs%Y%m%dT%H%M%SZ(tcalendarttimegmRtstrptime(tts((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyttimestamp_to_timepscCstjj|dS(s2convert %Y%m%dT%H%M%SZ format to a datetime objects%Y%m%dT%H%M%SZ(tdatetimeR$(R%((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyttimestamp_to_datetimeuscCsntj|}tj||ytj||j|jWn+tk ri}|j t j krjqjnXdS(sBcopy a file, preserving attributes, ownership, etc. where possibleN( tostlstattshutiltcopy2tportabletchowntst_uidtst_gidtOSErrorterrnotEPERM(tsrc_pathtdst_pathtfste((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytcopyfileysc Csd}tj|ttj|}xNttj|D]7}tjj||}tjj||}tj |}t |j rt ||tj |t|j tj||j|jtj||j|jfq;t|j rWtj||tj |t|j tj||j|jtj||j|jfq;t|j rtjtj||q;t|j rtj|t|j tj||j|jtj||j|jfq;t|j rtjtj}t tdr.tj!||j |j"nCy|j#||j$Wn%|j%k rp} t&j'}q;nXtj||j|jtj||j|jfq;t(|j st)|j r*t tdrrtj!||j |j"tj||j|jtj||j|jfqrq;t*|j dkrBq;t*|j dkrZq;dGt+t*|j GHq;Wtj |t|j tj||j|jtj||j|jf|r|d|d|dndS( s)Rewrite of shutil.copytree() that can handle special files such as FIFOs, sockets, and device nodes. It re-creates all symlinks rather than copying the data behind them, and supports neither the 'symlinks' nor the 'ignore' keyword arguments of the shutil version. tmknodiisunknown file type:iiiN(,tNoneR)tmakedirst PKG_DIR_MODEtstattsortedtlistdirtpathtjoinR*R tst_modetcopytreetchmodRR.R/R0tutimetst_atimetst_mtimeR R+R8R tsymlinktreadlinkR tmkfifoRtsockettAF_UNIXthasattrR9tst_devtbindtcloseterrortsystexc_infoR RRtoct( tsrctdsttproblemtsrc_stattnamets_pathtd_pathtstsockt_e((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRCsd   "cCstjj|rEtjj|tjj|jtjj}nytj||Wn?tk r}tj |}|j t j kr&t |j rt||tj|qtj||tj|t|j tj||j|jtj||j|jftj|q|j t jkr`t |j r`tjd||fq|j t jkrt |j rtjd|qnXdS(s:Rewrite of shutil.move() that uses our copy of copytree().s.Cannot move a directory '%s' into itself '%s'.s$Destination path '%s' already existsN(R)R@tisdirRAtbasenametrstriptseptrenametEnvironmentErrorR*R2tEXDEVR RBRCR+trmtreeR8RDRR.R/R0RERFRGtunlinktEINVALtErrortENOTDIR(RURVR7R\((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytmoves. ' ! !  cCsVt}xF|D]>}|}x/|dkrM|j|tjj|}qWqW|S(sTgiven a set of directories, return expanded set that includes all componentst(tsettaddR)R@tdirname(tdirstouttdtp((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt expanddirss   cCs!|ddkr|d}n|S(s0if 'u' donesn't have a trailing '/', append one.it/((tu((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyturl_affix_trailing_slashs spkg/%s (%s %s; %s %s; %%s; %%s)cCs@| s|jdkrt}n |j}tt||f}|S(s4Return a string that can use to identify the client.N(ttypeR:Rt_client_versionR(timgt client_nametimgtypet useragent((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytuser_agent_strs   s^(?:[a-zA-Z0-9\-]+[a-zA-Z0-9\-\.]* |(?:\d{1,3}\.){3}\d{3} |\[([a-fA-F0-9\.]*:){,7}[a-fA-F0-9\.]+\])$s.*[^a-zA-Z0-9\-\.:\[\]]+tfilethttpthttpscCs4|s tStj|rtStj|r0tStS(s@Verify that the publisher prefix only contains valid characters.(tFalset_invalid_host_charstmatcht _hostname_retTrue(tprefix((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytvalid_pub_prefixscCs|s tStj|}|dtkr-tS|ddkrtj|dddd}tj|}tjj|s~tSt Stj |dd}|r|j d}t |dkr|d}qn| st j|rtStj|rt StS(syVerify that the publisher URL contains only valid characters. If 'proxy' is set to True, some checks are relaxed.iRtallow_fragmentsiit@(Rturlparseturlsplitt _valid_prototurllibt url2pathnameR)R@tabspathRt splitporttsplittlenRRR(turltproxytoR@thostt host_parts((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt valid_pub_url's*cCsd}d}d}d}|p!| r;| r;tdn|jd} | dkretjdnt|jd} | dkrtjd nt|jd} |jd | |@rt|jd} | d t|jd} |j| n| |@rCx3tr?|jd} | s8| d krPqqWn| |@rx3tr|jd} | sx| d krPPqPqPWn| |@r|jdn|rn@|rg}x1|D]}|jtj|qWn |}tj tj }xtr|jd}|dkrw|j }|r2n4|rYx+|D]}|j |q?Wn |j ||j |Pn|j|}|rn4|rx+|D]}|j |qWn |j ||j |qW|rdS|rg}x!|D]}|j|jqW|S|jS(sDecompress a gzipped input stream into an output stream. The argument 'gz' is an input stream of a gzipped file and 'outfile' is is an output stream. gunzip_from_stream() decompresses data from 'gz' and writes it to 'outfile', and returns the hexadecimal SHA sum of that data using the hash_func supplied. 'hash_funcs', if supplied, is a list of hash functions which we should use to compute the hash. If 'hash_funcs' is supplied, a list of hexadecimal digests computed using those functions is returned. The returned list is in the same order as 'hash_funcs'. If 'ignore_hash' is True, we do not compute a hash when decompressing the content and do not return any value. iiiis(no hash functions for gunzip_from_streamssNot a gzipped fileisUnknown compression methodiiti@iRlNi(t ValueErrortreadtzlibRQtordRtappendtdigestt HASH_ALGSt decompressobjt MAX_WBITStflushtupdatetwritet decompresst hexdigest(tgztoutfilet hash_funct hash_funcst ignore_hashtFHCRCtFEXTRAtFNAMEtFCOMMENTtmagictmethodtflagtxlenR\tshasumstftshasumtdcobjtbuftubuftshat hexdigests((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytgunzip_from_streamNs                      t PipeErrorcBseZdZddZRS(s Pipe exception. cCstj|||_dS(N(t Exceptiont__init__t_args(tselftargs((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs N(t__name__t __module__t__doc__R:R(((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRscGsfy+djg|D]}t|^qGHWn4tk ra}|jtjkr[t|nnXdS(s Emit a message. t N(RAtstrtIOErrorR2tEPIPER(ttexttlR7((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytmsgs + cGsny3tjdjg|D]}t|^qIJWn4tk ri}|jtjkrct|nnXdS(s Emit a message to sys.stderr. RN(RRtstderrRARRR2RR(RRR7((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytemsgs 3 cCs|dkrt}nytj||tjWnftjtfk rydtj}Wntk ryd}nX|d|tj|dnXdS(sWraps locale.setlocale(), falling back to the C locale if the desired locale is broken or unavailable. The 'printer' parameter should be a function which takes a string and displays it. If 'None' (the default), setlocale() will print the message to stderr.s '%s.%s'Rls^Unable to set locale%s; locale package may be broken or not installed. Reverting to C locale.tCN(R:Rtlocalet setlocaletgetdefaultlocaleRiR(tcategorytloctprintertdl((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs    cCs|S(slReturn its argument; used to mark strings for localization when their use is delayed by the program.((tmessage((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytN_ss%(num).2f %(unit)sc Cs!tdtddftdtddftdtddftd td dftd tddftdtddftdtdd fg}xl|D]d\}}}|tdkr||krqn|it|t|d!dd6|d6|d6SWdS("s@Returns a human-formatted string representing the number of bytes in the largest unit possible. If provided, 'fmt' should be a string which can be formatted with a dictionary containing a float 'num' and strings 'unit' and 'shortunit'. The default format prints, for example, '3.23 MB' tBii tkBtkitMBtMitGBtGi(tTBtTi2tPBtPi<tEBtEiFtnumtunitt shortunitNiii@ll lli(Rtroundtfloat(tnbytestfmttunitstuomtshortuomtlimit((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt bytes_to_strs cCsG|j}|r(|jd|d}n|jdd}d||S(sCalculate the depth of the current request path relative to our base uri. path_info always ends with a '/' -- so ignore it when calculating depth.s/%s/Ruis../(t path_infotreplacetcount(trequestturitpubtrpathtdepth((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt get_rel_path s  cCs@|jjd}|dkr6|jjdd}nt|S(sTakes a file action and returns the over-the-wire size of a package as an integer. The OTW size is the compressed size, pkg.csize. If that value isn't available, it returns pkg.size. If pkg.size isn't available, return zero.s pkg.csizespkg.sizeiN(tattrstgetR:tint(tactiontsize((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytget_pkg_otw_sizes cCsd}t}t|tr6t|d|}t}n|}|dkr]tj|j}n|ro|} nU|dks|dkrtst dni} x|D]} || | | iRh(RDiRi(REiRj(sintiRkN(RRRt_ctype_formatst_timestruct_desct _psinfo_descR:Rmt iteritemst struct_nameRwRsRxtcount1RYtcount2tfmt_charRt collectionst namedtupleR3t staticmethodRrR{(((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyR0s      $ (cCs'tj}|dkrdS|jdS(s>Return the amount of virtual memory in bytes currently in use.iN(R0R{R:RT(R{((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt __getvmusageZs  cCs:tj}|dkrdS|jjt|jjdS(snReturn the process start time expressed as a floating point number in seconds since the epoch, in UTC.ggeAN(R0R{R:RZRGRRH(R{((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt_prstartbs  cCsd}y.t}|dk r3t|dd}nWn@ttfk rv}t|trw|jtjkrwqwnX|dk rd}nd}t|t S(sBReturn an out of memory message, for use in a MemoryError handler.Rs%(num).0f%(unit)ssMThere is not enough memory to complete the requested operation. At least %(vsz)s of virtual memory was in use by this command before it ran out of memory. You must add more memory (swap or physical) or allow the system to access more existing memory, or quit other programs that may be consuming memory, and try the operation again.sThere is not enough memory to complete the requested operation. You must add more memory (swap or physical) or allow the system to access more existing memory, or quit other programs that may be consuming memory, and try the operation again.N( R:RRt MemoryErrorRdRR2tENOMEMRtlocals(tvsztvmusaget__eRQ((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt out_of_memoryjs     t ImmutableDictcBsqeZedZdZdZd dZdZd dZ dZ dZ dZ e d ZRS( cCstj||dS(N(tdictR(Rtdefault((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRscCs|jdS(N(t_ImmutableDict__oops(Rtitemtvalue((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt __setitem__scCs|jdS(N(R(RRR((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt __delitem__scCs|jdS(N(R(RRR((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytpopscCs|jdS(N(R(R((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytpopitemscCs|jdS(N(R(RRR((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt setdefaultscCs|jdS(N(R(RRr((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRscCstS(N(R(R((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytcopyscCs|jdS(N(R(R((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytclearscCs tddS(Ns Item assignment to ImmutableDict(t TypeError(((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt__oopssN(RRtEmptyIRRRR:RRRRRRRR(((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs         t DictPropertyc BsWeZdefdYZddddddddddddd ZddZRS(t__InternalProxycBszeZdZdZdZdZdZdZdZd dZ d dZ d Z d Z d ZRS( c Csp||_||_||_||_||_||_||_||_| |_| |_ | |_ | |_ dS(N( t_InternalProxy__objt_InternalProxy__fgett_InternalProxy__fsett_InternalProxy__fdelt_InternalProxy__iteritemst_InternalProxy__keyst_InternalProxy__valuest_InternalProxy__itert_InternalProxy__fgetdefaultt_InternalProxy__fsetdefaultt_InternalProxy__updatet_InternalProxy__pop( RtobjtfgettfsettfdelRtkeystvaluestiteratort fgetdefaultt fsetdefaultRR((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs           cCs.|jdkrtdn|j|j|S(Nsunreadable attribute(RR:tAttributeErrorR(Rtkey((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt __getitem__s cCs5|jdkrtdn|j|j||dS(Nscan't set attribute(RR:RR(RRR((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs cCs2|jdkrtdn|j|j|dS(Nscan't delete attribute(RR:RR(RR((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs cCs+|jdkrtdn|j|jS(Nscan't iterate over items(RR:RR(R((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs cCs+|jdkrtdn|j|jS(Nscan't iterate over keys(RR:RR(R((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs cCs+|jdkrtdn|j|jS(Nscan't iterate over values(RR:RR(R((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs cCs1|jdkrtdn|j|j||S(Ns can't use get(RR:RR(RRR((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs cCs1|jdkrtdn|j|j||S(Nscan't use setdefault(RR:RR(RRR((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs cCs.|jdkrtdn|j|j|S(Nscan't use update(RR:RR(RRr((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs cCs1|jdkrtdn|j|j||S(Ns can't use pop(RR:RR(RRrR((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs cCs+|jdkrtdn|j|jS(Ns can't iterate(RR:RR(R((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt__iter__s N(RRRRRRRRRR:RRRRR(((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs           c Csp||_||_||_||_||_||_||_||_| |_| |_ | |_ | |_ dS(N( t_DictProperty__fgett_DictProperty__fsett_DictProperty__fdelt_DictProperty__iteritemsRt_DictProperty__keyst_DictProperty__valuest_DictProperty__itert_DictProperty__fgetdefaultt_DictProperty__fsetdefaultt_DictProperty__updatet_DictProperty__pop( RRRRRRRRtdocRRRR((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs           c Cs_|dkr|S|j||j|j|j|j|j|j|j|j |j |j |j S(N( R:t_DictProperty__InternalProxyRRRRRRRRRRR(RRtobjtype((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt__get__s  N(RRtobjectRR:RR(((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs I cCsy)t|d}|j}|jWntk r}|jtjkrktj|d|d|n|jtjkrtj |j n|jtj krtj |j nnXyt jt j|SWn1t jk r }tj|d|d|nXdS(sBTake the file given in path, open it, and use it to create an X509 certificate object. 'uri' is an optional value indicating the uri associated with or that requires the certificate for access. 'pub' is an optional string value containing the name (prefix) of a related publisher.RRt publisherN(RRRPRdR2tENOENTt api_errorstNoSuchCertificatetEACCEStPermissionsExceptiontfilenametEROFStReadOnlyFileSystemExceptiontosctload_certificatet FILETYPE_PEMRitInvalidCertificate(R@RRtcftcertdataR7((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt build_certs$   c Cs.t|d|d|}|jrBtj|d|d|ntjj}|j}tj|d}tjj t j |}||krtj |d|d|n|j }tj|d}tjj t j |} | |} | tkr*tj|d|d|d| jn|S(sjValidates the indicated certificate and returns a pyOpenSSL object representing it if it is valid.RRRs %Y%m%d%H%M%SZR(Rt has_expiredRtExpiredCertificateR'tutcnowt get_notBeforeRR$tutcfromtimestampR"R#tNotYetValidCertificatet get_notAftert MIN_WARN_DAYStExpiringCertificateR( tssl_certRRtcerttnowtnbR tnbdttnatnadttdiff((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytvalidate_ssl_cert9s*          t0123456789abcdefcCs[d}xN|D]F}t|}t|d}|d}t|d}|||7}q W|S(sDConverts a string of bytes to a hexadecimal representation. Rli(Rt char_list(R\tresRstatb((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt binary_to_hex_s   cCscd}xVtdt|dD]<}|ttj||dtj||d7}qW|S(sFConverts a string of hex digits to the binary representation. Rliiii(RRtchrRtfind(R\RR3((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt hex_to_binaryls  cCs=dddg}x'|D]}tj|}|rdSqWtS(sExamine the environment. If the environment has set TMPDIR, TEMP, or TMP, return None. This tells tempfile to use the environment settings when creating temporary files/directories. Otherwise, return a path that the caller should pass to tempfile instead.tTMPDIRtTEMPtTMPN(R)tgetenvR:tDEFAULT_TEMP_PATH(ttmp_envstevtenv_val((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytconfig_temp_rootvs  cCs=dddg}x'|D]}tj|}|r|SqWtS(sReturn the directory path where the temporary directories or files should be created. If the environment has set TMPDIR or TEMP or TMP then return the corresponding value else return the default value.RRR(R)RR(ttemp_envtenvR((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytget_temp_root_paths  cCs,|jddkr|jd r|s@tjj|}n6tjj|svtjjtjj||}ntj ddt j |dddf}ntj|ddd\}}}}}}|j }|dkr |jdr d|j d}q ntj ||||||fS( sParse the repository location provided and attempt to transform it into a valid repository URI. 'cwd' is the working directory to use to turn paths into an absolute path. If not provided, the current working directory is used. s://isfile:/RRlRiRu(Rt startswithR)R@RtisabstnormpathRARt urlunparseRt pathname2urltlowertlstrip(RtcwdtschemetnetlocR@tparamstquerytfragment((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt parse_uris%$ !*  cCsytj|tWntk r}|j|kr`|jtjks\tjj|jr`dS|jtj krt j |jq|jtj krt j |jq|jtjks|j|krqnXdS(sCreate a directory at the specified location if it does not already exist (including any parent directories) re-raising any unexpected exceptions as ApiExceptions. N(R)R;R<RdRR2tEEXISTR@texistsRRRRR(tpathnameR7((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyR;s!!t DummyLockcBsDeZdZdZddZdZdZedZRS(sThis has the same external interface as threading.Lock, but performs no locking. This is a placeholder object for situations where we want to be able to do locking, but don't always need a lock object present. The object has a held value, that is used for _is_owned. This is informational and doesn't actually provide mutual exclusion in any way whatsoever.cCs t|_dS(N(Rtheld(R((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRsicCs t|_tS(N(RR(Rtblocking((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytacquires cCs t|_dS(N(RR(R((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytreleases cCs|jS(N(R(R((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt _is_ownedscCs|jS(N(R(R((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytlockeds( RRRRRRRtpropertyR(((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs     t SingletoncBs eZdZdZdZRS(sqSet __metaclass__ to Singleton to create a singleton. See http://en.wikipedia.org/wiki/Singleton_pattern cCs)tt|j|||d|_dS(N(tsuperRRR:tinstance(tmcsRYtbasest dictionary((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRscOs7|jdkr0tt|j|||_n|jS(N(RR:RRt__call__(RRtkw((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyR!s(RRRRR!(((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs it.cCsK|r5|r5|dkr5|ddkr5|jdStjj|d|S(sbVersion of relpath to workaround python bug: http://bugs.python.org/issue5117 Ruitstart(RR)R@trelpath(R@R$((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyR%s( cCsxtj|D]\}}}x6|D].}tjj||}tj|||q&Wx6|D].}tjj||}tj|||q_WqWdS(s?Change the ownership of all files under directory d to uid:gid.N(R)twalkR@RAR-R.(Rrtuidtgidtdirpathtdirnamest filenamesRYR@((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytrecursive_chown_dir s  csg}d}t}xYD]Q}t|tkr:qnt|dkr[|\} } n$t|dkr|\} } } n| |kst|| \} } | s| st| dkr| d kst| tkr|jd| n|jd| | |d| tjD]0\}}|jd|jd||fqqW|S(sWhen running a pkg(1) command from within a packaging module, try to use the same pkg(1) path as our current invocation. If we're running pkg(1) from some other command (like the gui updater) then assume that pkg(1) is in the default path.tpkgs-Ds%s=%s( RPR)R@R`R=R1RRR(tpkg_binROtpkg_cmdRRw((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt api_pkgcmds      cCsHtjd}| r5dtjkr5tjd}n|sDd}n|S(s\Return path to the current live root image, i.e. the image that we are running from.tsimulate_live_roott PKG_LIVE_ROOTRu(RRNR)RM(t live_root((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytliveroots  cCs:y!tj|}|j|jSWntk r5dSXdS(spFind out how much space is available at the specified path if it exists; return -1 if path doesn't existiN(R)tstatvfstf_frsizetf_bavailR1(R@R((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt spaceavails  cCsJy!tdtj|DSWn"tk rE}tj|nXdS(sBReturn the size (in bytes) of a directory and all of its contents.cssF|]<\}}}|D]&}tjjtjj||VqqdS(N(R)R@tgetsizeRA(t.0RrtdnamestfnamesR((s./usr/lib/python2.7/vendor-packages/pkg/misc.pys s N(tsumR)R&RdRt_convert_error(R@R7((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt get_dir_sizes cs<fd}d}ddd} fdfd} dkrr|} |} nd krtfd D} d jd t| D} } nd ksdkrkitd6}dkrd|ds (s\Rs s RmRnRoRpRqRrRsRtRuRv(R(tvaltnvalR1(t out_format(s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt quote_value#s  cs7|d}t}t|ttttfr4t}nE|dkrRd|ddZss css|] }dVqdS(s%sN((R^R0((s./usr/lib/python2.7/vendor-packages/pkg/misc.pys ]stjsonsjson-formattedt sort_keysitindentcst|tr|St|ttttfrKg|D]}|^q5St|trx*|jD]\}}|||tss Rlc3s1|]'\}}|kr||fVqdS(N((R^RRw(R(s./usr/lib/python2.7/vendor-packages/pkg/misc.pys s ( RaRAtxrangeRRtdumpsRtmapR>tfilterRR.R(RfRt field_valuesRytdef_fmtt omit_headersR}RhRjRNR~Rt filter_funct num_fieldsRtoutputthdrsR(( RfR@R}RRlRRgRyRzs./usr/lib/python2.7/vendor-packages/pkg/misc.pyt get_listingsT,     #        /      icCsJy|j|Wn2tk r$n"tk rE}tj|nXdS(sTruncate the specified file.N(ttruncateRR1RRb(RRR7((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt truncate_files  cCsytjjWn2tk r$n"tk rE}tj|nXytjjWn2tk rjn"tk r}tj|nXdS(sflush stdout and stderrN(RRtstdoutRRR1RRbR(R7((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt flush_outputs  cCs|dkr;tr;tjdI|IJtjdI|IJn|dkrKdS|dkrct}n|dkrt}dg}i}|||g}nCt}|\}}}|s|}nt||B}|||g}t|tkst t|t ks t t|t kr=t |dkr=|ddksCt t|tks[t t|t krt |dkst d} t |tr|} n t|} t|dt|} t| | st d| || |ft | t st d |x0tD](} t| | r| ||||SqW| t tjfkri} t |dkr| j|| || ||S|jd\}}t |tr\t |dkst xt|jD]f\}}d ||f}t|||d |}d ||f}t|||d |}|| |): ( , ) } when we finish the object cache we update it so that it contains just encoded objects hashed by their assigned object id (obj_id). so the hash contains: { str(): } then we merge the state data and object cache into a single dictionary and return that. it json_statet json_objectstplandesc_validatesjson_encode finished name: sjson_encode finished data: (t itervaluesRRt json_validatet json_debugRRR(RYR tfinishtje_statet obj_cachet obj_cache2tobj_idt obj_state((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt je_returns  t __metaclass__s-unexpected %s for %s, expected: %s, value: %ssunexpected unicode string: %ss %s[%s].key()Rs%s[%s].value()s%d >= %dt fillvalues%s[%i]tgetstatesno json encoder for: %ss"json encoder returned none for: %sN(R:RRRRR{RRRxRRRRnRRtgetattrt issubclasstunicodetjson_types_immediatesRRRtitemsRt json_encodeR.Rmtextendt itertoolst izip_longestRtid(RYR Rst commonizeRRRRt commonize_oldRt desc_typet data_typeR Rutdesc_ktdesc_vRRwtname2tk2tv2R3tdata2tdesc2tencoder((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs      :* /             cCs|dkr;tr;tjdI|IJtjdI|IJn|dkrK|S|dkrct}n|dkrt}|si}n|d}|d}||g}nvt}|\}}| r|r|d}|d}nt}|s|}nt||B}t}|r||g}nt|tksEt dt|t|t ks]t t|tksut t|t krt |dkst d} t |tr|} n t|} x3tD]+} t| | r| |||||SqWt |t r|j} | jt |dkr\| j|| || |||S|jd\} }t | tr&t |d kst xt|jD]f\}}d || f}t||| d |}d || f}t|||d |}|| |= %dRs%s[%i]t fromstatesno json decoder for: %sRN(R:RRRRR{RRRxRRRRnRRRRRRRRRt json_decodeR.RmRRRRR(RYR RsRRRRRtje_state_changedRRR RuRRRRwRRRtrvtypeR3RRtdecoderR((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs             (*                     cCst|ts4tdt||t|ft|tkrxq|D]f}t|tksutd|d||f}t||d||f}t|||qMWnt|tkr x>t t |D]'}d||f}t|||qWndS(s*Validate that a named piece of data can be represented in json and that the data can be passed directly to json.dump(). If the data can't be represented as json we'll trigger an assert. 'name' is the name of the data to validate 'data' is the data to validate 'recurse' is an optional integer that controls recursion. if it's a negative number (the default) we recursively check any nested lists or dictionaries. if it's a positive integer than we only recurse to the specified depth.s*invalid json type "%s" for "%s", value: %ss(integer dictionary keys detected for: %ss %s[%s].key()s%s[%s].value()s%s[%i]N( Rt json_typesRRxRRRRRnRR(RYR Rtnew_nameR3((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs   c sfd}ttks\td|ttf|ttkrttkstd|ttttf|x?D]4}d||f}t|||qWnttkrttks^td|ttf|xKttD]4}d||f}t|||qqWndS(scCompare two json encoded objects to make sure they are identical, assert() if they are not.csAd}d|d|d|d|S(sdump debug info for json_diffcSstj|dtddS(s dbg helperRRi(RRR(R\((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRrss --- d0 s +++ d1 s --- alld0 s +++ alld1 ((Rr(talld0talld1td0td1(s./usr/lib/python2.7/vendor-packages/pkg/misc.pytdbgs s7Json data types differ for "%s": type 1: %s type 2: %s sLJson dictionary keys differ for "%s": dict 1 missing: %s dict 2 missing: %s s%s[%s]sGJson list lengths differ for "%s": list 1 length: %s list 2 length: %s s%s[%i]N(RxRRRmt json_diffRnRR( RYRRRRRRRR3((RRRRs./usr/lib/python2.7/vendor-packages/pkg/misc.pyRs&&7 %#cCsyi}xl|jD]^\}}t|tkrC|jd}nt|tkrg|jd}n|||tk ry}|j|_||j_tj|j_dSX||_Wnwtk r}d|_|j|_||j_y/tdrtdntj|j_Wqtk rqXnXdS(sJDedicated call thread. 'dummy' is a dummy parameter that is not used. this is done because the threading module (which invokes this function) inspects the first argument of "args" to check if it's iterable, and that may cause bizarre failures if cb is a dynamically bound class (like xmlrpclib._Method). We need to be careful here and catch all exceptions. Since we're executing in our own thread, any exceptions we don't catch get dumped to the console.tasync_thread_errorN( RRR:RR7t tracebackt format_excRRu(RtdummytcbRtkwargsRuR7((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyt __thread_cbf s,          cOs|j stt|_|r2d|f|}n d|f}tjd|jd|d||_t|j_|jjdS(sStart a call to an rpc server.ittargetRRN( RRRt threadingtThreadt_AsyncCall__thread_cbRtdaemonR$(RRRR((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyR$ s   cCs |jst|jjdS(sWait for an rpc call to finish.N(RRRRA(R((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRA scCs|jst|jj S(sCheck if an rpc call is done.(RRRtis_alive(R((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytis_done scCsG|jst|j|js+t|jr@|jn|jS(sFinish a call to an rpc server.(RRRARR7Ru(R((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytresult s    ( RRRRRR$RARR(((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyRS s  )   c Cs|}tjjd}tjjd}tjjd}tjjd}tjjd}tjjdg}tjjdg} |r|jd}n| r| jd} n|r|jd r|r|}nf|r|jd r|r|}nB|r&|jd r&|r&|}n|r5|}n|rD|}n|sP| rtj|d d j} | jd d } | |ks|dgkrdS| | ks| dgkrdSn|sdS|S(sKGiven a proxy string and a URI we want to access using it, determine whether any OS environment variables should override that value. The special value "-" is returned when a no_proxy environment variable was found which should apply to this URI, indicating that no proxy should be used at runtime.t http_proxyt https_proxyt HTTPS_PROXYt all_proxyt ALL_PROXYtno_proxytNO_PROXYt,RRRiRt*t-N(R)RMRRRRRR ( RRt runtime_proxytenviron_http_proxytenviron_https_proxytenviron_https_proxy_uppertenviron_all_proxytenviron_all_proxy_upperR tno_proxy_upperR R((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytget_runtime_proxy s@      cCs=y|jd}Wn#tk r8|jdd}nX|S(sKconvert non-ascii strings to unicode; replace non-convertable charstasciisutf-8R(RRtdecode(R\((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyR s  ccs|rg}x|D]}|rA|j|r4|p;||}n|}d|ks_d|krtjtj|j}t}nt}|j||fqW|}d}nx_|D]W}xI|D]5\}}|r||rPqq||krPqqW|rqn|VqWdS(sSHelper function for yielding items that match one of the provided patterns.Rt?N( Rtretcompiletfnmatcht translateRRRRR:(t pat_prefixRtpatternst npatternsRstpatt glob_matchR((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytyield_matching s0      cCsxtsXxOttD]>}|jdrd|krttt|j|qqWndjtj|d|gS(s convert signal number to name(s)tSIGRRusUnnamed signal: %d(tsigdicttdirtsignalRRRRAR(t signal_numberRY((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytsigname s $ccs|s| st|}x|D]\}}}} } g} xs|D]k} |rm| |jkrm|j| } n3| dkr|j} n| dkr|j|j} n| dkr|} n| dkrt|dd} n| dkr|j} n| dkr|j} n| d kr+|j} nu| d krp|j} | d kr|} | d krmd} qmqn0| d kr| } n| d kr| } nd} | j | qBW| rg| D]}t |dkr|^qs|r | s|d ks|| kr | }| Vq q Wd S(sProduces a list of n tuples (where n is the length of attrs) containing the relevant information about the actions. The "actionlist" parameter is a list of tuples which contain the fmri of the package that's the source of the action, the action, and the publisher the action's package came from. If the actionlist was generated by searching, the last two pieces, "match" and "match_type" contain information about why this action was selected. The "attrs" parameter is a list of the attributes of the action that should be displayed. The "show_all" parameter determines whether an action that lacks one or more of the desired attributes will be displayed or not. The "remove_consec_dup_lines" parameter determines whether consecutive duplicate lines should be removed from the results. The "last_res" parameter is a seed to compare the first result against for duplicate removal. s action.names action.keys action.rawthashs action.hashRlspkg.namespkg.fmris pkg.shortfmris pkg.publishers search.matchssearch.match_typeN(shashs action.hash( RRRYtkey_attrRtget_nametget_fmritget_short_fmrit get_publisherR:RR(t actionlistRtshow_alltremove_consec_dup_linestlast_rest last_linetpfmriRRRt match_typetlineRRR((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytlist_actions_by_attrs' sL                  7 c Cst|}t|}gt|dD])}gt|dD] }d^q@^q)}d}d}d} x*t|dD]}||||dR(Rt known_wordst candidatestknowntdistanceR1((s./usr/lib/python2.7/vendor-packages/pkg/misc.pytsuggest_known_words s$  ii(RtOpenSSL.cryptotcryptoRRR"RR'R2RR5RRR)tplatformRRR+R)t simplejsonRRKRoRRRRRRRRRtoperatorRR=RRRRRRRR R R R R RRRRtpkg.client.api_errorstclientRt pkg.portableR-t pkg.digestRRQRt pkg.clientRtpkg.client.debugvaluesRtpkg.client.imagetypesRRt pkg.pkggzipRRt timedeltaRtSIGNATURE_POLICYt BUG_URI_CLIt BUG_URI_GUIRRR!R&R(R8RCRkRtRwtutiltget_canonical_os_nametmachinetget_os_releaseRRyR~RtXRRRRRRR:RRRRRRRRRRRR/RR0RRRR.RRRRRRRRRRRRR;RRxRt EmptyDicttPKG_FILE_BUFSIZt PKG_FILE_MODER<tPKG_RO_FILE_MODER%R,RHRPRTRXR\RcRRRRR9RRR4RRRntjson_types_collectionsRRRRRRRRRRRRR%R'R+R:RBRG(((s./usr/lib/python2.7/vendor-packages/pkg/misc.pyts                         j     H    ' e    PH   ! %g$   !        % % Sd 3 %  B