gurudesh/pytracebugs huggingface dataset:
# Buggy code
def register(self, fileobj, events, data=None):
    key = super(KqueueSelector, self).register(fileobj, events, data)
    if events & EVENT_READ:
        kevent = select.kevent(key.fd, select.KQ_FILTER_READ, select.KQ_EV_ADD)

        _syscall_wrapper(self._kqueue.control, False, [kevent], 0, 0)

    if events & EVENT_WRITE:
        kevent = select.kevent(key.fd, select.KQ_FILTER_WRITE, select.KQ_EV_ADD)

        _syscall_wrapper(self._kqueue.control, False, [kevent], 0, 0)

    return key


# Traceback (TypeError)
The full traceback is:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 138, in run
res = self._execute()
File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 561, in _execute
result = self._handler.run(task_vars=variables)
File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/command.py", line 24, in run
results = merge_hash(results, self._execute_module(task_vars=task_vars, wrap_async=wrap_async))
File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/__init__.py", line 810, in _execute_module
res = self._low_level_execute_command(cmd, sudoable=sudoable, in_data=in_data)
File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/__init__.py", line 917, in _low_level_execute_command
rc, stdout, stderr = self._connection.exec_command(cmd, in_data=in_data, sudoable=sudoable)
File "/usr/lib/python2.7/dist-packages/ansible/plugins/connection/ssh.py", line 984, in exec_command
(returncode, stdout, stderr) = self._run(cmd, in_data, sudoable=sudoable)
File "/usr/lib/python2.7/dist-packages/ansible/plugins/connection/ssh.py", line 258, in wrapped
return_tuple = func(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/ansible/plugins/connection/ssh.py", line 878, in _run
return self._bare_run(cmd, in_data, sudoable=sudoable, checkrc=checkrc)
File "/usr/lib/python2.7/dist-packages/ansible/plugins/connection/ssh.py", line 715, in _bare_run
events = selector.select(timeout)
File "/usr/lib/python2.7/dist-packages/ansible/compat/selectors/_selectors2.py", line 464, in select
maxevents=max_events)
File "/usr/lib/python2.7/dist-packages/ansible/compat/selectors/_selectors2.py", line 139, in _syscall_wrapper
raise OSError(errno=errno.ETIMEDOUT)
TypeError: exceptions.OSError does not take keyword arguments

fatal: [staging.bizlock.net]: FAILED! => {
"msg": "Unexpected failure during module execution.",
"stdout": ""
}

# Fixed code
def register(self, fileobj, events, data=None):
    key = super(KqueueSelector, self).register(fileobj, events, data)
    if events & EVENT_READ:
        kevent = select.kevent(key.fd, select.KQ_FILTER_READ, select.KQ_EV_ADD)

        _syscall_wrapper(self._wrap_control, False, [kevent], 0, 0)

    if events & EVENT_WRITE:
        kevent = select.kevent(key.fd, select.KQ_FILTER_WRITE, select.KQ_EV_ADD)

        _syscall_wrapper(self._wrap_control, False, [kevent], 0, 0)

    return key
# Buggy code
def _exec_jsonrpc(self, name, *args, **kwargs):
    req = request_builder(name, *args, **kwargs)
    reqid = req["id"]

    troubleshoot = "https://docs.ansible.com/ansible/latest/network/user_guide/network_debug_troubleshooting.html#category-socket-path-issue"

    if not os.path.exists(self.socket_path):
        raise ConnectionError(
            "socket_path does not exist or cannot be found. Please check %s"
            % troubleshoot
        )

    try:
        data = json.dumps(req)
        out = self.send(data)
        response = json.loads(out)

    except socket.error as e:
        raise ConnectionError(
            "unable to connect to socket. Please check %s" % troubleshoot,
            err=to_text(e, errors="surrogate_then_replace"),
            exception=traceback.format_exc(),
        )

    if response["id"] != reqid:
        raise ConnectionError("invalid json-rpc id received")

    return response


# Traceback (nansible.module_utils.connection.ConnectionError)
[ios]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/var/folders/8l/27cd4l3n2vnc2cpk3498__680000gn/T/ansible_BoEKEj/ansible_module_ios_command.py\", line 247, in <module>\n    main()\n  File \"/var/folders/8l/27cd4l3n2vnc2cpk3498__680000gn/T/ansible_BoEKEj/ansible_module_ios_command.py\", line 217, in main\n    responses = run_commands(module, commands)\n  File \"/var/folders/8l/27cd4l3n2vnc2cpk3498__680000gn/T/ansible_BoEKEj/ansible_modlib.zip/ansible/module_utils/network/ios/ios.py\", line 125, in run_commands\n  File \"/var/folders/8l/27cd4l3n2vnc2cpk3498__680000gn/T/ansible_BoEKEj/ansible_modlib.zip/ansible/module_utils/connection.py\", line 149, in __rpc__\nansible.module_utils.connection.ConnectionError: command timeout triggered, timeout value is 1 secs\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def _exec_jsonrpc(self, name, *args, **kwargs):
    req = request_builder(name, *args, **kwargs)
    reqid = req["id"]

    if not os.path.exists(self.socket_path):
        raise ConnectionError(
            "socket_path does not exist or cannot be found."
            "\nSee the socket_path issue catergory in Network Debug and Troubleshooting Guide"
        )

    try:
        data = json.dumps(req)
        out = self.send(data)
        response = json.loads(out)

    except socket.error as e:
        raise ConnectionError(
            "unable to connect to socket. See the socket_path issue catergory in Network Debug and Troubleshooting Guide",
            err=to_text(e, errors="surrogate_then_replace"),
            exception=traceback.format_exc(),
        )

    if response["id"] != reqid:
        raise ConnectionError("invalid json-rpc id received")

    return response
