def join(options):
fields = options.invite_code.split(INVITE_SEPERATOR)
assert len(fields) == 2
- magic_readonly_cap, dmd_write_cap = fields
+ magic_readonly_cap, dmd_write_cap = fields
dmd_cap_file = os.path.join(options["node-directory"], "private/magic_folder_dircap")
- fileutil.write(dmd_cap_file, dmd_write_cap)
-
collective_readcap_file = os.path.join(options["node-directory"], "private/collective_dircap")
- fileutil.write(collective_readcap_file, magic_readonly_cap)
-
- c = open(os.path.join(options["node-directory"], "tahoe.cfg"), "a")
- c.write("[magic_folder]\nenabled = True\nlocal.directory = %s\n" % (options.local_dir,))
- c.close()
+ fileutil.write(dmd_cap_file, dmd_write_cap)
+ fileutil.write(collective_readcap_file, magic_readonly_cap)
+ fileutil.write(os.path.join(options["node-directory"], "tahoe.cfg"), "[magic_folder]\nenabled = True\nlocal.directory = %s\n" % (options.local_dir,))
+ return 0
class MagicFolderCommand(BaseOptions):
subCommands = [
def _create_magic_folder(self):
d = self.do_cli("magic-folder", "create", "magic")
def _done((rc,stdout,stderr)):
+ self.failUnless(rc == 0)
self.failUnless("Alias 'magic' created" in stdout)
self.failIf(stderr)
aliases = get_aliases(self.get_clientdir())
def _invite(self, ignore):
d = self.do_cli("magic-folder", "invite", u"magic", u"Alice")
+ def _done((rc,stdout,stderr)):
+ self.failUnless(rc == 0)
+ return (rc,stdout,stderr)
+ d.addCallback(_done)
return d
def _join(self, result):
invite_code = result[1].strip()
d = self.do_cli("magic-folder", "join", invite_code, u"Alice_local_magic")
+ def _done((rc,stdout,stderr)):
+ print "_join rc %s" % (rc,)
+ self.failUnless(rc == 0)
+ return (rc,stdout,stderr)
+ d.addCallback(_done)
return d
def _check_config(self, result):
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)
+ def _done((rc,stdout,stderr)):
+ self.failUnless(rc == 0)
+ return (rc,stdout,stderr)
+ d.addCallback(_done)
return d