def notify_job_completed(request, job_id): t = Templeton(SERVER_USER.get()) job = Job.objects.get(job_id=job_id) job.status = job.JOB_COMPLETED try: result = t.check_job(job_id) exitValue = result['exitValue'] if 'exitValue' in result else None completed = result['completed'] if 'completed' in result else None runState = result['status']['runState'] if 'status' in result and 'runState' in result['status'] else None if runState == job.TEMPLETON_JOB_RUN_STATE_KILLED: job.status = job.JOB_KILLED elif runState == job.TEMPLETON_JOB_RUN_STATE_FAILED or (completed and exitValue is not None and exitValue != 0): job.status = job.JOB_FAILED except Exception, ex: LOG.debug(unicode(ex))
def check_running_job(request, job_id): t = Templeton(request.user.username) job = Job.objects.get(job_id=job_id) if job is not None: try: result = t.check_job(job_id) exitValue = result['exitValue'] if 'exitValue' in result else None completed = result['completed'] if 'completed' in result else None runState = result['status']['runState'] if 'status' in result and 'runState' in result['status'] else None if runState == job.TEMPLETON_JOB_RUN_STATE_KILLED: job.status = job.JOB_KILLED elif runState == job.TEMPLETON_JOB_RUN_STATE_FAILED or \ (completed and exitValue is not None and exitValue != 0): job.status = job.JOB_FAILED job.save() return HttpResponse(json.dumps({"status": job.status})) except Exception, ex: LOG.debug(unicode(ex))
def notify_job_completed(request, job_id): t = Templeton(SERVER_USER.get()) job = Job.objects.get(job_id=job_id) job.status = job.JOB_COMPLETED try: result = t.check_job(job_id) exitValue = result['exitValue'] if 'exitValue' in result else None completed = result['completed'] if 'completed' in result else None runState = result['status'][ 'runState'] if 'status' in result and 'runState' in result[ 'status'] else None if runState == job.TEMPLETON_JOB_RUN_STATE_KILLED: job.status = job.JOB_KILLED elif runState == job.TEMPLETON_JOB_RUN_STATE_FAILED or ( completed and exitValue is not None and exitValue != 0): job.status = job.JOB_FAILED except Exception, ex: LOG.debug(unicode(ex))
def check_running_job(request, job_id): t = Templeton(request.user.username) job = Job.objects.get(job_id=job_id) if job is not None: try: result = t.check_job(job_id) exitValue = result['exitValue'] if 'exitValue' in result else None completed = result['completed'] if 'completed' in result else None runState = result['status'][ 'runState'] if 'status' in result and 'runState' in result[ 'status'] else None if runState == job.TEMPLETON_JOB_RUN_STATE_KILLED: job.status = job.JOB_KILLED elif runState == job.TEMPLETON_JOB_RUN_STATE_FAILED or \ (completed and exitValue is not None and exitValue != 0): job.status = job.JOB_FAILED job.save() return HttpResponse(json.dumps({"status": job.status})) except Exception, ex: LOG.debug(unicode(ex))
def ping_job(request, job_id): t = Templeton(request.user.username) try: result = t.check_job(job_id) except Exception, ex: result = {"status": {"failureInfo": unicode(ex)}}