Code Duplication    Length = 24-24 lines in 2 locations

gvm/protocols/gmpv7/gmpv7.py 1 location

@@ 52-75 (lines=24) @@
49
Severity = numbers.Real
50
51
52
def _check_command_status(xml: str) -> bool:
53
    """Check gmp response
54
55
    Look into the gmp response and check for the status in the root element
56
57
    Arguments:
58
        xml: XML-Source
59
60
    Returns:
61
        True if valid, otherwise False
62
    """
63
64
    if xml == 0 or xml is None:
65
        logger.error("XML Command is empty")
66
        return False
67
68
    try:
69
        root = etree.XML(xml, parser=create_parser())
70
        status = root.attrib["status"]
71
        return status is not None and status[0] == "2"
72
73
    except etree.Error as e:
74
        logger.error("etree.XML(xml): %s", e)
75
        return False
76
77
78
def _to_bool(value: bool) -> str:

gvm/protocols/gmpv208/gmpv208.py 1 location

@@ 57-80 (lines=24) @@
54
Severity = numbers.Real
55
56
57
def _check_command_status(xml: str) -> bool:
58
    """Check gmp response
59
60
    Look into the gmp response and check for the status in the root element
61
62
    Arguments:
63
        xml: XML-Source
64
65
    Returns:
66
        True if valid, otherwise False
67
    """
68
69
    if xml == 0 or xml is None:
70
        logger.error("XML Command is empty")
71
        return False
72
73
    try:
74
        root = etree.XML(xml, parser=create_parser())
75
        status = root.attrib["status"]
76
        return status is not None and status[0] == "2"
77
78
    except etree.Error as e:
79
        logger.error("etree.XML(xml): %s", e)
80
        return False
81
82
83
def _to_bool(value: bool) -> str: