当前位置: 首页>>代码示例>>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;未经允许,请勿转载。