mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-24 13:05:50 +00:00
Move write_introducer somewhere it can be used more widely
This commit is contained in:
parent
7cf5b04b77
commit
10600ef5ec
@ -4,15 +4,19 @@ import os, sys, urllib, textwrap
|
||||
import codecs
|
||||
from os.path import join
|
||||
|
||||
from yaml import (
|
||||
safe_dump,
|
||||
)
|
||||
|
||||
# Python 2 compatibility
|
||||
from future.utils import PY2
|
||||
if PY2:
|
||||
from future.builtins import str # noqa: F401
|
||||
|
||||
# On Python 2 this will be the backported package:
|
||||
from configparser import NoSectionError
|
||||
|
||||
from twisted.python import usage
|
||||
from twisted.python.filepath import FilePath
|
||||
|
||||
|
||||
|
||||
from allmydata.util.assertutil import precondition
|
||||
from allmydata.util.encodingutil import unicode_to_url, quote_output, \
|
||||
@ -115,6 +119,22 @@ class NoDefaultBasedirOptions(BasedirOptions):
|
||||
DEFAULT_ALIAS = u"tahoe"
|
||||
|
||||
|
||||
def write_introducer(basedir, petname, furl):
|
||||
"""
|
||||
Overwrite the node's ``introducers.yaml`` with a file containing the given
|
||||
introducer information.
|
||||
"""
|
||||
FilePath(basedir).child(b"private").child(b"introducers.yaml").setContent(
|
||||
safe_dump({
|
||||
"introducers": {
|
||||
petname: {
|
||||
"furl": furl.decode("ascii"),
|
||||
},
|
||||
},
|
||||
}).encode("ascii"),
|
||||
)
|
||||
|
||||
|
||||
def get_introducer_furl(nodedir, config):
|
||||
"""
|
||||
:return: the introducer FURL for the given node (no matter if it's
|
||||
|
@ -32,10 +32,6 @@ import attr
|
||||
|
||||
import treq
|
||||
|
||||
from yaml import (
|
||||
safe_dump,
|
||||
)
|
||||
|
||||
from zope.interface import implementer
|
||||
|
||||
from testtools import (
|
||||
@ -85,6 +81,9 @@ from allmydata.client import (
|
||||
config_from_string,
|
||||
create_client_from_config,
|
||||
)
|
||||
from allmydata.scripts.common import (
|
||||
write_introducer,
|
||||
)
|
||||
|
||||
from ..crypto import (
|
||||
ed25519,
|
||||
@ -104,22 +103,6 @@ EMPTY_CLIENT_CONFIG = config_from_string(
|
||||
)
|
||||
|
||||
|
||||
def write_introducer(basedir, petname, furl):
|
||||
"""
|
||||
Overwrite the node's ``introducers.yaml`` with a file containing the given
|
||||
introducer information.
|
||||
"""
|
||||
FilePath(basedir).child(b"private").child(b"introducers.yaml").setContent(
|
||||
safe_dump({
|
||||
"introducers": {
|
||||
petname: {
|
||||
"furl": furl.decode("ascii"),
|
||||
},
|
||||
},
|
||||
}).encode("ascii"),
|
||||
)
|
||||
|
||||
|
||||
@attr.s
|
||||
class MemoryIntroducerClient(object):
|
||||
"""
|
||||
|
@ -58,6 +58,9 @@ from allmydata.util import (
|
||||
from allmydata.util.fileutil import abspath_expanduser_unicode
|
||||
from allmydata.interfaces import IFilesystemNode, IFileNode, \
|
||||
IImmutableFileNode, IMutableFileNode, IDirectoryNode
|
||||
from allmydata.scripts.common import (
|
||||
write_introducer,
|
||||
)
|
||||
from foolscap.api import flushEventualQueue
|
||||
import allmydata.test.common_util as testutil
|
||||
from .common import (
|
||||
@ -66,7 +69,6 @@ from .common import (
|
||||
UseTestPlugins,
|
||||
MemoryIntroducerClient,
|
||||
get_published_announcements,
|
||||
write_introducer,
|
||||
)
|
||||
from .matchers import (
|
||||
MatchesSameElements,
|
||||
|
@ -39,9 +39,11 @@ from allmydata.util import pollmixin, idlib, fileutil, yamlutil
|
||||
from allmydata.util.iputil import (
|
||||
listenOnUnused,
|
||||
)
|
||||
from allmydata.scripts.common import (
|
||||
write_introducer,
|
||||
)
|
||||
import allmydata.test.common_util as testutil
|
||||
from .common import (
|
||||
write_introducer,
|
||||
SyncTestCase,
|
||||
AsyncTestCase,
|
||||
AsyncBrokenTestCase,
|
||||
|
@ -47,7 +47,7 @@ from .web.common import (
|
||||
from allmydata.test.test_runner import RunBinTahoeMixin
|
||||
from . import common_util as testutil
|
||||
from .common_util import run_cli
|
||||
from .common import (
|
||||
from ..scripts.common import (
|
||||
write_introducer,
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user