From: Cezary Czaplewski Date: Wed, 12 Feb 2020 20:47:12 +0000 (+0100) Subject: pbs qdel not done jobs on rm X-Git-Url: http://mmka.chem.univ.gda.pl/gitweb/?a=commitdiff_plain;h=56595cc7938f5c7b53dd3ebe91b2a42f52cb89d1;p=django_unres.git pbs qdel not done jobs on rm --- diff --git a/django_simple/todo/jobfiles.py b/django_simple/todo/jobfiles.py index f78b873..e7ee716 100644 --- a/django_simple/todo/jobfiles.py +++ b/django_simple/todo/jobfiles.py @@ -72,7 +72,7 @@ def write_ssbond(ssbond): @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) @@ -545,14 +545,28 @@ CUTOFF=7.00000 WCORR4=0.00000""" 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 diff --git a/django_simple/todo/models.py b/django_simple/todo/models.py index d11b412..622cac3 100644 --- a/django_simple/todo/models.py +++ b/django_simple/todo/models.py @@ -104,6 +104,7 @@ class Task(models.Model): owner = models.ForeignKey(User,default=1) created_date = models.DateTimeField(default=timezone.now) jobdirname = models.CharField(max_length=100,default='') + pbsjob = models.CharField(max_length=40,default='') example = models.CharField(max_length=10,default='') damino = models.BooleanField(default=False) diff --git a/django_simple/todo/templates/details.html b/django_simple/todo/templates/details.html index 3466e5c..2b926d1 100644 --- a/django_simple/todo/templates/details.html +++ b/django_simple/todo/templates/details.html @@ -80,6 +80,12 @@ Created {{ task.created_date }}
type
{{ task.type }}
+ +
  • +
    pbsjob
    +
    {{ task.pbsjob }}
    +
  • +
  • force field