def setup(self):
        def _log_starting_vals():
            def _get_lbry_files_json():
                r = self._get_lbry_files()
                return json.dumps(r)

            def _get_lbryum_version():
                r = urlopen("https://raw.githubusercontent.com/lbryio/lbryum/master/lib/version.py").read().split('\n')
                version = next(line.split("=")[1].split("#")[0].replace(" ", "")
                               for line in r if "ELECTRUM_VERSION" in line)
                version = version.replace("'", "")
                log.info("remote lbryum " + str(version) + " > local lbryum " + str(lbryum_version) + " = " + str(
                    version > lbryum_version))
                return version

            def _get_lbrynet_version():
                r = urlopen("https://raw.githubusercontent.com/lbryio/lbry/master/lbrynet/__init__.py").read().split('\n')
                vs = next(i for i in r if 'version =' in i).split("=")[1].replace(" ", "")
                vt = tuple(int(x) for x in vs[1:-1].split(','))
                vr = ".".join([str(x) for x in vt])
                log.info("remote lbrynet " + str(vr) + " > local lbrynet " + str(lbrynet_version) + " = " + str(
                    vr > lbrynet_version))
                return vr

            self.git_lbrynet_version = _get_lbrynet_version()
            self.git_lbryum_version = _get_lbryum_version()

            log.info("LBRY Files: " + _get_lbry_files_json())
            log.info("Starting balance: " + str(self.session.wallet.wallet_balance))

            return defer.succeed(None)

        def _announce_startup():
            def _announce():
                self.announced_startup = True
                self.startup_status = STARTUP_STAGES[5]
                log.info("[" + str(datetime.now()) + "] Started lbrynet-daemon")

            if self.first_run:
                d = self._upload_log(name_prefix="fr")
            else:
                d = self._upload_log(exclude_previous=True, name_prefix="start")

            if float(self.session.wallet.wallet_balance) == 0.0:
                d.addCallback(lambda _: self._check_first_run())
                d.addCallback(self._show_first_run_result)

            d.addCallback(lambda _: _announce())
            return d

        log.info("[" + str(datetime.now()) + "] Starting lbrynet-daemon")

        d = defer.Deferred()
        d.addCallback(lambda _: self._initial_setup())
        d.addCallback(self._set_daemon_settings)
        d.addCallback(lambda _: threads.deferToThread(self._setup_data_directory))
        d.addCallback(lambda _: self._check_db_migration())
        d.addCallback(lambda _: self._get_settings())
        d.addCallback(lambda _: self._get_lbrycrdd_path())
        d.addCallback(lambda _: self._get_session())
        d.addCallback(lambda _: add_lbry_file_to_sd_identifier(self.sd_identifier))
        d.addCallback(lambda _: self._setup_stream_identifier())
        d.addCallback(lambda _: self._setup_lbry_file_manager())
        d.addCallback(lambda _: self._setup_lbry_file_opener())
        d.addCallback(lambda _: self._setup_query_handlers())
        d.addCallback(lambda _: self._setup_server())
        d.addCallback(lambda _: self._setup_fetcher())
        d.addCallback(lambda _: _log_starting_vals())
        d.addCallback(lambda _: _announce_startup())
        d.callback(None)

        return defer.succeed(None)
dataset/ETHPy150Open lbryio/lbry/lbrynet/lbrynet_daemon/LBRYDaemon.py/LBRYDaemon.setup/original