ó ©7ãLc@s6dZddlZddlZddlZddlZddlZddlZddlZddlZ d„Z d„Z d„Z d„Z d„Zd„Zd „Zd „Zd „Zd „Zd „ZdZgaejƒad„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z!dS(sj Windows has a specific implementation for most of these. For the group and user id-related (credential) APIs, no implementation is provided. This causes the file and directory actions to not utilize any credential metadata when acting on Windows-compatible systems. In the future, this may be able to be mapped onto the NTFS group mechanism if deemed useful. iÿÿÿÿNcCsdgS(s TODO: Detect Windows 64-bitti386((((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pyt get_isainfo,scCs tjƒS(N(tos_utiltget_os_release(((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pyt get_release0scCsdS(s. TODO: any other windows platforms to support?ti86pc((((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pyt get_platform3scCsdS(s+group names/numbers are ignored on Windows.iÿÿÿÿ((tnametdirpathtuse_file((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pytget_group_by_name7scCsdS(s+group names/numbers are ignored on Windows.iÿÿÿÿ((RRR ((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pytget_user_by_name;scCsdS(s+group names/numbers are ignored on Windows.t((tgidRR ((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pytget_name_by_gid?scCsdS(s+group names/numbers are ignored on Windows.R ((tuidRR ((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pytget_name_by_uidCscCsdS(s+group names/numbers are ignored on Windows.iÿÿÿÿ((((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pyt get_useridGscCsUytjƒSWn@tk rPyddl}|jƒSWqQtk rLdSXnXdS(Niÿÿÿÿ(tgetpasstgetusert ImportErrortwin32apit GetUserNametNone(R((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pyt get_usernameKs   cCs?y&ddl}|jjjƒdkSWntk r:tSXdS(Niÿÿÿÿi(tctypestwindlltshell32t IsUserAnAdminRtFalse(R((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pytis_adminWs   cCsdS(su group names/numbers are ignored on Windows, so changing ownership of a file makes no sense. N((tpathtownertgroup((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pytchown_sttrashcCsëddljj}ddlm}z·tjƒx'tD]\}}|j|ƒr6|Sq6Wy%|j t j j |ƒdt ƒ}Wn|k r’dSXt j j|jtƒ}tj|tƒtj|jƒ|fƒ|SWdtjƒXdS(s& Use path to determine the trash directory. This method does not create the directory. If path is not contained within an image, return None. The directories for the images that have already been accessed are cached to improve the speed of this method. iÿÿÿÿN(tImageNotFoundExceptiontallow_ondisk_upgrade(tpkg.client.imagetclienttimagetpkg.client.api_errorsR$t cache_locktacquiretcached_image_infot startswithtImagetosRtdirnameRRtjointimgdirt trashnametshutiltrmtreetTruetappendtget_roottrelease(RR(R$tiroottitrashtimgttrashdir((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pyt get_trashdirŠs"    cCsyt|ƒ}|sdStjj|ƒs8tj|ƒntjd|ƒ}tj|tjj|tjj |ƒƒƒdS(sÙ Move the file to a trash folder within its containing image. If the file is not in an image, just return without moving it. If the file cannot be removed, raise an OSError exception. Ntdir( R>R/RtexiststmkdirttempfiletmkdtemptrenameR1tbasename(RR=ttdir((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pyt move_to_trashªs cCs…ytj||ƒWnjtk r€}|jtjkr>‚nytj|ƒWntk rlt|ƒnXtj||ƒnXdS(sQ Rename the src file to the dst name, deleting dst if necessary. N(R/RDtOSErrorterrnotEEXISTtunlinkRG(tsrctdstterr((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pyRDºs cCsMytj|ƒWn5tk rH}|jtjkr;‚nt|ƒnXdS(s˜ Remove the given path. The file is moved to the trash area of the image if necessary where it will be removed at a later time. N(R/RKRHRItEACCESRG(RRN((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pytremoveÊs cCst||ƒdS(N(tcopyfile(RLRM((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pytlinkÖscCs#tjj|ƒ}|djdƒS(Nis\(R/Rt splitdrivetsplit(Rt drivepath((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pyt split_pathÙscCs<tjj|ƒ}|ddkr,tjjS|ddSdS(NiR s\(R/RRStsep(RRU((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pyR8Ýs cCsdtjtj|ƒjƒ}|tj@|tj@kr`td|||fƒ}||_|‚ndS(Ns%mode mismatch for %s, has %o, want %o(tstattS_IMODER/tlstattst_modetS_IRWXUtAssertionErrortmode(RR^tfmodetae((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pyt assert_modeäs  cCstj||ƒdS(N(R4RQ(RLRM((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pyRQís("t__doc__RR4R/RIRXRBt threadingtutilRRRRR R RRRRRR"R3R,tLockR*R>RGRDRPRRRVR8RaRQ(((s=/usr/lib/python2.7/vendor-packages/pkg/portable/os_windows.pyt!s>                  "