Exemplo n.º 1
0
def _extract_last_nlines(path, nlines=25):
    """Attempt to extract the last nlines from a file

    If the file is not found or there's an error parsing the file,
    an empty string is returned.
    """
    try:
        n = nlines + 1
        nfs_exists_check(path)
        with open(path, 'r') as f:
            s = f.readlines()
            return "\n".join(s[-1: n])
    except Exception as e:
        log.exception("Unable to extract stderr from {p}. {e}".format(p=path, e=e))
        return ""
Exemplo n.º 2
0
def _get_last_lines_of_stderr(n, stderr_path):
    """Read in the last N-lines of the stderr from a task

    This should be smarter to look for stacktraces and common errors.
    """
    lines = []
    try:
        nfs_exists_check(stderr_path)
        with open(stderr_path, 'r') as f:
            lines = deque(f, n)
            lines = [l.rstrip() for l in lines]
    except Exception as e:
        log.exception("Unable to extract stderr from {p} Error {e}".format(p=stderr_path, e=e.message))

    return lines
Exemplo n.º 3
0
def _extract_last_nlines(path, nlines=25):
    """Attempt to extract the last nlines from a file

    If the file is not found or there's an error parsing the file,
    an empty string is returned.
    """
    try:
        n = nlines + 1
        nfs_exists_check(path)
        with open(path, 'r') as f:
            s = f.readlines()
            return "".join(s[-n:])
    except Exception as e:
        log.warn("Unable to extract stderr from {p}. {e}".format(p=path, e=e))
        return ""
Exemplo n.º 4
0
def _get_last_lines_of_stderr(n, stderr_path):
    """Read in the last N-lines of the stderr from a task

    This should be smarter to look for stacktraces and common errors.
    """
    lines = []
    try:
        nfs_exists_check(stderr_path)
        with open(stderr_path, 'r') as f:
            lines = deque(f, n)
            lines = [l.rstrip() for l in lines]
    except Exception as e:
        log.exception("Unable to extract stderr from {p} Error {e}".format(p=stderr_path, e=e.message))

    return lines
Exemplo n.º 5
0
def trigger_nfs_refresh(ff):
    return nfs_exists_check(ff)