# Buggy code
def populate(self):
    data = self.run("show version", output="json")
    if data:
        if data.get("sys_ver_str"):
            self.facts.update(self.transform_dict(data, self.VERSION_MAP_7K))
        else:
            self.facts.update(self.transform_dict(data, self.VERSION_MAP))


# Traceback (TypeError)
TypeError: string indices must be integers
HOST | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 613, in <module>\n    main()\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 596, in main\n    inst.populate()\n  File \"/tmp/a
nsible_2BukBx/ansible_module_nxos_facts.py\", line 259, in populate\n    self.facts['memtotal_mb'] = int(data['memory_usage_total']) / 1024\nTypeError: string indices must be integers\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def populate(self):
    data = None

    try:
        data = self.run("show version", output="json")
    except ConnectionError:
        data = self.run("show version")
    if data:
        if isinstance(data, dict):
            if data.get("sys_ver_str"):
                self.facts.update(self.transform_dict(data, self.VERSION_MAP_7K))
            else:
                self.facts.update(self.transform_dict(data, self.VERSION_MAP))
        else:
            self.facts["version"] = self.parse_version(data)
            self.facts["serialnum"] = self.parse_serialnum(data)
            self.facts["model"] = self.parse_model(data)
            self.facts["image"] = self.parse_image(data)
            self.facts["hostname"] = self.parse_hostname(data)
# Buggy code
def populate(self):
    data = self.run("dir")
    if data:
        self.facts["filesystems"] = self.parse_filesystems(data)

    data = self.run("show system resources", output="json")
    if data:
        self.facts["memtotal_mb"] = int(data["memory_usage_total"]) / 1024
        self.facts["memfree_mb"] = int(data["memory_usage_free"]) / 1024


# Traceback (TypeError)
TypeError: string indices must be integers
HOST | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 613, in <module>\n    main()\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 596, in main\n    inst.populate()\n  File \"/tmp/a
nsible_2BukBx/ansible_module_nxos_facts.py\", line 259, in populate\n    self.facts['memtotal_mb'] = int(data['memory_usage_total']) / 1024\nTypeError: string indices must be integers\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def populate(self):
    data = self.run("dir")
    if data:
        self.facts["filesystems"] = self.parse_filesystems(data)

    data = None
    try:
        data = self.run("show system resources", output="json")
    except ConnectionError:
        data = self.run("show system resources")
    if data:
        if isinstance(data, dict):
            self.facts["memtotal_mb"] = int(data["memory_usage_total"]) / 1024
            self.facts["memfree_mb"] = int(data["memory_usage_free"]) / 1024
        else:
            self.facts["memtotal_mb"] = self.parse_memtotal_mb(data)
            self.facts["memfree_mb"] = self.parse_memfree_mb(data)
# Buggy code
def ipv6_structure_op_supported(self):
    data = self.run("show version", output="json")
    if data:
        unsupported_versions = ["I2", "F1", "A8"]
        for ver in unsupported_versions:
            if ver in data.get("kickstart_ver_str"):
                return False
        return True


# Traceback (TypeError)
TypeError: string indices must be integers
HOST | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 613, in <module>\n    main()\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 596, in main\n    inst.populate()\n  File \"/tmp/a
nsible_2BukBx/ansible_module_nxos_facts.py\", line 259, in populate\n    self.facts['memtotal_mb'] = int(data['memory_usage_total']) / 1024\nTypeError: string indices must be integers\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def ipv6_structure_op_supported(self):
    data = get_capabilities(self.module)
    if data:
        nxos_os_version = data["device_info"]["network_os_version"]
        unsupported_versions = ["I2", "F1", "A8"]
        for ver in unsupported_versions:
            if ver in nxos_os_version:
                return False
        return True
# Buggy code
def populate(self):
    self.facts["all_ipv4_addresses"] = list()
    self.facts["all_ipv6_addresses"] = list()

    data = self.run("show interface", output="json")
    if data:
        self.facts["interfaces"] = self.populate_interfaces(data)

    data = (
        self.run("show ipv6 interface", output="json")
        if self.ipv6_structure_op_supported()
        else None
    )
    if data and not isinstance(data, string_types):
        self.parse_ipv6_interfaces(data)

    data = self.run("show lldp neighbors")
    if data:
        self.facts["neighbors"] = self.populate_neighbors(data)

    data = self.run("show cdp neighbors detail", output="json")
    if data:
        self.facts["neighbors"] = self.populate_neighbors_cdp(data)


