mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-01 18:56:41 +00:00
change imports; introducer client.read_config
This commit is contained in:
parent
4c7f60f42a
commit
2937c729e3
@ -28,9 +28,7 @@ from allmydata.history import History
|
|||||||
from allmydata.interfaces import IStatsProducer, SDMF_VERSION, MDMF_VERSION
|
from allmydata.interfaces import IStatsProducer, SDMF_VERSION, MDMF_VERSION
|
||||||
from allmydata.nodemaker import NodeMaker
|
from allmydata.nodemaker import NodeMaker
|
||||||
from allmydata.blacklist import Blacklist
|
from allmydata.blacklist import Blacklist
|
||||||
from allmydata.node import OldConfigOptionError, _common_config_sections
|
from allmydata import node
|
||||||
from allmydata.node import read_config
|
|
||||||
from allmydata.node import get_app_versions
|
|
||||||
|
|
||||||
|
|
||||||
KiB=1024
|
KiB=1024
|
||||||
@ -40,7 +38,7 @@ TiB=1024*GiB
|
|||||||
PiB=1024*TiB
|
PiB=1024*TiB
|
||||||
|
|
||||||
def _valid_config_sections():
|
def _valid_config_sections():
|
||||||
cfg = _common_config_sections()
|
cfg = node._common_config_sections()
|
||||||
cfg.update({
|
cfg.update({
|
||||||
"client": (
|
"client": (
|
||||||
"helper.furl",
|
"helper.furl",
|
||||||
@ -165,6 +163,14 @@ class Terminator(service.Service):
|
|||||||
return service.Service.stopService(self)
|
return service.Service.stopService(self)
|
||||||
|
|
||||||
|
|
||||||
|
def read_config(basedir, portnumfile, generated_files=[]):
|
||||||
|
return node.read_config(
|
||||||
|
basedir, portnumfile,
|
||||||
|
generated_files=generated_files,
|
||||||
|
_valid_config_sections=_valid_config_sections,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
#@defer.inlineCallbacks
|
#@defer.inlineCallbacks
|
||||||
def create_client(basedir=u".", _client_factory=None):
|
def create_client(basedir=u".", _client_factory=None):
|
||||||
"""
|
"""
|
||||||
@ -175,9 +181,7 @@ def create_client(basedir=u".", _client_factory=None):
|
|||||||
:param _client_factory: for testing; the class to instantiate
|
:param _client_factory: for testing; the class to instantiate
|
||||||
"""
|
"""
|
||||||
node.create_node_dir(basedir, CLIENT_README)
|
node.create_node_dir(basedir, CLIENT_README)
|
||||||
|
config = read_config(basedir, u"client.port")
|
||||||
# load configuration
|
|
||||||
config = read_config(basedir, u"client.port", _valid_config_sections=_valid_config_sections)
|
|
||||||
|
|
||||||
if _client_factory is None:
|
if _client_factory is None:
|
||||||
_client_factory = _Client
|
_client_factory = _Client
|
||||||
@ -301,7 +305,7 @@ class _Client(node.Node, pollmixin.PollMixin):
|
|||||||
self.nickname,
|
self.nickname,
|
||||||
str(allmydata.__full_version__),
|
str(allmydata.__full_version__),
|
||||||
str(self.OLDEST_SUPPORTED_VERSION),
|
str(self.OLDEST_SUPPORTED_VERSION),
|
||||||
get_app_versions(), self._sequencer,
|
node.get_app_versions(), self._sequencer,
|
||||||
introducer_cache_filepath)
|
introducer_cache_filepath)
|
||||||
self.introducer_clients.append(ic)
|
self.introducer_clients.append(ic)
|
||||||
self.introducer_furls.append(introducer['furl'])
|
self.introducer_furls.append(introducer['furl'])
|
||||||
@ -596,8 +600,10 @@ class _Client(node.Node, pollmixin.PollMixin):
|
|||||||
def init_magic_folder(self):
|
def init_magic_folder(self):
|
||||||
#print "init_magic_folder"
|
#print "init_magic_folder"
|
||||||
if self.config.get_config("drop_upload", "enabled", False, boolean=True):
|
if self.config.get_config("drop_upload", "enabled", False, boolean=True):
|
||||||
raise OldConfigOptionError("The [drop_upload] section must be renamed to [magic_folder].\n"
|
raise node.OldConfigOptionError(
|
||||||
"See docs/frontends/magic-folder.rst for more information.")
|
"The [drop_upload] section must be renamed to [magic_folder].\n"
|
||||||
|
"See docs/frontends/magic-folder.rst for more information."
|
||||||
|
)
|
||||||
|
|
||||||
if self.config.get_config("magic_folder", "enabled", False, boolean=True):
|
if self.config.get_config("magic_folder", "enabled", False, boolean=True):
|
||||||
from allmydata.frontends import magic_folder
|
from allmydata.frontends import magic_folder
|
||||||
|
@ -16,8 +16,8 @@ import foolscap.logging.log
|
|||||||
from twisted.application import service
|
from twisted.application import service
|
||||||
from allmydata.node import Node, formatTimeTahoeStyle, MissingConfigEntry, read_config, config_from_string, create_node_dir
|
from allmydata.node import Node, formatTimeTahoeStyle, MissingConfigEntry, read_config, config_from_string, create_node_dir
|
||||||
from allmydata.introducer.server import create_introducer
|
from allmydata.introducer.server import create_introducer
|
||||||
from allmydata.client import create_client
|
from allmydata import client
|
||||||
from allmydata.client import _valid_config_sections as client_valid_config_sections
|
|
||||||
from allmydata.util import fileutil, iputil
|
from allmydata.util import fileutil, iputil
|
||||||
from allmydata.util import i2p_provider, tor_provider
|
from allmydata.util import i2p_provider, tor_provider
|
||||||
from allmydata.util.namespace import Namespace
|
from allmydata.util.namespace import Namespace
|
||||||
@ -436,7 +436,7 @@ class Listeners(unittest.TestCase):
|
|||||||
f.write("tub.location = tcp:example.org:1234\n")
|
f.write("tub.location = tcp:example.org:1234\n")
|
||||||
# we're doing a lot of calling-into-setup-methods here, it might be
|
# we're doing a lot of calling-into-setup-methods here, it might be
|
||||||
# better to just create a real Node instance, I'm not sure.
|
# better to just create a real Node instance, I'm not sure.
|
||||||
config = read_config(
|
config = client.read_config(
|
||||||
n.basedir,
|
n.basedir,
|
||||||
"client.port",
|
"client.port",
|
||||||
_valid_config_sections=client_valid_config_sections,
|
_valid_config_sections=client_valid_config_sections,
|
||||||
@ -474,7 +474,7 @@ class ClientNotListening(unittest.TestCase):
|
|||||||
f.write(NOLISTEN)
|
f.write(NOLISTEN)
|
||||||
f.write(DISABLE_STORAGE)
|
f.write(DISABLE_STORAGE)
|
||||||
f.close()
|
f.close()
|
||||||
n = create_client(basedir)
|
n = client.create_client(basedir)
|
||||||
self.assertEqual(n.tub.getListeners(), [])
|
self.assertEqual(n.tub.getListeners(), [])
|
||||||
|
|
||||||
def test_disabled_but_storage(self):
|
def test_disabled_but_storage(self):
|
||||||
@ -485,7 +485,7 @@ class ClientNotListening(unittest.TestCase):
|
|||||||
f.write(NOLISTEN)
|
f.write(NOLISTEN)
|
||||||
f.write(ENABLE_STORAGE)
|
f.write(ENABLE_STORAGE)
|
||||||
f.close()
|
f.close()
|
||||||
e = self.assertRaises(ValueError, create_client, basedir)
|
e = self.assertRaises(ValueError, client.create_client, basedir)
|
||||||
self.assertIn("storage is enabled, but tub is not listening", str(e))
|
self.assertIn("storage is enabled, but tub is not listening", str(e))
|
||||||
|
|
||||||
def test_disabled_but_helper(self):
|
def test_disabled_but_helper(self):
|
||||||
@ -497,7 +497,7 @@ class ClientNotListening(unittest.TestCase):
|
|||||||
f.write(DISABLE_STORAGE)
|
f.write(DISABLE_STORAGE)
|
||||||
f.write(ENABLE_HELPER)
|
f.write(ENABLE_HELPER)
|
||||||
f.close()
|
f.close()
|
||||||
e = self.assertRaises(ValueError, create_client, basedir)
|
e = self.assertRaises(ValueError, client.create_client, basedir)
|
||||||
self.assertIn("helper is enabled, but tub is not listening", str(e))
|
self.assertIn("helper is enabled, but tub is not listening", str(e))
|
||||||
|
|
||||||
class IntroducerNotListening(unittest.TestCase):
|
class IntroducerNotListening(unittest.TestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user