mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-02 03:06:41 +00:00
Add complete usage functionality to create
This commit is contained in:
parent
9deae9b587
commit
1e710187c4
@ -29,6 +29,34 @@ class CreateOptions(BasedirOptions):
|
|||||||
def create(options):
|
def create(options):
|
||||||
from allmydata.scripts import tahoe_add_alias
|
from allmydata.scripts import tahoe_add_alias
|
||||||
rc = tahoe_add_alias.create_alias(options)
|
rc = tahoe_add_alias.create_alias(options)
|
||||||
|
|
||||||
|
if options.nickname is not None:
|
||||||
|
invite_options = InviteOptions()
|
||||||
|
invite_options.aliases = get_aliases(options['node-directory'])
|
||||||
|
invite_options["node-url"] = options["node-url"]
|
||||||
|
invite_options["node-directory"] = options["node-directory"]
|
||||||
|
invite_options.alias = options.alias
|
||||||
|
invite_options.nickname = options.nickname
|
||||||
|
invite_options.stdin = StringIO("")
|
||||||
|
invite_options.stdout = StringIO()
|
||||||
|
invite_options.strerr = StringIO()
|
||||||
|
rc = invite(invite_options)
|
||||||
|
if rc != 0:
|
||||||
|
print >>options.stderr, "magic-folder: failed to invite after create\n"
|
||||||
|
return -1
|
||||||
|
invite_code = invite_options.stdout.getvalue().strip()
|
||||||
|
|
||||||
|
join_options = JoinOptions()
|
||||||
|
join_options.alias = options.alias
|
||||||
|
join_options.aliases = get_aliases(options['node-directory'])
|
||||||
|
join_options["node-url"] = options["node-url"]
|
||||||
|
join_options["node-directory"] = options["node-directory"]
|
||||||
|
join_options.invite_code = invite_code
|
||||||
|
join_options.local_dir = options.localdir
|
||||||
|
rc = join(join_options)
|
||||||
|
if rc != 0:
|
||||||
|
print >>options.stderr, "magic-folder: failed to invite after create\n"
|
||||||
|
return -1
|
||||||
return rc
|
return rc
|
||||||
|
|
||||||
def diminish_readonly(write_cap, node_url):
|
def diminish_readonly(write_cap, node_url):
|
||||||
|
@ -33,10 +33,17 @@ class CreateMagicFolder(GridTestMixin, CLITestMixin, unittest.TestCase):
|
|||||||
d = self.do_cli("magic-folder", "join", invite_code, u"LOCAL_DIR")
|
d = self.do_cli("magic-folder", "join", invite_code, u"LOCAL_DIR")
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def test_create_invite_join(self):
|
def test_create_and_then_invite_join(self):
|
||||||
self.basedir = "cli/MagicFolder/create-invite-join"
|
self.basedir = "cli/MagicFolder/create-and-then-invite-join"
|
||||||
self.set_up_grid()
|
self.set_up_grid()
|
||||||
d = self._create_magic_folder()
|
d = self._create_magic_folder()
|
||||||
d.addCallback(self._invite)
|
d.addCallback(self._invite)
|
||||||
d.addCallback(self._join)
|
d.addCallback(self._join)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def test_create_invite_join(self):
|
||||||
|
self.basedir = "cli/MagicFolder/create-invite-join"
|
||||||
|
self.set_up_grid()
|
||||||
|
magic_local_dir = os.path.join(self.basedir, "magic")
|
||||||
|
d = self.do_cli("magic-folder", "create", u"magic", u"Alice", magic_local_dir)
|
||||||
|
return d
|
||||||
|
Loading…
Reference in New Issue
Block a user