# Traceback (TypeError)
TypeError: string indices must be integers
HOST | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 613, in <module>\n    main()\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 596, in main\n    inst.populate()\n  File \"/tmp/a
nsible_2BukBx/ansible_module_nxos_facts.py\", line 259, in populate\n    self.facts['memtotal_mb'] = int(data['memory_usage_total']) / 1024\nTypeError: string indices must be integers\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def populate(self):
    self.facts["all_ipv4_addresses"] = list()
    self.facts["all_ipv6_addresses"] = list()
    data = None

    try:
        data = self.run("show interface", output="json")
    except ConnectionError:
        data = self.run("show interface")
    if data:
        if isinstance(data, dict):
            self.facts["interfaces"] = self.populate_structured_interfaces(data)
        else:
            interfaces = self.parse_interfaces(data)
            self.facts["interfaces"] = self.populate_interfaces(interfaces)

    if self.ipv6_structure_op_supported():
        try:
            data = self.run("show ipv6 interface", output="json")
        except ConnectionError:
            data = self.run("show ipv6 interface")
    else:
        data = None
    if data:
        if isinstance(data, dict):
            self.populate_structured_ipv6_interfaces(data)
        else:
            interfaces = self.parse_interfaces(data)
            self.populate_ipv6_interfaces(interfaces)

    data = self.run("show lldp neighbors")
    if data:
        self.facts["neighbors"] = self.populate_neighbors(data)

    try:
        data = self.run("show cdp neighbors detail", output="json")
    except ConnectionError:
        data = self.run("show cdp neighbors detail")
    if data:
        if isinstance(data, dict):
            self.facts["neighbors"] = self.populate_structured_neighbors_cdp(data)
        else:
            self.facts["neighbors"] = self.populate_neighbors_cdp(data)
# Buggy code
def populate_interfaces(self, data):
    interfaces = dict()
    for item in data["TABLE_interface"]["ROW_interface"]:
        name = item["interface"]

        intf = dict()
        if "type" in item:
            intf.update(self.transform_dict(item, self.INTERFACE_SVI_MAP))
        else:
            intf.update(self.transform_dict(item, self.INTERFACE_MAP))

        if "eth_ip_addr" in item:
            intf["ipv4"] = self.transform_dict(item, self.INTERFACE_IPV4_MAP)
            self.facts["all_ipv4_addresses"].append(item["eth_ip_addr"])

        if "svi_ip_addr" in item:
            intf["ipv4"] = self.transform_dict(item, self.INTERFACE_SVI_IPV4_MAP)
            self.facts["all_ipv4_addresses"].append(item["svi_ip_addr"])

        interfaces[name] = intf

    return interfaces


# Traceback (TypeError)
TypeError: string indices must be integers
HOST | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 613, in <module>\n    main()\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 596, in main\n    inst.populate()\n  File \"/tmp/a
nsible_2BukBx/ansible_module_nxos_facts.py\", line 259, in populate\n    self.facts['memtotal_mb'] = int(data['memory_usage_total']) / 1024\nTypeError: string indices must be integers\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def populate_interfaces(self, interfaces):
    facts = dict()
    for key, value in iteritems(interfaces):
        intf = dict()
        if get_interface_type(key) == "svi":
            intf["state"] = self.parse_state(key, value, intf_type="svi")
            intf["macaddress"] = self.parse_macaddress(value, intf_type="svi")
            intf["mtu"] = self.parse_mtu(value, intf_type="svi")
            intf["bandwidth"] = self.parse_bandwidth(value, intf_type="svi")
            intf["type"] = self.parse_type(value, intf_type="svi")
            if "Internet Address" in value:
                intf["ipv4"] = self.parse_ipv4_address(value, intf_type="svi")
            facts[key] = intf
        else:
            intf["state"] = self.parse_state(key, value)
            intf["description"] = self.parse_description(value)
            intf["macaddress"] = self.parse_macaddress(value)
            intf["mode"] = self.parse_mode(value)
            intf["mtu"] = self.parse_mtu(value)
            intf["bandwidth"] = self.parse_bandwidth(value)
            intf["duplex"] = self.parse_duplex(value)
            intf["speed"] = self.parse_speed(value)
            intf["type"] = self.parse_type(value)
            if "Internet Address" in value:
                intf["ipv4"] = self.parse_ipv4_address(value)
            facts[key] = intf

    return facts
# Buggy code
def populate_neighbors_cdp(self, data):
    objects = dict()
    data = data["TABLE_cdp_neighbor_detail_info"]["ROW_cdp_neighbor_detail_info"]

    if isinstance(data, dict):
        data = [data]

    for item in data:
        local_intf = item["intf_id"]
        objects[local_intf] = list()
        nbor = dict()
        nbor["port"] = item["port_id"]
        nbor["sysname"] = item["device_id"]
        objects[local_intf].append(nbor)

    return objects


# Traceback (TypeError)
TypeError: string indices must be integers
HOST | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 613, in <module>\n    main()\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 596, in main\n    inst.populate()\n  File \"/tmp/a
nsible_2BukBx/ansible_module_nxos_facts.py\", line 259, in populate\n    self.facts['memtotal_mb'] = int(data['memory_usage_total']) / 1024\nTypeError: string indices must be integers\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def populate_neighbors_cdp(self, data):
    facts = dict()

    for item in data.split("----------------------------------------"):
        if item == "":
            continue
        local_intf = self.parse_lldp_intf(item)
        if local_intf not in facts:
            facts[local_intf] = list()

        fact = dict()
        fact["port"] = self.parse_lldp_port(item)
        fact["sysname"] = self.parse_lldp_sysname(item)
        facts[local_intf].append(facts)

    return facts
# Buggy code
def parse_interfaces(self, data):
    objects = list()
    for item in data["TABLE_interface"]["ROW_interface"]:
        objects.append(item["interface"])
    return objects


# Traceback (TypeError)
TypeError: string indices must be integers
HOST | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 613, in <module>\n    main()\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 596, in main\n    inst.populate()\n  File \"/tmp/a
nsible_2BukBx/ansible_module_nxos_facts.py\", line 259, in populate\n    self.facts['memtotal_mb'] = int(data['memory_usage_total']) / 1024\nTypeError: string indices must be integers\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def parse_interfaces(self, data):
    objects = list()
    for line in data.split("\n"):
        if len(line) == 0:
            continue
        elif line.startswith("admin") or line[0] == " ":
            continue
        else:
            match = re.match(r"^(\S+)", line)
            if match:
                intf = match.group(1)
                if get_interface_type(intf) != "unknown":
                    objects.append(intf)
    return objects
