예제 #1
0
def getSimulationJSON(request, result_id):
  # ...
  res = ModellingResult.objects.get(id=result_id)
  # ...

  # set time limits
  dt = 60*30 # task has 30min till it gets revoked
  expire = 60 # task gets canceled after 60s in queue
  
  task = calculateModel.apply_async(args=(result_id,), timeout=dt,
                                    expires=expire)
  res.is_rendered = False
  res.task_id = task.task_id
  res.rendered_last = now();
  res.save()
예제 #2
0
def getSimulationJSON(request, result_id):
    # ...
    res = ModellingResult.objects.get(id=result_id)
    # ...

    # set time limits
    dt = 60 * 30  # task has 30min till it gets revoked
    expire = 60  # task gets canceled after 60s in queue

    task = calculateModel.apply_async(args=(result_id, ),
                                      timeout=dt,
                                      expires=expire)
    res.is_rendered = False
    res.task_id = task.task_id
    res.rendered_last = now()
    res.save()
 os.mkdir(datapath)
 #shutil.copy(old_datapath+'/cfg.gls', datapath+'/cfg.gls')
 try:
   shutil.copy(old_datapath+'/input.png', datapath+'/input.png')
 except:
   pass
 
 with open(old_datapath+'/cfg.gls', 'r') as f:
   txt = f.read()
 with open(datapath+'/cfg.gls', 'w') as f:
   txt = re.sub('pixrad\((\d+)\)', "pixrad(%i) #man"%new_pxr, txt)
   txt = re.sub('model\((\d+)\)', "model(%i) #man"%new_nmod, txt)
   txt = re.sub('tmp_media/\d+', "tmp_media/%06i"%new_id, txt)
   f.write(txt)
   
 task = calculateModel.apply_async(args=(new_id,), timeout=10e10, expires=10e10)
 mresobj_new.task_id = task.task_id
 mresobj_new.save()
 
   
 print " --> improved_id: {0}".format(new_id)
 logf.write("  {id}: by: {user[user_name]:12} p:{pxr:2} m:{nmod:4} comment: '{com}'".format(**model))
 logf.write("  improved_id: {0}\n".format(new_id))
 logf.flush()
 post.write(" - [model {0:06}, was {1:06}](http://mite.physik.uzh.ch/data/{0:06}) | by: {2} | time: {3} | comment: '{4}'\n".format(
   new_id, mresobj_old.pk, mresobj_old.created_by_str, mresobj_old.created, model['com']
 ))
 post.flush()
 newids.write("%06i\n"%new_id)
 newids.flush()