Exemple #1
0
 def __init__(self):
     self.session = None
     self.known_dht_nodes = [('104.236.42.182', 4000)]
     self.db_dir = os.path.join(os.path.expanduser("~"), ".lbrydownloader")
     self.blobfile_dir = os.path.join(self.db_dir, "blobfiles")
     self.peer_port = 3333
     self.dht_node_port = 4444
     self.run_server = True
     self.first_run = False
     self.current_db_revision = 1
     if os.name == "nt":
         from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle
         self.download_directory = get_path(FOLDERID.Downloads, UserHandle.current)
         self.wallet_dir = os.path.join(get_path(FOLDERID.RoamingAppData, UserHandle.current), "lbrycrd")
     else:
         self.download_directory = os.getcwd()
         self.wallet_dir = os.path.join(os.path.expanduser("~"), ".lbrycrd")
     self.wallet_conf = os.path.join(self.wallet_dir, "lbrycrd.conf")
     self.wallet_user = None
     self.wallet_password = None
     self.sd_identifier = StreamDescriptorIdentifier()
     self.wallet_rpc_port = 8332
     self.download_deferreds = []
     self.stream_frames = []
     self.default_blob_data_payment_rate = MIN_BLOB_DATA_PAYMENT_RATE
     self.use_upnp = True
     self.start_lbrycrdd = True
     if os.name == "nt":
         self.lbrycrdd_path = "lbrycrdd.exe"
     else:
         self.lbrycrdd_path = None
         self.default_lbrycrdd_path = "./lbrycrdd"
     self.delete_blobs_on_remove = True
     self.blob_request_payment_rate_manager = None
Exemple #2
0
        def _set_vars():
            self.fetcher = None
            self.current_db_revision = 1
            self.run_server = True
            self.session = None
            self.known_dht_nodes = [('104.236.42.182', 4000)]
            self.db_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
            self.blobfile_dir = os.path.join(self.db_dir, "blobfiles")
            self.peer_port = 3333
            self.dht_node_port = 4444
            self.first_run = False
            self.current_db_revision = 1
            if os.name == "nt":
                from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle
                self.download_directory = get_path(FOLDERID.Downloads, UserHandle.current)
                self.wallet_dir = os.path.join(get_path(FOLDERID.RoamingAppData, UserHandle.current), "lbrycrd")
            elif sys.platform == "darwin":
                self.download_directory = os.path.join(os.path.expanduser("~"), 'Downloads')
                self.wallet_dir = os.path.join(os.path.expanduser("~"), "Library/Application Support/lbrycrd")
            else:
                self.wallet_dir = os.path.join(os.path.expanduser("~"), ".lbrycrd")
                self.download_directory = os.path.join(os.path.expanduser("~"), 'Downloads')

            self.wallet_conf = os.path.join(self.wallet_dir, "lbrycrd.conf")
            self.wallet_user = None
            self.wallet_password = None
            self.sd_identifier = StreamDescriptorIdentifier()
            self.stream_info_manager = TempLBRYFileMetadataManager()
            self.wallet_rpc_port = 8332
            self.downloads = []
            self.stream_frames = []
            self.default_blob_data_payment_rate = MIN_BLOB_DATA_PAYMENT_RATE
            self.use_upnp = True
            self.start_lbrycrdd = True
            if os.name == "nt":
                self.lbrycrdd_path = "lbrycrdd.exe"
            else:
                self.lbrycrdd_path = "./lbrycrdd"
            self.delete_blobs_on_remove = True
            self.blob_request_payment_rate_manager = None
            self.lbry_file_metadata_manager = None
            self.lbry_file_manager = None
            self.settings = LBRYSettings(self.db_dir)
            self.wallet_type = "lbrycrd"
            self.lbrycrd_conf = os.path.join(self.wallet_dir, "lbrycrd.conf")
            self.autofetcher_conf = os.path.join(self.wallet_dir, "autofetcher.conf")
            self.rpc_conn = None
            self.files = []
            self.created_data_dir = False
            if not os.path.exists(self.db_dir):
                os.mkdir(self.db_dir)
                self.created_data_dir = True
            self.session_settings = None
            self.data_rate = 0.5
            self.max_key_fee = 100.0
            return defer.succeed(None)
