示例#1
0
def _get_new_directories(platform_type):
    directories = {}
    if platform_type == ANDROID:
        directories['data'] = '%s/lbrynet' % android_app_internal_storage_dir()
        directories['lbryum'] = '%s/lbryum' % android_app_internal_storage_dir(
        )
        directories['download'] = '%s/Download' % android_internal_storage_dir(
        )
    elif platform_type == WINDOWS:
        directories['data'] = user_data_dir('lbrynet', 'lbry')
        directories['lbryum'] = user_data_dir('lbryum', 'lbry')
        directories['download'] = get_path(FOLDERID.Downloads,
                                           UserHandle.current)
    elif platform_type == DARWIN:
        directories = _get_old_directories(platform_type)
    elif platform_type == LINUX:
        directories['data'] = user_data_dir('lbry/lbrynet')
        directories['lbryum'] = user_data_dir('lbry/lbryum')
        try:
            with open(os.path.join(user_config_dir(), 'user-dirs.dirs'),
                      'r') as xdg:
                down_dir = re.search(r'XDG_DOWNLOAD_DIR=(.+)',
                                     xdg.read()).group(1)
                down_dir = re.sub('\$HOME', os.getenv('HOME'), down_dir)
                directories['download'] = re.sub('\"', '', down_dir)
        except EnvironmentError:
            directories['download'] = os.getenv('XDG_DOWNLOAD_DIR')

        if not directories['download']:
            directories['download'] = os.path.expanduser('~/Downloads')
    else:
        raise ValueError('unknown platform value')
    return directories
示例#2
0
文件: conf.py 项目: hyn6014/lbry
def get_windows_directories() -> typing.Tuple[str, str, str]:
    from lbrynet.winpaths import get_path, FOLDERID, UserHandle

    download_dir = get_path(FOLDERID.Downloads, UserHandle.current)

    # old
    appdata = get_path(FOLDERID.RoamingAppData, UserHandle.current)
    data_dir = os.path.join(appdata, 'lbrynet')
    lbryum_dir = os.path.join(appdata, 'lbryum')
    if os.path.isdir(data_dir) or os.path.isdir(lbryum_dir):
        return data_dir, lbryum_dir, download_dir

    # new
    data_dir = user_data_dir('lbrynet', 'lbry')
    lbryum_dir = user_data_dir('lbryum', 'lbry')
    download_dir = get_path(FOLDERID.Downloads, UserHandle.current)
    return data_dir, lbryum_dir, download_dir
示例#3
0
def _get_old_directories(platform_type):
    directories = {}
    if platform_type == WINDOWS:
        appdata = get_path(FOLDERID.RoamingAppData, UserHandle.current)
        directories['data'] = os.path.join(appdata, 'lbrynet')
        directories['lbryum'] = os.path.join(appdata, 'lbryum')
        directories['download'] = get_path(FOLDERID.Downloads,
                                           UserHandle.current)
    elif platform_type == DARWIN:
        directories['data'] = user_data_dir('LBRY')
        directories['lbryum'] = os.path.expanduser('~/.lbryum')
        directories['download'] = os.path.expanduser('~/Downloads')
    elif platform_type == LINUX:
        directories['data'] = os.path.expanduser('~/.lbrynet')
        directories['lbryum'] = os.path.expanduser('~/.lbryum')
        directories['download'] = os.path.expanduser('~/Downloads')
    else:
        raise ValueError('unknown platform value')
    return directories