當前位置: 首頁>>代碼示例>>Python>>正文


Python shellcon.CSIDL_APPDATA屬性代碼示例

本文整理匯總了Python中win32com.shell.shellcon.CSIDL_APPDATA屬性的典型用法代碼示例。如果您正苦於以下問題:Python shellcon.CSIDL_APPDATA屬性的具體用法?Python shellcon.CSIDL_APPDATA怎麽用?Python shellcon.CSIDL_APPDATA使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在win32com.shell.shellcon的用法示例。


在下文中一共展示了shellcon.CSIDL_APPDATA屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: win32_appdata

# 需要導入模塊: from win32com.shell import shellcon [as 別名]
# 或者: from win32com.shell.shellcon import CSIDL_APPDATA [as 別名]
def win32_appdata():
    # try to use win32 api to get the AppData folder since python doesn't populate os.environ with unicode strings.

    try:
        import win32com.client

        objShell = win32com.client.Dispatch("WScript.Shell")
        return objShell.SpecialFolders("AppData")
    except Exception, e:
        print "Error while getting AppData folder using WScript.Shell.SpecialFolders: {0!r}".format(e)
        try:
            from win32com.shell import shell, shellcon

            return shell.SHGetPathFromIDListEx(
                shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_APPDATA)
            )
        except Exception, e:
            print "Error while getting AppData folder using SHGetSpecialFolderLocation: {0!r}".format(e)

            return os.environ['APPDATA'].decode(sys.getfilesystemencoding()) 
開發者ID:mcgreentn,項目名稱:GDMC,代碼行數:22,代碼來源:directories.py

示例2: win32_appdata

# 需要導入模塊: from win32com.shell import shellcon [as 別名]
# 或者: from win32com.shell.shellcon import CSIDL_APPDATA [as 別名]
def win32_appdata():
    # try to use win32 api to get the AppData folder since python doesn't populate os.environ with unicode strings.

    try:
        import win32com.client

        objShell = win32com.client.Dispatch("WScript.Shell")
        return objShell.SpecialFolders("AppData")
    except Exception as e:
        print "Error while getting AppData folder using WScript.Shell.SpecialFolders: {0!r}".format(e)
        try:
            from win32com.shell import shell, shellcon

            return shell.SHGetPathFromIDListEx(
                shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_APPDATA)
            )
        except Exception as e:
            print "Error while getting AppData folder using SHGetSpecialFolderLocation: {0!r}".format(e)

            return os.environ['APPDATA'].decode(sys.getfilesystemencoding()) 
開發者ID:Podshot,項目名稱:MCEdit-Unified,代碼行數:22,代碼來源:directories.py

示例3: get_data_location

# 需要導入模塊: from win32com.shell import shellcon [as 別名]
# 或者: from win32com.shell.shellcon import CSIDL_APPDATA [as 別名]
def get_data_location():
	data_dir = None

	if is_windows():
		data_location = os.getenv('APPDATA')

		if not os.path.exists(data_location):
			try:
				from win32com.shell import shellcon, shell
				data_location = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0)

			except ImportError: # quick semi-nasty fallback for non-windows/win32com case
				data_location = os.path.expanduser("~")

		data_dir = os.path.join(data_location, constant.APP_NAME)

		if not os.path.exists(data_dir):
			os.mkdir(data_dir)

	if is_linux() or is_darwin():
		home = path_translate("~")
		data_dir = os.path.join(home, ".{}".format(constant.APP_NAME))

		if not os.path.exists(data_dir):
			os.mkdir(data_dir)

	return data_dir 
開發者ID:turingsec,項目名稱:marsnake,代碼行數:29,代碼來源:common.py

示例4: appdatadirectory

