<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def action_set(self, hostname=None, action=None, subdoms=None, *args):
        "Adds a hostname to the LB, or alters an existing one"
        usage = "set <hostname> <action> <subdoms> [option=value, ...]"
        if hostname is None:
            sys.stderr.write("You must supply a hostname.\n")
            sys.stderr.write("Usage: %s\n" % usage)
            sys.exit(1)
        if action is None:
            sys.stderr.write("You must supply an action.\n")
            sys.stderr.write("Usage: %s\n" % usage)
            sys.exit(1)
        if subdoms is None or subdoms.lower() not in ("true", "false"):
            sys.stderr.write("You must supply True or False for the subdomains flag.\n")
            sys.stderr.write("Usage: %s\n" % usage)
            sys.exit(1)
        # Grab options
        options = {}
        for arg in args:
            if "=" not in arg:
                sys.stderr.write("%s is not a valid option (no =)\n" % (
                    arg
                ))
                sys.exit(1)
            key, value = arg.split("=", 1)
            options[key] = value
        # Sanity-check options
        if action in ("proxy, mirror") and "backends" not in options:
            sys.stderr.write("The %s action requires a backends option.\n" % action)
            sys.exit(1)
        if action == "static" and "type" not in options:
            sys.stderr.write("The %s action requires a type option.\n" % action)
            sys.exit(1)
        if action == "redirect" and "redirect_to" not in options:
            sys.stderr.write("The %s action requires a redirect_to option.\n" % action)
            sys.exit(1)
        if action == "empty" and "code" not in options:
            sys.stderr.write("The %s action requires a code option.\n" % action)
            sys.exit(1)
        # Expand some options from text to datastructure
        if "backends" in options:
            options['backends'] = [
                (lambda x: (x[0], int(x[1])))(bit.split(":", 1))
                for bit in options['backends'].split(",")
            ]
        # Set!
        self.client.set(
            hostname,
            [action, options, subdoms.lower() == "true"]
        )