From: David Stainton Date: Tue, 23 Jun 2015 09:19:45 +0000 (-0700) Subject: Add complete usage functionality to create X-Git-Url: https://git.rkrishnan.org/%5B/frontends/%22news.html/htmlfontify-example.html?a=commitdiff_plain;h=1e710187c49b8968c7c49b2d8df171a922176079;p=tahoe-lafs%2Ftahoe-lafs.git Add complete usage functionality to create --- diff --git a/src/allmydata/scripts/magic_folder_cli.py b/src/allmydata/scripts/magic_folder_cli.py index 58f13e15..08af3e25 100644 --- a/src/allmydata/scripts/magic_folder_cli.py +++ b/src/allmydata/scripts/magic_folder_cli.py @@ -29,6 +29,34 @@ class CreateOptions(BasedirOptions): def create(options): from allmydata.scripts import tahoe_add_alias 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 def diminish_readonly(write_cap, node_url): diff --git a/src/allmydata/test/test_cli_magic_folder.py b/src/allmydata/test/test_cli_magic_folder.py index c65a93b6..b8418ac7 100644 --- a/src/allmydata/test/test_cli_magic_folder.py +++ b/src/allmydata/test/test_cli_magic_folder.py @@ -33,10 +33,17 @@ class CreateMagicFolder(GridTestMixin, CLITestMixin, unittest.TestCase): d = self.do_cli("magic-folder", "join", invite_code, u"LOCAL_DIR") return d - def test_create_invite_join(self): - self.basedir = "cli/MagicFolder/create-invite-join" + def test_create_and_then_invite_join(self): + self.basedir = "cli/MagicFolder/create-and-then-invite-join" self.set_up_grid() d = self._create_magic_folder() d.addCallback(self._invite) d.addCallback(self._join) 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