def check_command(command, startswith, endswith):
    output = subprocess.check_output(command)
    lines = output.split('\n')
    matches = False
    for line in lines:
        line = line.strip()
        if line.startswith(startswith):
            matches = True
            if not line.endswith(endswith):
                status = 0
                break
    else:
        if matches:
            status = 1
        else:
            raise BadOutputError(
                'The output was not in the expected format:\n%s' % output)
    return status
dataset/ETHPy150Open rcbops/rpc-openstack/maas/plugins/hp_monitoring.py/check_command/original