Ejemplo n.º 1
0
def sql_job_status(job_id):
    """Return the job status for the last submission attempt of this sql script
    
    job_id - the job_id, for instance returned by sql_file_job_id
    
    returns either the result of bjobs for the latest job submitted or
    "DONE" if the job is marked as done in the database.
    Raises an exception if no job is found.
    """
    cursor = connection.cursor()
    try:
        statement = """select stop_timestamp
                         from sql_job where job_id = %(job_id)d""" % (locals())
        rowcount = cursor.execute(statement)
        if rowcount == 0:
            raise ValueError(
                "Can't find job with job_id = %(job_id)d in the database" %
                (locals()))
        (stop_timestamp, ) = cursor.fetchone()
    finally:
        cursor.close()

    if not stop_timestamp is None:
        return "DONE"

    status = GetJobStatus(job_id)
    if status is None:
        # Job didn't report to database and isn't visible
        return "UNKNOWN"
    if not status.has_key("STAT"):
        return "UNKNOWN"
    return status["STAT"]
Ejemplo n.º 2
0
def sql_job_status(job_id):
    """Return the job status for the last submission attempt of this sql script
    
    job_id - the job_id, for instance returned by sql_file_job_id
    
    returns either the result of bjobs for the latest job submitted or
    "DONE" if the job is marked as done in the database.
    Raises an exception if no job is found.
    """
    cursor = connection.cursor()
    try:
        statement = """select stop_timestamp
                         from sql_job where job_id = %(job_id)d"""%(locals())
        rowcount = cursor.execute(statement)
        if rowcount == 0:
            raise ValueError("Can't find job with job_id = %(job_id)d in the database"%(locals()))
        (stop_timestamp,) = cursor.fetchone()
    finally:
        cursor.close()
    
    if not stop_timestamp is None:
        return "DONE"
    
    status = GetJobStatus(job_id)
    if status is None:
        # Job didn't report to database and isn't visible
        return "UNKNOWN"
    if not status.has_key("STAT"):
        return "UNKNOWN"
    return status["STAT"]