def parse_job_lsf(log_file, job_id):
    """ Parse lsf log file to check whether the corresponding
        job was finished successfully
    """
    with open(log_file, 'r') as f:
        for ll in f:
            ll = ll.rstrip()
            # '---------------' marks the begin of lsf log
            if ll.startswith('---------------'):
                return False
            try:
                # get rid of the datetime prefix and check
                msg = " ".join(ll.split()[2:])
            except Exception:
                # if this fails for some reason, there is something unexpected in
                # the log and we fail the job
                return False
            if msg == "processed job %i" % job_id:
                return True
    return False