Exemple #3
0
def _get_new_directories(platform):
    dirs = {}
    if platform == ANDROID:
        dirs['data'] = '%s/lbrynet' % android_app_internal_storage_dir()
        dirs['lbryum'] = '%s/lbryum' % android_app_internal_storage_dir()
        dirs['download'] = '%s/Download' % android_internal_storage_dir()
    elif platform == WINDOWS:
        dirs['data'] = user_data_dir('lbrynet', 'lbry')
        dirs['lbryum'] = user_data_dir('lbryum', 'lbry')
        dirs['download'] = get_path(FOLDERID.Downloads, UserHandle.current)
    elif platform == DARWIN:
        _get_old_directories(platform)
    elif platform == LINUX:
        dirs['data'] = user_data_dir('lbry/lbrynet')
        dirs['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)
                dirs['download'] = re.sub('\"', '', down_dir)
        except EnvironmentError:
            dirs['download'] = os.getenv('XDG_DOWNLOAD_DIR')

        if not dirs['download']:
            dirs['download'] = os.path.expanduser('~/Downloads')
    else:
        raise ValueError('unknown platform value')
    return dirs
Exemple #4
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
Exemple #5
0
def _get_old_directories(platform):
    dirs = {}
    if platform == WINDOWS:
        appdata = get_path(FOLDERID.RoamingAppData, UserHandle.current)
        dirs['data'] = os.path.join(appdata, 'lbrynet')
        dirs['lbryum'] = os.path.join(appdata, 'lbryum')
        dirs['download'] = get_path(FOLDERID.Downloads, UserHandle.current)
    elif platform == DARWIN:
        dirs['data'] = user_data_dir('LBRY')
        dirs['lbryum'] = os.path.expanduser('~/.lbryum')
        dirs['download'] = os.path.expanduser('~/Downloads')
    elif platform == LINUX:
        dirs['data'] = os.path.expanduser('~/.lbrynet')
        dirs['lbryum'] = os.path.expanduser('~/.lbryum')
        dirs['download'] = os.path.expanduser('~/Downloads')
    else:
        raise ValueError('unknown platform value')
    return dirs
Exemple #6
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
Exemple #7
0
settings_decoders = {'.json': json.loads, '.yml': yaml.load}

settings_encoders = {'.json': json.dumps, '.yml': yaml.safe_dump}

if sys.platform.startswith('darwin'):
    platform = DARWIN
    default_download_directory = os.path.join(os.path.expanduser('~'),
                                              'Downloads')
    default_data_dir = user_data_dir('LBRY')
    default_lbryum_dir = os.path.join(os.path.expanduser('~'), '.lbryum')
elif sys.platform.startswith('win'):
    platform = WINDOWS
    from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle

    default_download_directory = get_path(FOLDERID.Downloads,
                                          UserHandle.current)
    default_data_dir = os.path.join(
        get_path(FOLDERID.RoamingAppData, UserHandle.current), 'lbrynet')
    default_lbryum_dir = os.path.join(
        get_path(FOLDERID.RoamingAppData, UserHandle.current), 'lbryum')
else:
    platform = LINUX
    default_download_directory = os.path.join(os.path.expanduser('~'),
                                              'Downloads')
    default_data_dir = os.path.join(os.path.expanduser('~'), '.lbrynet')
    default_lbryum_dir = os.path.join(os.path.expanduser('~'), '.lbryum')

ICON_PATH = 'icons' if platform is WINDOWS else 'app.icns'


def server_port(server_and_port):
Exemple #8
0
                     ('lbrynet3.lbry.io', 4444)]

settings_decoders = {'.json': json.loads, '.yml': yaml.load}

settings_encoders = {'.json': json.dumps, '.yml': yaml.safe_dump}

if 'darwin' in sys.platform:
    platform = DARWIN
    default_download_dir = os.path.expanduser('~/Downloads')
    default_data_dir = user_data_dir('LBRY')
    default_lbryum_dir = os.path.expanduser('~/.lbryum')
elif 'nt' in sys.platform:
    platform = WINDOWS
    from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle

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

    # This checks whether the folders are still in their old locations
    if os.path.isdir(user_data_dir('lbryum', roaming=True)) and \
       os.path.isdir(user_data_dir('lbrynet', roaming=True)):
        default_data_dir = user_data_dir('lbrynet', roaming=True)
        default_lbryum_dir = user_data_dir('lbryum', roaming=True)
    else:
        default_data_dir = user_data_dir('lbrynet', 'lbry')
        default_lbryum_dir = user_data_dir('lbryum', 'lbry')
else:
    platform = LINUX

    # This checks whether the folders are still in their old locations
    if os.path.isdir(os.path.expanduser('~/.lbrynet')) and \
       os.path.isdir(os.path.expanduser('~/.lbryum')):
Exemple #9
0
settings_encoders = {
    '.json': json.dumps,
    '.yml': yaml.safe_dump
}

if sys.platform.startswith('darwin'):
    platform = DARWIN
    default_download_directory = os.path.join(os.path.expanduser('~'), 'Downloads')
    default_data_dir = user_data_dir('LBRY')
    default_lbryum_dir = os.path.join(os.path.expanduser('~'), '.lbryum')
elif sys.platform.startswith('win'):
    platform = WINDOWS
    from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle

    default_download_directory = get_path(FOLDERID.Downloads, UserHandle.current)
    default_data_dir = os.path.join(
        get_path(FOLDERID.RoamingAppData, UserHandle.current), 'lbrynet')
    default_lbryum_dir = os.path.join(
        get_path(FOLDERID.RoamingAppData, UserHandle.current), 'lbryum')
else:
    platform = LINUX
    default_download_directory = os.path.join(os.path.expanduser('~'), 'Downloads')
    default_data_dir = os.path.join(os.path.expanduser('~'), '.lbrynet')
    default_lbryum_dir = os.path.join(os.path.expanduser('~'), '.lbryum')

ICON_PATH = 'icons' if platform is WINDOWS else 'app.icns'


def server_port(server_and_port):
    server, port = server_and_port.split(':')