@receiver(post_save, sender=Task)
def write_on_task_save(sender, instance, **kwargs):
- if instance.ready and not instance.done and instance.running==0:
+ if instance.ready and not instance.done and instance.running==0 and instance.pbsjob=='':
if (not os.path.isdir(instance.jobdirname)):
os.mkdir(instance.jobdirname)
# os.chdir(instance.jobdirname)
os.chdir(instance.jobdirname)
ret_code = subprocess.Popen(' /opt/torque/bin/qsub pbs8.csh', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
os.chdir('..')
+
+ output = str(ret_code.communicate()[0])
+ output=output.strip()
+ if output=='':
+ output='error'
+ logger.warning("PBS \"%s\" " % output)
+ instance.pbsjob = output
+ instance.save()
- print ret_code.stdout.readlines()
+# print ret_code.stdout.readlines()
logger.warning("Dir \"%s\" has been saved." % instance.jobdirname)
@receiver(post_delete, sender=Task)
def delete_on_task_del(sender, instance, **kwargs):
if instance.jobdirname:
if os.path.isdir(instance.jobdirname):
+ if not instance.done:
+ ret_code_qdel = subprocess.Popen(' /opt/torque/bin/qdel '+str(instance.pbsjob), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ output = str(ret_code_qdel.communicate()[0])
+ output=output.strip()
+ logger.warning("PBS qdel \"%s\" " % instance.pbsjob)
+ logger.warning("QDEL \"%s\" " % output)
shutil.rmtree(instance.jobdirname)
logger.warning("Dir \"%s\" has been rm." % instance.jobdirname)
\ No newline at end of file