cliutils.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:python-redfish-utility 作者: DMTF 项目源码 文件源码
def get_user_config_dir():
    """Platform specific directory for user configuration.

    :returns: returns the user configuration directory.
    :rtype: string
    """
    if os.name == 'nt':
        try:
            csidl_appdata = 26

            shgetfolderpath = windll.shell32.SHGetFolderPathW
            shgetfolderpath.argtypes = [wintypes.HWND, ctypes.c_int, \
                             wintypes.HANDLE, wintypes.DWORD, wintypes.LPCWSTR]


            path_buf = wintypes.create_unicode_buffer(wintypes.MAX_PATH)
            result = shgetfolderpath(0, csidl_appdata, 0, 0, path_buf)

            if result == 0:
                return path_buf.value
        except ImportError:
            pass

        return os.environ['APPDATA']
    else:
        return os.path.expanduser('~')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号