o 0ka)@sxdZddlmZddlmZeddlmZddlmZddlm Z ddlm Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZdd lmZddlmZddlmZz dd l mZmZWneysd d Zd dZYnwd.ddZddZddZddZddZGddde Z!Gddde Z"ddZ#d d!Z$d"d#Z%ej&d$d%Z'd/d'd(Z(d)d*Z)d0d,d-Z*dS)1z Miscellaneous utilities. )print_function)standard_library) isinstance)map)object)strN)tarfile)fsencodefsdecodecCs|tdS)zGConvert a unicode filename to a filename encoded in the system encodingreplace)encodesysgetfilesystemencoding)unicode_filenamer0/usr/lib/python3/dist-packages/duplicity/util.pyr >sr cCs|tjdS)zttdtjztjdt_ttjdt_WdSt y=}zt dt |WYd}~dSd}~wwdS)NzReleasing lockfile %srzCould not release lockfile: %s) rlockfiler<Debugr>lockpathreleaser/remover:Errorr)r7rrrrelease_lockfiles   rlrcCsd}d}|dkr ||}|s |S|t|7}||q |||kr>||}|s-n|t|7}|||||ks%|||}|t|7}|||S)zCopy byte_count bytes from infp to outfp, or all if byte_count < 0 Returns the number of bytes actually written (may be less than byte_count if find eof. Does not close either fileobj. ir)readlenwrite)infpoutfp byte_count blocksize bytes_writtenbufrrr copyfileobjs,         rvcCsxdd}tj|\}}|r||r|SdStdtjD]}|d}tjtj||}||r9|SqdS)zW Return absolute path for program name. Returns None if program not found. cSs&tj|otj|ot|tjSrE)r/r0isfileisabsaccessX_OK)fpathrrris_exe s&zwhich..is_exePATH"N)r/r0splitgetenvpathsepstripabspathr")programr|r{fnamer0exe_filerrrwhichs rFcstdds`dtjvstddrb|r-ddgd}fdd|D}t|tjd <d dl}|jd d d d dtj d }| tj j dd}tj j |}tj d |dtjd<dSdSdS)N DEBUG_RUNNINGz--pydevdPYDEVDz(/Users/ken/workspace/duplicity-testfilesz'/home/ken/workspace/duplicity-testfiles)rbin duplicityzduplicity/backendstestingztesting/functionalz testing/unitc s8g|]}tjtj|tjtj|fqSr)r/r0normpathr").0pclientserverrr .s z"start_debugger..PATHS_FROM_ECLIPSE_TO_PYTHONrz dione.locali.T)portstdoutToServerstderrToServerryes)r/rr argvjsondumpsenvironpydevdsettracer0poprsepr"insert)remoteduppathspathlistrbaserrrstart_debuggers""  r)r)r)F)+__doc__ __future__rfuturerinstall_aliasesbuiltinsrrrrrarr/r#r ratexitrrduplicity.configr duplicity.logr<r r ImportErrorr*r-r3r9rBr1rCrLrYr_reregisterrlrvrrrrrrsN