# Buggy code
def parse_vlans(self, data):
    objects = list()
    data = data["TABLE_vlanbriefxbrief"]["ROW_vlanbriefxbrief"]
    if isinstance(data, dict):
        objects.append(data["vlanshowbr-vlanid-utf"])
    elif isinstance(data, list):
        for item in data:
            objects.append(item["vlanshowbr-vlanid-utf"])
    return objects


# Traceback (TypeError)
TypeError: string indices must be integers
HOST | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 613, in <module>\n    main()\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 596, in main\n    inst.populate()\n  File \"/tmp/a
nsible_2BukBx/ansible_module_nxos_facts.py\", line 259, in populate\n    self.facts['memtotal_mb'] = int(data['memory_usage_total']) / 1024\nTypeError: string indices must be integers\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def parse_vlans(self, data):
    objects = list()
    for line in data.splitlines():
        if line == "":
            continue
        if line[0].isdigit():
            vlan = line.split()[0]
            objects.append(vlan)
    return objects
# Buggy code
def parse_module(self, data):
    data = data["TABLE_modinfo"]["ROW_modinfo"]
    if isinstance(data, dict):
        data = [data]
    objects = list(self.transform_iterable(data, self.MODULE_MAP))
    return objects


# Traceback (TypeError)
TypeError: string indices must be integers
HOST | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 613, in <module>\n    main()\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 596, in main\n    inst.populate()\n  File \"/tmp/a
nsible_2BukBx/ansible_module_nxos_facts.py\", line 259, in populate\n    self.facts['memtotal_mb'] = int(data['memory_usage_total']) / 1024\nTypeError: string indices must be integers\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def parse_module(self, data):
    objects = list()
    for line in data.splitlines():
        if line == "":
            break
        if line[0].isdigit():
            obj = {}
            match_port = re.search(r"\d\s*(\d*)", line, re.M)
            if match_port:
                obj["ports"] = match_port.group(1)

            match = re.search(r"\d\s*\d*\s*(.+)$", line, re.M)
            if match:
                l = match.group(1).split("  ")
                items = list()
                for item in l:
                    if item == "":
                        continue
                    items.append(item.strip())

                if items:
                    obj["type"] = items[0]
                    obj["model"] = items[1]
                    obj["status"] = items[2]

            objects.append(obj)
    return objects
# Buggy code
def parse_fan_info(self, data):
    objects = list()
    if data.get("fandetails"):
        data = data["fandetails"]["TABLE_faninfo"]["ROW_faninfo"]
    elif data.get("fandetails_3k"):
        data = data["fandetails_3k"]["TABLE_faninfo"]["ROW_faninfo"]
    else:
        return objects
    objects = list(self.transform_iterable(data, self.FAN_MAP))
    return objects


# Traceback (TypeError)
TypeError: string indices must be integers
HOST | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 613, in <module>\n    main()\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 596, in main\n    inst.populate()\n  File \"/tmp/a
nsible_2BukBx/ansible_module_nxos_facts.py\", line 259, in populate\n    self.facts['memtotal_mb'] = int(data['memory_usage_total']) / 1024\nTypeError: string indices must be integers\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def parse_fan_info(self, data):
    objects = list()

    for l in data.splitlines():
        if "-----------------" in l or "Status" in l:
            continue
        line = l.split()
        if len(line) > 1:
            obj = {}
            obj["name"] = line[0]
            obj["model"] = line[1]
            obj["hw_ver"] = line[-2]
            obj["status"] = line[-1]
            objects.append(obj)
    return objects
# Buggy code
def parse_power_supply_info(self, data):
    if data.get("powersup").get("TABLE_psinfo_n3k"):
        data = data["powersup"]["TABLE_psinfo_n3k"]["ROW_psinfo_n3k"]
    else:
        data = data["powersup"]["TABLE_psinfo"]["ROW_psinfo"]
    objects = list(self.transform_iterable(data, self.POWERSUP_MAP))
    return objects


# Traceback (TypeError)
TypeError: string indices must be integers
HOST | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 613, in <module>\n    main()\n  File \"/tmp/ansible_2BukBx/ansible_module_nxos_facts.py\", line 596, in main\n    inst.populate()\n  File \"/tmp/a
nsible_2BukBx/ansible_module_nxos_facts.py\", line 259, in populate\n    self.facts['memtotal_mb'] = int(data['memory_usage_total']) / 1024\nTypeError: string indices must be integers\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def parse_power_supply_info(self, data):
    objects = list()

    for l in data.splitlines():
        if l == "":
            break
        if l[0].isdigit():
            obj = {}
            line = l.split()
            obj["model"] = line[1]
            obj["number"] = line[0]
            obj["status"] = line[-1]

            objects.append(obj)
    return objects
# Buggy code
def load_config(module, commands):
    rc, out, err = exec_command(module, "configure terminal")
    if rc != 0:
        module.fail_json(
            msg="unable to enter configuration mode",
            err=to_text(err, errors="surrogate_or_strict"),
        )

    for command in to_list(commands):
        if command == "end":
            continue
        rc, out, err = exec_command(module, command)
        if rc != 0:
            module.fail_json(
                msg=to_text(err, errors="surrogate_or_strict"), command=command, rc=rc
            )
    exec_command(module, "end")


