def invite(options): precondition(isinstance(options.alias, unicode), alias=options.alias) precondition(isinstance(options.nickname, unicode), nickname=options.nickname) mkdir_options = _delegate_options(options, MakeDirectoryOptions()) mkdir_options.where = None rc = tahoe_mkdir.mkdir(mkdir_options) if rc != 0: print("magic-folder: failed to mkdir\n", file=options.stderr) return rc # FIXME this assumes caps are ASCII. dmd_write_cap = mkdir_options.stdout.getvalue().strip() dmd_readonly_cap = uri.from_string( dmd_write_cap).get_readonly().to_string() if dmd_readonly_cap is None: print("magic-folder: failed to diminish dmd write cap\n", file=options.stderr) return 1 magic_write_cap = get_aliases(options["node-directory"])[options.alias] magic_readonly_cap = uri.from_string( magic_write_cap).get_readonly().to_string() # tahoe ln CLIENT_READCAP COLLECTIVE_WRITECAP/NICKNAME ln_options = _delegate_options(options, LnOptions()) ln_options.from_file = unicode(dmd_readonly_cap, 'utf-8') ln_options.to_file = u"%s/%s" % (unicode(magic_write_cap, 'utf-8'), options.nickname) rc = tahoe_mv.mv(ln_options, mode="link") if rc != 0: print("magic-folder: failed to create link\n", file=options.stderr) print(ln_options.stderr.getvalue(), file=options.stderr) return rc # FIXME: this assumes caps are ASCII. print("%s%s%s" % (magic_readonly_cap, INVITE_SEPARATOR, dmd_write_cap), file=options.stdout) return 0
def ln(options): from allmydata.scripts import tahoe_mv rc = tahoe_mv.mv(options, mode="link") return rc
def mv(options): from allmydata.scripts import tahoe_mv rc = tahoe_mv.mv(options, mode="move") return rc