-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/win32utils.pyc


tPc@@sBdZddlmZddlZddlZddlZddlZddlZddlm	Z	m
Z
ddlmZej
dkrej\ZZZZZedkrdZqd	ZndZyddlZeZWnek
reZnFXed	krejZd
ZdZnejZej dZd
Zyddl!Z!eZ"Wnek
rreZ"Z#Z$naXyddl%Z%eZ#Wnek
reZ#nXyddl&Z&eZ$Wnek
reZ$nXda'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dedZ3dddZ4dZ5dZ6dZ7d Z8d!Z9dZ:d"Z;e
j<e
j=d4d#Z>e
j<e
j=d5e6Z?e
j<e
j=d6e8Z@e
j<e
j=d7e9ZAe
j<e
j=d8e;ZBd$ZCd%ZDd&ZEd'ZFd(ZGd)ZHed*ZIerzedkrzd+ZJdd,ZKndZJdd-ZKe$rd.ZLeLZMner5ej
dkr5dd/lNmOZOmPZPmQZQejRjSZTejUeOeQd0eTfZVejUeQePeOePd1eTfZWd2ZXeXZMnd3ZYdS(9sRWin32-specific helper functions

Only one dependency: ctypes should be installed.
i(tabsolute_importN(tcmdlinetsymbol_versioning(tgettexttwin32is
Windows NTs
Windows 98cC@s|jjdS(Ntmbcs(tvaluetdecode(tbuf((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pytextract_bufferHstARtWiiiiiiiiiitc
C@sqddlm}trdtjfdY}tjjj}|}tjjj	|tj
|tj|}|s|jt
ddSi
|jd6|jd6|jd	6|jd
6|jd6|jd6|jd
6|jd6|jd6|jd6}nGtr1ddl}|j}	|j	|	}n|jt
ddS|r|jt
dj|d	d|dd|dS|r|jd|n|jt
d|d	d|jt
d|dd|jt
d|jddd|jt
d|jddd|jt
d|jddd|jt
d|jdddS(s1Use trace.note() to dump the running memory info.i(ttracetPROCESS_MEMORY_COUNTERS_EXcB@seZdZdejfdejfdejfdejfdejfdejfdejfdejfd	ejfd
ejfdejfgZRS(sUsed by GetProcessMemoryInfotcbtPageFaultCounttPeakWorkingSetSizetWorkingSetSizetQuotaPeakPagedPoolUsagetQuotaPagedPoolUsagetQuotaPeakNonPagedPoolUsagetQuotaNonPagedPoolUsaget
PagefileUsagetPeakPagefileUsagetPrivateUsage(t__name__t
__module__t__doc__tctypestc_ulongtc_size_tt_fields_(((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pyR~ss Failed to GetProcessMemoryInfo()NRRRRRRRRRRs;Cannot debug memory on win32 without ctypes or win32processs/WorkingSize {0:>7}KiB	PeakWorking {1:>7}KiB	{2}is%ssWorkingSize       %8d KiBsPeakWorking       %8d KiBsPagefileUsage     %8d KiBsPeakPagefileUsage %8d KiBsPrivateUsage      %8d KiBsPageFaultCount    %8d(tbzrlibR
t
has_ctypesRt	Structuretwindlltkernel32tGetCurrentProcesstpsapitGetProcessMemoryInfotbyreftsizeoftnoteRRRRRRRRRRRthas_win32apitwin32processtformattget(
tmessagetshortR
Rtcur_processt
mem_structtrettinfoR-tproc((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pytdebug_memory_win32apizsT	









&&iPicC@sts||fStjjjt}tjd}tjjj||}|rtj	d|j
\}}}}}	}
}}}
}}||
d}|
|d}||fS||fSdS(sReturn size of current console.

    This function try to determine actual size of current working
    console window and return tuple (sizex, sizey) if success,
    or default size (defaultx, defaulty) otherwise.
    ithhhhHhhhhhhiN(R"RR$R%tGetStdHandletWIN32_STDERR_HANDLEtcreate_string_buffertGetConsoleScreenBufferInfotstructtunpacktraw(tdefaultxtdefaultythtcsbitrestbufxtbufytcurxtcurytwattrtleftttoptrighttbottomtmaxxtmaxytsizextsizey((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pytget_console_sizes
0
cC@str[ytjjj}Wntk
r,q[Xtjt}|d||dr[|j	Snt
dkryddlm}t
a
Wqtk
rta
qXnt
rddlm}y|jd|dSWq|jk
rqXndS(shCall SHGetSpecialFolderPathW if available, or return None.

    Result is always unicode (or None).
    i(tshellN(R"RR$tshell32tSHGetSpecialFolderPathWtAttributeErrortcreate_unicode_buffertMAX_PATHtNoneRthas_win32com_shelltwin32com.shellRStTruetImportErrortFalsetSHGetSpecialFolderPathterror(tcsidlR_RRS((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pyt_get_sh_special_folder_paths*




cC@s tt}|r|StdS(sReturn Application Data location.
    Return None if we cannot obtain location.

    Windows defines two 'Application Data' folders per user - a 'roaming'
    one that moves with the user as they logon to different machines, and
    a 'local' one that stays local to the machine.  This returns the 'roaming'
    directory, and thus is suitable for storing user-preferences, etc.
    tAPPDATA(Rbt
CSIDL_APPDATAtget_environ_unicode(tappdata((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pytget_appdata_locations	cC@s3tt}|r|Std}|r,|StS(sReturn Local Application Data location.
    Return the same as get_appdata_location() if we cannot obtain location.

    Windows defines two 'Application Data' folders per user - a 'roaming'
    one that moves with the user as they logon to different machines, and
    a 'local' one that stays local to the machine.  This returns the 'local'
    directory, and thus is suitable for caches, temp files and other things
    which don't need to move with the user.
    tLOCALAPPDATA(RbtCSIDL_LOCAL_APPDATAReRg(tlocal((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pytget_local_appdata_locations
cC@stt}|r|Std}|d	k	r2|Std}|d	k	rftjjtdd|Std}|rtjj|ddStdS(
sReturn user's home location.
    Assume on win32 it's the <My Documents> folder.
    If location cannot be obtained return system drive root,
    i.e. C:    tHOMEtHOMEPATHtHOMEDIRRtWINDIRit/sC:/N(	RbtCSIDL_PERSONALReRYtostpathtjoint
splitdrivetunicode(thomethomepathtwindir((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pytget_home_location scC@stry#tjj}t|dt}Wntk
r<qXttd}tj	td}||tj
|rt|SntdS(sPReturn user name as login name.
    If name cannot be obtained return None.
    tGetUserNameitUSERNAME(
R"RR$tadvapi32tgetattrtsuffixRVt
create_buffertUNLENtc_intR)R	Re(R}R{Rtn((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pyt
get_user_name7s

cC@s/tr7ytjtSWq7ttjfk
r3q7Xntr%ytjj	}Wnt
k
r`q%Xttd}tj
td}t|dtd}|dk	r|t|tj|rt|Stj
td}t|dtd}|dk	r%||tj|r%t|SntdS(sReturn host machine name.
    If name cannot be obtained return None.

    :return: A unicode string representing the host name.
    itGetComputerNameExtGetComputerNametCOMPUTERNAMEN(R,twin32apiRt_WIN32_ComputerNameDnsHostnametNotImplementedErrorR`R"RR$R%RVRtMAX_COMPUTERNAME_LENGTHRR~RRYR)R	Re(R%RRRR((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pyt
get_host_nameNs2

	

	
cC@sD|r@t|tkr@ddlm}|j|j}n|S(Ni(tosutils(ttypeRvR!RRtget_user_encoding(tsR((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pyt_ensure_unicodewscC@sQtjj|ds5|jds5|jdrCd|tfS|tfSdS(Niu*u?u./(RrRstsplitt
startswithR\R^(Rs((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pyt_ensure_with_dirs&cC@s|r|dS|SdS(Ni((Rst	corrected((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pyt_undo_ensure_with_dirscC@st|\}}tj|}|s3|g}n+|r^g|D]}t||^q@}ng|D]}|jdd^qeS(sSame as glob.glob().

    work around bugs in glob.glob()
    - Python bug #1001604 ("glob doesn't return unicode with ...")
    - failing expansion for */* with non-iso-8859-* chars
    u\u/(RtglobRtreplace(t
possible_globtcorrected_globRt
glob_filestelem((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pytglob_ones"cC@s8|s
gSg}x!|D]}|jt|qW|S(s!Replacement for glob expansion by the shell.

    Win32's cmd.exe does not do glob expansion (eg ``*.py``), so we do our own
    here.

    :param file_list: A list of filenames which may include shell globs.
    :return: An expanded list of filenames.

    Introduced in bzrlib 0.18.
    (textendR(t	file_listtexpanded_file_listR((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pytglob_expands
cC@s(ddl}|}tjj|ds5|d}ny|j|jd|}Wntk
rf|SXz5y|j|d\}}Wntk
r|SXWd|j	|X|t
kr|S|tkr$tr$t
j|}t|dkr |ddkr |ddkr |dd!}n|S|S(	sLook up in Windows registry for full path to application executable.
    Typically, applications create subkey with their basename
    in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\

    :param  appname:    name of application (if no filename extension
                        is specified, .exe used)
    :return:    full path to aplication executable from registry,
                or appname itself if nothing found.
    iNis.exes4SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Rt"i(t_winregRrRstsplitexttOpenKeytHKEY_LOCAL_MACHINEtEnvironmentErrortQueryValueExtWindowsErrortCloseKeytREG_SZt
REG_EXPAND_SZR,RtExpandEnvironmentStringstlen(tappnameRtbasenamethkeyRsttype_idtfullpath((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pytget_app_paths0



	2cC@s~trztdkrtj}n	tj}y||tjWqztjk
rv}ddlm	}|j
d||qzXndS(s)Set file attributes to hidden if possibles
Windows 98i(R
s(Unable to set hidden attribute on %r: %sN(t
has_win32filetwinvert	win32filetSetFileAttributesWtSetFileAttributestFILE_ATTRIBUTE_HIDDENt
pywintypesR`R!R
tmutter(RsRteR
((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pytset_file_attr_hiddens	cC@stj|d|}t|}t|t|krHtdn|t|t|}g}xM|D]E\}}|stj|r|j|qo|jt	|qoW|S(s3Convert a Unicode command line into a list of argv arguments.

    It performs wildcard expansion to make wildcards act closer to how they
    work in posix shells, versus how they work by default on Windows. Quoted
    arguments are left untouched.

    :param command_line: The unicode string to split into an arg list.
    :param single_quotes_allowed: Whether single quotes are accepted as quoting
                                  characters like double quotes. False by
                                  default.
    :return: A list of unicode strings.
    tsingle_quotes_alloweds-Split command line can't be shorter than argv(
RtSplittertlistRtAssertionErrorRt	has_magictappendRR(tcommand_linetargvRRt	argumentstargst	is_quotedtarg((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pyt_command_line_to_argvscC@shtjtj}|dtjjf}|}|dkrNtjnt|tj	d}|S(NtGetCommandLineWi(
RtWINFUNCTYPEt	c_wchar_pR$R%RYtWinErrorRtsysR(t	prototypeRRR((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pytget_unicode_argv#s	c
C@sttdd}|dkrpddlm}m}m}tj||||dtj	j
f}|t_nd}xytrtj
|}||||}|stj}	|	dkr|Stj|	n||kr|| S|}qyWdS(sGet `key` from environment as unicode or `default` if unset

        The environment is natively unicode on modern windows versions but
        Python 2 only accesses it through the legacy bytestring api.

        Environmental variable names are case insenstive on Windows.

        A large enough buffer will be allocated to retrieve the value, though
        it may take two calls to the underlying library function.

        This needs ctypes because pywin32 does not expose the wide version.
        t_c_functioni(tDWORDtLPCWSTRtLPWSTRtGetEnvironmentVariableWiiN(R~ReRYtctypes.wintypesRRRRRR$R%RR\RWtGetLastErrorR(
tkeytdefaulttcfuncRRRtbuffer_sizetbuffertlengthtcode((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pyRe/s$
	cC@sGddlm}ytj|j|jSWntk
rB|SXdS(sGet `key` from environment as unicode or `default` if unset

        Fallback version that should basically never be needed.
        i(RN(R!RRrtenvironRRtKeyError(RRR((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pyRePs

cC@skytjdt|}WnAtjk
r\}|ddkrBtS|ddkrVtSnX|jtS(s>True if pid doesn't correspond to live process on this machineiiiiW(RtOpenProcessR^RR`R\tclose(tpidthandleR((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pyt_pywin32_is_local_pid_dead]s
(tBOOLRtHANDLEtCloseHandleRcC@sdtdt|}|sVtj}|dkr4tS|dkrDtStj|nt|tS(s>True if pid doesn't correspond to live process on this machineiiiW(t_OpenProcessR^RRR\Rt_CloseHandle(RRt	errorcode((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pyt_ctypes_is_local_pid_deadrs
cC@s trt|tjrtStS(s3True if exception instance is an error from pywin32(thas_pywintypest
isinstanceRR`R\R^(tevalue((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pyt_is_pywintypes_errors(iii(iii(iii(iii(iii(ZRt
__future__RRtoperatorRrR=RR!RRtbzrlib.i18nRtplatformtgetwindowsversiont_majort_minort_buildt	_platformt_textRRYRR\R"R]R^R;RR	RRWt
attrgetterRRRR,RRRZtWIN32_STDIN_HANDLEtWIN32_STDOUT_HANDLER:RdRiRqRXRRRRR7RRRbRgRkRzRRRtdeprecated_functiont
deprecated_inRtget_appdata_location_unicodetget_home_location_unicodetget_user_name_unicodetget_host_name_unicodeRRRRRRRRReRtis_local_pid_deadRRRRR$R%t	_kernel32RRRRR(((s5/usr/lib/python2.7/dist-packages/bzrlib/win32utils.pyt<module>s		


				







C	#					)					)	)	 	
		
	

Copyright © 2017 || Recoded By Mr.Bumblebee