# Traceback (nAttributeError)
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_rez_T3/ansible_module_dellos9_config.py\", line 327, in <module>\n    main()\n  File \"/tmp/ansible_rez_T3/ansible_module_dellos9_config.py\", line 290, in main\n    ['prompt', 'answer'].issubset(module.params['lines'][0])):\nAttributeError: 'list' object has no attribute 'issubset'\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1

# Fixed code
def load_config(module, commands):
    rc, out, err = exec_command(module, "configure terminal")
    if rc != 0:
        module.fail_json(
            msg="unable to enter configuration mode",
            err=to_text(err, errors="surrogate_or_strict"),
        )

    for command in to_list(commands):
        if command == "end":
            continue
        #        cmd = {'command': command, 'prompt': WARNING_PROMPTS_RE, 'answer': 'yes'}
        rc, out, err = exec_command(module, command)
        if rc != 0:
            module.fail_json(
                msg=to_text(err, errors="surrogate_or_strict"), command=command, rc=rc
            )
    exec_command(module, "end")
# Buggy code
def is_fakes3(s3_url):
    """Return True if s3_url has scheme fakes3://"""
    if s3_url is not None:
        return urlparse.urlparse(s3_url).scheme in ("fakes3", "fakes3s")
    else:
        return False


# Traceback (TypeError)
Traceback (most recent call last):
File "/tmp/ansible_546eises/ansible_module_s3_bucket.py", line 558, in <module> main()
File "/tmp/ansible_546eises/ansible_module_s3_bucket.py", line 544, in main
s3_client = get_s3_client(module, aws_connect_kwargs, location, ceph, s3_url)
File "/tmp/ansible_546eises/ansible_module_s3_bucket.py", line 476, in get_s3_client
ceph = urlparse(s3_url)
TypeError: 'Module_six_moves_urllib_parse' object is not callable

# Fixed code
def is_fakes3(s3_url):
    """Return True if s3_url has scheme fakes3://"""
    if s3_url is not None:
        return urlparse(s3_url).scheme in ("fakes3", "fakes3s")
    else:
        return False
# Buggy code
def is_walrus(s3_url):
    """Return True if it's Walrus endpoint, not S3

    We assume anything other than *.amazonaws.com is Walrus"""
    if s3_url is not None:
        o = urlparse.urlparse(s3_url)
        return not o.hostname.endswith("amazonaws.com")
    else:
        return False


# Traceback (TypeError)
Traceback (most recent call last):
File "/tmp/ansible_546eises/ansible_module_s3_bucket.py", line 558, in <module> main()
File "/tmp/ansible_546eises/ansible_module_s3_bucket.py", line 544, in main
s3_client = get_s3_client(module, aws_connect_kwargs, location, ceph, s3_url)
File "/tmp/ansible_546eises/ansible_module_s3_bucket.py", line 476, in get_s3_client
ceph = urlparse(s3_url)
TypeError: 'Module_six_moves_urllib_parse' object is not callable

# Fixed code
def is_walrus(s3_url):
    """Return True if it's Walrus endpoint, not S3

    We assume anything other than *.amazonaws.com is Walrus"""
    if s3_url is not None:
        o = urlparse(s3_url)
        return not o.hostname.endswith("amazonaws.com")
    else:
        return False
# Buggy code
def get_state(path):
    """Find out current state"""

    b_path = to_bytes(path, errors="surrogate_or_strict")
    if os.path.lexists(b_path):
        if os.path.islink(b_path):
            return "link"
        elif os.path.isdir(b_path):
            return "directory"
        elif os.stat(b_path).st_nlink > 1:
            return "hard"

        # could be many other things, but defaulting to file
        return "file"

    return "absent"


# Traceback (OSError)
Traceback (most recent call last):
File "/tmp/ansible_hWZCOr/ansible_module_file.py", line 739, in <module>
main()
File "/tmp/ansible_hWZCOr/ansible_module_file.py", line 707, in main
additional_parameter_handling(module.params)
File "/tmp/ansible_hWZCOr/ansible_module_file.py", line 185, in additional_parameter_handling
prev_state = get_state(to_bytes(params['path'], errors='surrogate_or_strict'))
File "/tmp/ansible_hWZCOr/ansible_module_file.py", line 220, in get_state
elif os.stat(b_path).st_nlink > 1:
OSError: [Errno 2] No such file or directory: '/home/ccla/.ssh/known_hosts'

# Fixed code
def get_state(path):
    """Find out current state"""

    b_path = to_bytes(path, errors="surrogate_or_strict")
    try:
        if os.path.lexists(b_path):
            if os.path.islink(b_path):
                return "link"
            elif os.path.isdir(b_path):
                return "directory"
            elif os.stat(b_path).st_nlink > 1:
                return "hard"

            # could be many other things, but defaulting to file
            return "file"

        return "absent"
    except OSError as e:
        if e.errno == errno.ENOENT:  # It may already have been removed
            return "absent"
        else:
            raise
# Buggy code
def get_switchport(name, module):
    config = run_commands(module, ["show interface {0} switchport".format(name)])[0]
    mode = re.search(r"Administrative Mode: (?:.* )?(\w+)$", config, re.M).group(1)
    access = re.search(r"Access Mode VLAN: (\d+)", config).group(1)
    native = re.search(r"Trunking Native Mode VLAN: (\d+)", config).group(1)
    trunk = re.search(r"Trunking VLANs Enabled: (.+)$", config, re.M).group(1)
    if trunk == "ALL":
        trunk = "1-4094"

    switchport_config = {
        "interface": name,
        "mode": mode,
        "access_vlan": access,
        "native_vlan": native,
        "trunk_vlans": trunk,
    }

    return switchport_config


