def delete(request, task_id):
Task.objects.get(id=task_id).delete()
return redirect('/')
-
+
@login_required
def restart(request, task_id):
task = get_object_or_404(Task, id=task_id)
+ restart0(task)
+ return redirect('/')
+
+def add_restart_inp():
+ with open('file.inp','r') as f1, open ('file.inp.tmp','w') as f2:
+ for line in f1:
+ if 'reset_vel=' in line:
+ f2.write('{:79}'.format('restart'+line[7:]))
+ else:
+ f2.write(line)
+ os.remove('file.inp')
+ os.rename('file.inp.tmp','file.inp')
+ return
+
+def restart0(task):
if os.path.isfile(task.jobdirname+'/finished'):
os.remove(task.jobdirname+'/finished')
task.running =1
task.save()
if task.type == 'md':
os.chdir(task.jobdirname)
+ add_restart_inp()
ret_code = subprocess.Popen(' /opt/torque/bin/qsub pbs.csh', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
os.chdir('..')
elif task.type == 'remd':
os.chdir(task.jobdirname)
+ add_restart_inp()
tmp1=json.loads(task.remd_multi_m)
nreplicas=sum(map(int, tmp1))
with open('file_wham.inp','r') as f1, open ('file_wham.tmp','w') as f2:
os.rename('file_wham.tmp','file_wham.inp')
ret_code = subprocess.Popen(' /opt/torque/bin/qsub pbs8.csh', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
os.chdir('..')
- return redirect('/')
+ return
+def restart1(request, user_id, task_id):
+ task = get_object_or_404(Task, id=task_id)
+ user = task.owner
+ restart0(task)
+ return redirect('/details1/'+str(user)+'/'+str(task.id)+'/')
+
def refresh_done1(request, task_id):
task = get_object_or_404(Task, id=task_id)