mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-29 17:28:53 +00:00
create _NoNetworkClient using same code as _Client
This commit is contained in:
parent
22e2d0a417
commit
86a9ce5793
@ -166,13 +166,23 @@ class Terminator(service.Service):
|
||||
|
||||
|
||||
#@defer.inlineCallbacks
|
||||
def create_client(basedir=u"."):
|
||||
def create_client(basedir=u".", _client_factory=None):
|
||||
"""
|
||||
Creates a new client instance (a subclass of Node).
|
||||
|
||||
:param basedir: the node directory
|
||||
|
||||
:param _client_factory: for testing; the class to instantiate
|
||||
"""
|
||||
# load configuration
|
||||
config = read_config(basedir, u"client.port", _valid_config_sections=_valid_config_sections)
|
||||
config.write_private_config("README", CLIENT_README)
|
||||
|
||||
if _client_factory is None:
|
||||
_client_factory = _Client
|
||||
|
||||
#defer.returnValue(
|
||||
return _Client(
|
||||
return _client_factory(
|
||||
config,
|
||||
)
|
||||
#)
|
||||
|
@ -34,7 +34,7 @@ def create_introducer(basedir=u"."):
|
||||
config = read_config(
|
||||
basedir, u"client.port",
|
||||
generated_files=["introducer.furl"],
|
||||
_valid_config_secionts=_valid_config_sections,
|
||||
_valid_config_sections=_valid_config_sections,
|
||||
)
|
||||
config.write_private_config("README", INTRODUCER_README)
|
||||
#defer.returnValue(
|
||||
|
@ -313,6 +313,7 @@ class _Config(object):
|
||||
config file that resides within the subdirectory named 'private'), and
|
||||
return it.
|
||||
"""
|
||||
fileutil.make_dirs(os.path.join(self._basedir, "private"), 0700)
|
||||
privname = os.path.join(self._basedir, "private", name)
|
||||
with open(privname, "w") as f:
|
||||
f.write(value)
|
||||
|
@ -27,7 +27,7 @@ from allmydata.util.assertutil import _assert
|
||||
|
||||
from allmydata import uri as tahoe_uri
|
||||
from allmydata.client import _Client
|
||||
from allmydata.client import _valid_config_sections as client_valid_config_sections
|
||||
from allmydata.client import create_client
|
||||
from allmydata.storage.server import StorageServer, storage_index_to_dir
|
||||
from allmydata.util import fileutil, idlib, hashutil
|
||||
from allmydata.util.hashutil import permute_server_hash
|
||||
@ -185,12 +185,8 @@ class NoNetworkStorageBroker(object):
|
||||
return [] # FIXME?
|
||||
|
||||
|
||||
def NoNetworkClient(basedir):
|
||||
# XXX FIXME this is just to avoid massive search-replace for now;
|
||||
# should be create_nonetwork_client() or something...
|
||||
from allmydata.node import read_config
|
||||
config = read_config(basedir, u'client.port', _valid_config_sections=client_valid_config_sections)
|
||||
return _NoNetworkClient(config)
|
||||
def create_no_network_client(basedir):
|
||||
return create_client(basedir, _client_factory=_NoNetworkClient)
|
||||
|
||||
|
||||
class _NoNetworkClient(_Client):
|
||||
@ -293,7 +289,7 @@ class NoNetworkGrid(service.MultiService):
|
||||
c = self.client_config_hooks[i](clientdir)
|
||||
|
||||
if not c:
|
||||
c = NoNetworkClient(clientdir)
|
||||
c = create_no_network_client(clientdir)
|
||||
c.set_default_mutable_keysize(TEST_RSA_KEY_SIZE)
|
||||
|
||||
c.nodeid = clientid
|
||||
|
Loading…
Reference in New Issue
Block a user