# Traceback (AttributeError)
TASK [Set Switchport Trunk Mode] ***********************************************
task path: /repository/ansible/playbooks/includes/tasks/interface_physical/trunk_tagged.yml:3
Using module file /opt/stackstorm/virtualenvs/ansible/lib/python2.7/site-packages/ansible/modules/network/ios/ios_l2_interface.py
<5L27-02-241> ESTABLISH LOCAL CONNECTION FOR USER: root
<5L27-02-241> EXEC /bin/sh -c '/usr/bin/python &amp;&amp; sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ZJlJQr/ansible_module_ios_l2_interface.py", line 490, in <module>
main()
File "/tmp/ansible_ZJlJQr/ansible_module_ios_l2_interface.py", line 428, in main
existing = get_switchport(name, module)
File "/tmp/ansible_ZJlJQr/ansible_module_ios_l2_interface.py", line 158, in get_switchport
access = re.search(r'Access Mode VLAN: (\d+)', config).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
fatal: [5L27-02-241]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_ZJlJQr/ansible_module_ios_l2_interface.py\", line 490, in <module>\n    main()\n  File \"/tmp/ansible_ZJlJQr/ansible_module_ios_l2_interface.py\", line 428, in main\n    existing = get_switchport(name, module)\n  File \"/tmp/ansible_ZJlJQr/ansible_module_ios_l2_interface.py\", line 158, in get_switchport\n    access = re.search(r'Access Mode VLAN: (\\d+)', config).group(1)\nAttributeError: 'NoneType' object has no attribute 'group'\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def get_switchport(name, module):
    config = run_commands(module, ["show interface {0} switchport".format(name)])[0]
    mode = re.search(r"Administrative Mode: (?:.* )?(\w+)$", config, re.M)
    access = re.search(r"Access Mode VLAN: (\d+)", config)
    native = re.search(r"Trunking Native Mode VLAN: (\d+)", config)
    trunk = re.search(r"Trunking VLANs Enabled: (.+)$", config, re.M)
    if mode:
        mode = mode.group(1)
    if access:
        access = access.group(1)
    if native:
        native = native.group(1)
    if trunk:
        trunk = trunk.group(1)
    if trunk == "ALL":
        trunk = "1-4094"

    switchport_config = {
        "interface": name,
        "mode": mode,
        "access_vlan": access,
        "native_vlan": native,
        "trunk_vlans": trunk,
    }

    return switchport_config
# Buggy code
def run_commands(self, commands, check_rc=True):
    """Run list of commands on remote device and return results"""
    responses = list()
    connection = self._get_connection()

    for cmd in to_list(commands):
        if isinstance(cmd, dict):
            command = cmd["command"]
            prompt = cmd["prompt"]
            answer = cmd["answer"]
        else:
            command = cmd
            prompt = None
            answer = None

        out = connection.get(command, prompt, answer)
        out = to_text(out, errors="surrogate_or_strict")

        try:
            out = self._module.from_json(out)
        except ValueError:
            out = str(out).strip()

        responses.append(out)

    return responses


# Traceback (TypeError)
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_hh4_Fh/ansible_module_eos_facts.py", line 384, in <module>
main()
File "/tmp/ansible_hh4_Fh/ansible_module_eos_facts.py", line 372, in main
inst.populate()
File "/tmp/ansible_hh4_Fh/ansible_module_eos_facts.py", line 203, in populate
self.facts.update(self.populate_memory())
File "/tmp/ansible_hh4_Fh/ansible_module_eos_facts.py", line 217, in populate_memory
memfree_mb=int(values['memFree']) / 1024,
TypeError: string indices must be integers, not str

# Fixed code
def run_commands(self, commands, check_rc=True):
    """Run list of commands on remote device and return results"""
    responses = list()
    connection = self._get_connection()

    for cmd in to_list(commands):
        if isinstance(cmd, dict):
            command = cmd["command"]
            prompt = cmd["prompt"]
            answer = cmd["answer"]
        else:
            command = cmd
            prompt = None
            answer = None

        try:
            out = connection.get(command, prompt, answer)
        except ConnectionError as exc:
            if check_rc:
                raise
            out = getattr(exc, "err", exc)
        out = to_text(out, errors="surrogate_or_strict")

        try:
            out = self._module.from_json(out)
        except ValueError:
            out = str(out).strip()

        responses.append(out)

    return responses
# Buggy code
def run_commands(self, commands):
    """Runs list of commands on remote device and returns results"""
    output = None
    queue = list()
    responses = list()

    def _send(commands, output):
        response = self.send_request(commands, output=output)
        if "error" in response:
            err = response["error"]
            self._module.fail_json(msg=err["message"], code=err["code"])
        return response["result"]

    for item in to_list(commands):
        if is_json(item["command"]):
            item["command"] = str(item["command"]).replace("| json", "")
            item["output"] = "json"

        if output and output != item["output"]:
            responses.extend(_send(queue, output))
            queue = list()

        output = item["output"] or "json"
        queue.append(item["command"])

    if queue:
        responses.extend(_send(queue, output))

    for index, item in enumerate(commands):
        try:
            responses[index] = responses[index]["output"].strip()
        except KeyError:
            pass

    return responses