# 需要導入模塊: from win32com.shell import shellcon [as 別名]
# 或者: from win32com.shell.shellcon import CSIDL_APPDATA [as 別名]
def appdatadirectory(  ):
    """Attempt to retrieve the current user's app-data directory

    This is the location where application-specific
    files should be stored.  On *nix systems, this will
    be the ${HOME}/.config directory.  On Win32 systems, it will be
    the "Application Data" directory.  Note that for
    Win32 systems it is normal to create a sub-directory
    for storing data in the Application Data directory.
    """
    if shell:
        # on Win32 and have Win32all extensions, best-case
        return shell_getShellFolder(shellcon.CSIDL_APPDATA)
    if _winreg:
        # on Win32, but no Win32 shell com available, this uses
        # a direct registry access, likely to fail on Win98/Me
        return _winreg_getShellFolder( 'AppData' )
    # okay, what if for some reason _winreg is missing? would we want to allow ctypes?
    ## default case, look for name in environ...
    for name in ['APPDATA', 'HOME']:
        if name in os.environ:
            return os.path.join( os.environ[name], '.config' )
    # well, someone's being naughty, see if we can get ~ to expand to a directory...
    possible = os.path.abspath(os.path.expanduser( '~/.config' ))
    if os.path.exists( possible ):
        return possible
    raise OSError( """Unable to determine user's application-data directory, no ${HOME} or ${APPDATA} in environment""" ) 
開發者ID:lrq3000,項目名稱:pyFileFixity,代碼行數:29,代碼來源:homedirectory.py

示例5: _get_nnabla_config

# 需要導入模塊: from win32com.shell import shellcon [as 別名]
# 或者: from win32com.shell.shellcon import CSIDL_APPDATA [as 別名]
def _get_nnabla_config():
    config_files = []
    config_files.append(join(dirname(abspath(__file__)), 'nnabla.conf'))
    if os.name == 'posix':
        config_files.append('/etc/nnabla.conf')
        config_files.append(abspath(join(expanduser('~'), '.nnabla')))
        config_files.append(abspath(join(os.getcwd(), 'nnabla.conf')))
    elif os.name == 'nt':
        from win32com.shell import shell, shellcon
        config_files.append(abspath(join(shell.SHGetFolderPath(
            0, shellcon.CSIDL_COMMON_APPDATA, None, 0), 'NNabla', 'nnabla.ini')))
        config_files.append(abspath(join(shell.SHGetFolderPath(
            0, shellcon.CSIDL_APPDATA, None, 0), 'NNabla', 'nnabla.ini')))
    config_files.append(abspath(join(os.getcwd(), 'nnabla.conf')))

    if "NNABLA_CONFIG_FILE_PATH" in os.environ:
        conf = os.environ["NNABLA_CONFIG_FILE_PATH"]
        if os.path.exists(conf):
            config_files.append(conf)

    config = configparser.RawConfigParser()
    for filename in config_files:
        # print(' Checking {}'.format(filename))
        if exists(filename):
            # print(' Read from {}'.format(filename))
            config.read(filename)
    return config 
開發者ID:sony,項目名稱:nnabla,代碼行數:29,代碼來源:config.py

示例6: get_config_dir

# 需要導入模塊: from win32com.shell import shellcon [as 別名]
# 或者: from win32com.shell.shellcon import CSIDL_APPDATA [as 別名]
def get_config_dir():
    """a cross-platform way to get user's config directory.
    """
    if _config_dir is not None:
        return _config_dir

    shellvars = ['${APPDATA}', '${HOME}', '${USERPROFILE}']
    dir_root = get_dir_root(shellvars)

    if dir_root is None and os.name == 'nt':
        app_dir = get_shell_dir(shellcon.CSIDL_APPDATA)
        if app_dir is not None:
            dir_root = app_dir

    if dir_root is None and os.name == 'nt':
        tmp_dir_root = os.path.split(sys.executable)[0]
        if os.access(tmp_dir_root, os.R_OK|os.W_OK):
            dir_root = tmp_dir_root

    return dir_root



# For string literal subdirectories, starting with unicode and then
# converting to filesystem encoding may not always be necessary, but it seems
# safer to do so.  --Dave 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:28,代碼來源:platform.py


注:本文中的win32com.shell.shellcon.CSIDL_APPDATA屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。