def share_delete(args): user_id = backend.user_get_id(args.login) if not user_id: sys.stderr.write("Error: user `%s' does not exist\n" % args.login) return args.path = share_clean_path(args.path) if not args.path: sys.stderr.write("Error: shared data path must not be empty\n") return share_id = backend.share_id(user_id, args.path) if share_id is not None: if not args.force: sys.stdout.write( "You are about to delete share `%s' for user `%s'. Are you sure? (y/N) " % (args.path, args.login) ) if raw_input().lower().strip() not in ["y", "yes"]: return backend.share_delete(share_id) if backend.share_is_acl_set(share_id): if fs.share_path_exists(base_path, args.path): sys.stdout.write("Unsetting ACL... [Please wait]\n") fs.share_unset(base_path, args.path, user_id) else: sys.stderr.write("Warning: shared data path `%s' data path does not exist\n" % args.path) fs.user_unlink(base_path, args.login, args.path) sys.stdout.write("OK\n") else: sys.stderr.write("Error: share `%s' for user `%s' does not exist\n" % (args.path, args.login))
def user_delete(args): args.login = args.login.lower() user_id = backend.user_get_id(args.login) if user_id: if not args.force: sys.stdout.write("You are about to delete `%s' user account. Are you sure? (y/N) " % args.login) if raw_input().lower().strip() not in ['y', 'yes']: return shares = backend.share_list(user_id) for share in shares: fs.share_unset(base_path, share['share_path'], user_id) backend.user_unset(login=args.login) fs.user_rmdir(base_path, args.login) sys.stdout.write('OK\n') else: sys.stderr.write("Error: user `%s' does not exist\n" % args.LOGIN)