# Traceback (TypeError)
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_hh4_Fh/ansible_module_eos_facts.py", line 384, in <module>
main()
File "/tmp/ansible_hh4_Fh/ansible_module_eos_facts.py", line 372, in main
inst.populate()
File "/tmp/ansible_hh4_Fh/ansible_module_eos_facts.py", line 203, in populate
self.facts.update(self.populate_memory())
File "/tmp/ansible_hh4_Fh/ansible_module_eos_facts.py", line 217, in populate_memory
memfree_mb=int(values['memFree']) / 1024,
TypeError: string indices must be integers, not str

# Fixed code
def run_commands(self, commands, check_rc=True):
    """Runs list of commands on remote device and returns results"""
    output = None
    queue = list()
    responses = list()

    def _send(commands, output):
        response = self.send_request(commands, output=output)
        if "error" in response:
            err = response["error"]
            self._module.fail_json(msg=err["message"], code=err["code"])
        return response["result"]

    for item in to_list(commands):
        if is_json(item["command"]):
            item["command"] = str(item["command"]).replace("| json", "")
            item["output"] = "json"

        if output and output != item["output"]:
            responses.extend(_send(queue, output))
            queue = list()

        output = item["output"] or "json"
        queue.append(item["command"])

    if queue:
        responses.extend(_send(queue, output))

    for index, item in enumerate(commands):
        try:
            responses[index] = responses[index]["output"].strip()
        except KeyError:
            pass

    return responses
# Buggy code
def populate(self):
    self.responses = run_commands(self.module, list(self.COMMANDS))


# Traceback (TypeError)
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_hh4_Fh/ansible_module_eos_facts.py", line 384, in <module>
main()
File "/tmp/ansible_hh4_Fh/ansible_module_eos_facts.py", line 372, in main
inst.populate()
File "/tmp/ansible_hh4_Fh/ansible_module_eos_facts.py", line 203, in populate
self.facts.update(self.populate_memory())
File "/tmp/ansible_hh4_Fh/ansible_module_eos_facts.py", line 217, in populate_memory
memfree_mb=int(values['memFree']) / 1024,
TypeError: string indices must be integers, not str

# Fixed code
def populate(self):
    self.responses = run_commands(self.module, list(self.COMMANDS), check_rc=False)
# Buggy code
def populate(self):
    super(Interfaces, self).populate()

    self.facts["all_ipv4_addresses"] = list()
    self.facts["all_ipv6_addresses"] = list()

    data = self.responses[0]
    self.facts["interfaces"] = self.populate_interfaces(data)

    data = self.responses[1]
    self.facts["neighbors"] = self.populate_neighbors(data["lldpNeighbors"])


# Traceback (TypeError)
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_hh4_Fh/ansible_module_eos_facts.py", line 384, in <module>
main()
File "/tmp/ansible_hh4_Fh/ansible_module_eos_facts.py", line 372, in main
inst.populate()
File "/tmp/ansible_hh4_Fh/ansible_module_eos_facts.py", line 203, in populate
self.facts.update(self.populate_memory())
File "/tmp/ansible_hh4_Fh/ansible_module_eos_facts.py", line 217, in populate_memory
memfree_mb=int(values['memFree']) / 1024,
TypeError: string indices must be integers, not str

# Fixed code
def populate(self):
    super(Interfaces, self).populate()

    self.facts["all_ipv4_addresses"] = list()
    self.facts["all_ipv6_addresses"] = list()

    data = self.responses[0]
    self.facts["interfaces"] = self.populate_interfaces(data)

    data = self.responses[1]
    if data:
        self.facts["neighbors"] = self.populate_neighbors(data["lldpNeighbors"])
# Buggy code
def _validate_valid_at():
    if self.valid_at:
        if not (
            self.valid_at >= self.cert.get_notBefore()
            and self.valid_at <= self.cert.get_notAfter()
        ):
            self.message.append(
                "Certificate is not valid for the specified date (%s) - notBefore: %s - notAfter: %s"
                % (self.valid_at, self.cert.get_notBefore(), self.cert.get_notAfter())
            )


# Traceback (TypeError)
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py", line 901, in <module>
main()
File "/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py", line 880, in main
certificate.generate(module)
File "/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py", line 703, in generate
self.assertonly()
File "/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py", line 698, in assertonly
f_name()
File "/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py", line 684, in _validate_valid_in
if not (valid_in_date >= self.cert.get_notBefore() and valid_in_date <= self.cert.get_notAfter()):
TypeError: unorderable types: str() >= bytes()

localhost | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py\", line 901, in <module>\n    main()\n  File \"/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py\", line 880, in main\n    certificate.generate(module)\n  File \"/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py\", line 703, in generate\n    self.assertonly()\n  File \"/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py\", line 698, in assertonly\n    f_name()\n  File \"/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py\", line 684, in _validate_valid_in\n    if not (valid_in_date >= self.cert.get_notBefore() and valid_in_date <= self.cert.get_notAfter()):\nTypeError: unorderable types: str() >= bytes()\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def _validate_valid_at():
    if self.valid_at:
        if not (self.cert.get_notBefore() <= self.valid_at <= self.cert.get_notAfter()):
            self.message.append(
                "Certificate is not valid for the specified date (%s) - notBefore: %s - notAfter: %s"
                % (self.valid_at, self.cert.get_notBefore(), self.cert.get_notAfter())
            )
