def create(options): precondition(isinstance(options.alias, unicode), alias=options.alias) precondition(isinstance(options.nickname, (unicode, NoneType)), nickname=options.nickname) precondition(isinstance(options.local_dir, (unicode, NoneType)), local_dir=options.local_dir) from allmydata.scripts import tahoe_add_alias create_alias_options = _delegate_options(options, CreateAliasOptions()) create_alias_options.alias = options.alias rc = tahoe_add_alias.create_alias(create_alias_options) if rc != 0: print >>options.stderr, create_alias_options.stderr.getvalue() return rc print >>options.stdout, create_alias_options.stdout.getvalue() if options.nickname is not None: invite_options = _delegate_options(options, InviteOptions()) invite_options.alias = options.alias invite_options.nickname = options.nickname rc = invite(invite_options) if rc != 0: print >>options.stderr, "magic-folder: failed to invite after create\n" print >>options.stderr, invite_options.stderr.getvalue() return rc invite_code = invite_options.stdout.getvalue().strip() join_options = _delegate_options(options, JoinOptions()) join_options.local_dir = options.local_dir join_options.invite_code = invite_code rc = join(join_options) if rc != 0: print >>options.stderr, "magic-folder: failed to join after create\n" print >>options.stderr, join_options.stderr.getvalue() return rc return 0
def create(options): precondition(isinstance(options.alias, unicode), alias=options.alias) precondition(isinstance(options.nickname, (unicode, NoneType)), nickname=options.nickname) precondition(isinstance(options.local_dir, (unicode, NoneType)), local_dir=options.local_dir) # make sure we don't already have a magic-folder with this name before we create the alias maybe_upgrade_magic_folders(options["node-directory"]) folders = load_magic_folders(options["node-directory"]) if options['name'] in folders: print("Already have a magic-folder named '{}'".format(options['name']), file=options.stderr) return 1 # create an alias; this basically just remembers the cap for the # master directory create_alias_options = _delegate_options(options, CreateAliasOptions()) create_alias_options.alias = options.alias rc = tahoe_add_alias.create_alias(create_alias_options) if rc != 0: print(create_alias_options.stderr.getvalue(), file=options.stderr) return rc print(create_alias_options.stdout.getvalue(), file=options.stdout) if options.nickname is not None: print(u"Inviting myself as client '{}':".format(options.nickname), file=options.stdout) invite_options = _delegate_options(options, InviteOptions()) invite_options.alias = options.alias invite_options.nickname = options.nickname invite_options['name'] = options['name'] rc = invite(invite_options) if rc != 0: print(u"magic-folder: failed to invite after create\n", file=options.stderr) print(invite_options.stderr.getvalue(), file=options.stderr) return rc invite_code = invite_options.stdout.getvalue().strip() print(u" created invite code", file=options.stdout) join_options = _delegate_options(options, JoinOptions()) join_options['poll-interval'] = options['poll-interval'] join_options.nickname = options.nickname join_options.local_dir = options.local_dir join_options.invite_code = invite_code rc = join(join_options) if rc != 0: print(u"magic-folder: failed to join after create\n", file=options.stderr) print(join_options.stderr.getvalue(), file=options.stderr) return rc print(u" joined new magic-folder", file=options.stdout) print(u"Successfully created magic-folder '{}' with alias '{}:' " u"and client '{}'\nYou must re-start your node before the " u"magic-folder will be active.".format(options['name'], options.alias, options.nickname), file=options.stdout) return 0
def create(options): precondition(isinstance(options.alias, unicode), alias=options.alias) precondition(isinstance(options.nickname, (unicode, NoneType)), nickname=options.nickname) precondition(isinstance(options.local_dir, (unicode, NoneType)), local_dir=options.local_dir) # make sure we don't already have a magic-folder with this name before we create the alias maybe_upgrade_magic_folders(options["node-directory"]) folders = load_magic_folders(options["node-directory"]) if options['name'] in folders: print("Already have a magic-folder named '{}'".format(options['name']), file=options.stderr) return 1 # create an alias; this basically just remembers the cap for the # master directory from allmydata.scripts import tahoe_add_alias create_alias_options = _delegate_options(options, CreateAliasOptions()) create_alias_options.alias = options.alias rc = tahoe_add_alias.create_alias(create_alias_options) if rc != 0: print(create_alias_options.stderr.getvalue(), file=options.stderr) return rc print(create_alias_options.stdout.getvalue(), file=options.stdout) if options.nickname is not None: print(u"Inviting myself as client '{}':".format(options.nickname), file=options.stdout) invite_options = _delegate_options(options, InviteOptions()) invite_options.alias = options.alias invite_options.nickname = options.nickname invite_options['name'] = options['name'] rc = invite(invite_options) if rc != 0: print(u"magic-folder: failed to invite after create\n", file=options.stderr) print(invite_options.stderr.getvalue(), file=options.stderr) return rc invite_code = invite_options.stdout.getvalue().strip() print(u" created invite code", file=options.stdout) join_options = _delegate_options(options, JoinOptions()) join_options['poll-interval'] = options['poll-interval'] join_options.nickname = options.nickname join_options.local_dir = options.local_dir join_options.invite_code = invite_code rc = join(join_options) if rc != 0: print(u"magic-folder: failed to join after create\n", file=options.stderr) print(join_options.stderr.getvalue(), file=options.stderr) return rc print(u" joined new magic-folder", file=options.stdout) print( u"Successfully created magic-folder '{}' with alias '{}:' " u"and client '{}'\nYou must re-start your node before the " u"magic-folder will be active." .format(options['name'], options.alias, options.nickname), file=options.stdout) return 0
def create_alias(options): from allmydata.scripts import tahoe_add_alias rc = tahoe_add_alias.create_alias(options) return rc