def _initial_setup(self):
        def _log_platform():
            log.info("Platform: " + json.dumps(self.platform_info))
            return defer.succeed(None)

        def _load_daemon_conf():
            if os.path.isfile(self.daemon_conf):
                f = open(self.daemon_conf, "r")
                loaded_settings = json.loads(f.read())
                f.close()
                missing_settings = {}
                for k in self.default_settings.keys():
                    if k not in loaded_settings.keys():
                        missing_settings[k] = self.default_settings[k]
                if missing_settings != {}:
                    for k in missing_settings.keys():
                        log.info("Adding missing setting: " + k + " with default value: " + str(missing_settings[k]))
                        loaded_settings[k] = missing_settings[k]
                    f = open(self.daemon_conf, "w")
                    f.write(json.dumps(loaded_settings))
                    f.close()
                rsettings = loaded_settings
            else:
                log.info("Writing default settings : " + json.dumps(self.default_settings) + " --> " + str(self.daemon_conf))
                f = open(self.daemon_conf, "w")
                f.write(json.dumps(self.default_settings))
                f.close()
                rsettings = self.default_settings
            for k in rsettings.keys():
                self.__dict__[k] = rsettings[k]
            return rsettings

        d = _log_platform()
        d.addCallback(lambda _: _load_daemon_conf())

        return d
dataset/ETHPy150Open lbryio/lbry/lbrynet/lbrynet_daemon/LBRYDaemon.py/LBRYDaemon._initial_setup/original