# Buggy code
def _validate_valid_in():
    if self.valid_in:
        valid_in_date = datetime.datetime.utcnow() + datetime.timedelta(
            seconds=self.valid_in
        )
        valid_in_date = valid_in_date.strftime("%Y%m%d%H%M%SZ")
        if not (
            valid_in_date >= self.cert.get_notBefore()
            and valid_in_date <= self.cert.get_notAfter()
        ):
            self.message.append(
                "Certificate is not valid in %s seconds from now (%s) - notBefore: %s - notAfter: %s"
                % (
                    self.valid_in,
                    valid_in_date,
                    self.cert.get_notBefore(),
                    self.cert.get_notAfter(),
                )
            )


# Traceback (TypeError)
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py", line 901, in <module>
main()
File "/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py", line 880, in main
certificate.generate(module)
File "/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py", line 703, in generate
self.assertonly()
File "/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py", line 698, in assertonly
f_name()
File "/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py", line 684, in _validate_valid_in
if not (valid_in_date >= self.cert.get_notBefore() and valid_in_date <= self.cert.get_notAfter()):
TypeError: unorderable types: str() >= bytes()

localhost | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py\", line 901, in <module>\n    main()\n  File \"/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py\", line 880, in main\n    certificate.generate(module)\n  File \"/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py\", line 703, in generate\n    self.assertonly()\n  File \"/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py\", line 698, in assertonly\n    f_name()\n  File \"/tmp/ansible_4f9cmasi/ansible_module_openssl_certificate.py\", line 684, in _validate_valid_in\n    if not (valid_in_date >= self.cert.get_notBefore() and valid_in_date <= self.cert.get_notAfter()):\nTypeError: unorderable types: str() >= bytes()\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

# Fixed code
def _validate_valid_in():
    if self.valid_in:
        valid_in_date = datetime.datetime.utcnow() + datetime.timedelta(
            seconds=self.valid_in
        )
        valid_in_date = to_bytes(
            valid_in_date.strftime("%Y%m%d%H%M%SZ"), errors="surrogate_or_strict"
        )
        if not (self.cert.get_notBefore() <= valid_in_date <= self.cert.get_notAfter()):
            self.message.append(
                "Certificate is not valid in %s seconds from now (%s) - notBefore: %s - notAfter: %s"
                % (
                    self.valid_in,
                    valid_in_date,
                    self.cert.get_notBefore(),
                    self.cert.get_notAfter(),
                )
            )
# Buggy code
def parse_stacks(self, data):
    match = re.findall(r"^Model number\s+: (\S+)", data, re.M)
    if match:
        self.facts["stacked_models"] = match

    match = re.findall(r"^System serial number\s+: (\S+)", data, re.M)
    if match:
        self.facts["stacked_serialnums"] = match


# Traceback (nIndexError)
FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/var/folders/dq/_tjy3jfn0j98n6j590nyr24jpxb_7r/T/ansible_ad9N9O/ansible_module_ios_facts.py\", line 518, in <module>\n    main()\n  File \"/var/folders/dq/_tjy3jfn0j98n6j590nyr24jpxb_7r/T/ansible_ad9N9O/ansible_module_ios_facts.py\", line 503, in main\n    inst.populate()\n  File \"/var/folders/dq/_tjy3jfn0j98n6j590nyr24jpxb_7r/T/ansible_ad9N9O/ansible_module_ios_facts.py\", line 232, in populate\n    if 'Processor' in l].pop()\nIndexError: pop from empty list\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1}

# Fixed code
def parse_stacks(self, data):
    match = re.findall(r"^Model [Nn]umber\s+: (\S+)", data, re.M)
    if match:
        self.facts["stacked_models"] = match

    match = re.findall(r"^System [Ss]erial [Nn]umber\s+: (\S+)", data, re.M)
    if match:
        self.facts["stacked_serialnums"] = match
# Buggy code
def populate(self):
    super(Hardware, self).populate()
    data = self.responses[0]
    if data:
        self.facts["filesystems"] = self.parse_filesystems(data)

    data = self.responses[1]
    if data:
        processor_line = [l for l in data.splitlines() if "Processor" in l].pop()
        match = re.findall(r"\s(\d+)\s", processor_line)
        if match:
            self.facts["memtotal_mb"] = int(match[0]) / 1024
            self.facts["memfree_mb"] = int(match[3]) / 1024


# Traceback (nIndexError)
FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/var/folders/dq/_tjy3jfn0j98n6j590nyr24jpxb_7r/T/ansible_ad9N9O/ansible_module_ios_facts.py\", line 518, in <module>\n    main()\n  File \"/var/folders/dq/_tjy3jfn0j98n6j590nyr24jpxb_7r/T/ansible_ad9N9O/ansible_module_ios_facts.py\", line 503, in main\n    inst.populate()\n  File \"/var/folders/dq/_tjy3jfn0j98n6j590nyr24jpxb_7r/T/ansible_ad9N9O/ansible_module_ios_facts.py\", line 232, in populate\n    if 'Processor' in l].pop()\nIndexError: pop from empty list\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1}

# Fixed code
def populate(self):
    super(Hardware, self).populate()
    data = self.responses[0]
    if data:
        self.facts["filesystems"] = self.parse_filesystems(data)

    data = self.responses[1]
    if data:
        if "Invalid input detected" in data:
            warnings.append("Unable to gather memory statistics")
        else:
            processor_line = [l for l in data.splitlines() if "Processor" in l].pop()
            match = re.findall(r"\s(\d+)\s", processor_line)
            if match:
                self.facts["memtotal_mb"] = int(match[0]) / 1024
                self.facts["memfree_mb"] = int(match[3]) / 1024