Hello

In my controller function I have a couple of try excepts. In case of except 
I want to update db record status to different value based on where the 
error occurred. somehow update record is not executed

any suggestions why?

here is my controller  function

def runWoshi(scriptId, script, outPath, org, path,llsPath):
    

    print "scriptId ", scriptId
    db.script_activity.insert(sa_id_script = scriptId, sa_start = 'now', 
sa_organization = org, sa_location =  llsPath);
    
    ##validiramo json če ima kakršne koli napake idt.
    try:
        print "tukej validiram neki"
        valJson = validateJson(script.sc_menu_data)
    
    except Exception as e:
        "Če je napaka v validaciji Jsona je status v  92"
        script.update_record(sc_status = 92)
        print db._lastsql
        print "je biu error scripta id " ,scriptId
        
        exc_type, exc_obj, exc_tb = sys.exc_info()
        fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
        errmsg = ["error v validaciji Jsona", exc_type, fname, 
exc_tb.tb_lineno,e.__doc__ , e.message]
        print errmsg
        print(exc_type, fname, exc_tb.tb_lineno)
        print e.__doc__
        print e.message
        return dict(status = 672, errmsg = errmsg)
     
            
#    if not valJson:
#        script.update_record(sc_status = 92)
#        #validacija ni uspela vrnemo error 300 
#        return dict(status = 300)
#    #nov json - z vsemi errorji zapiđšemo v sc_menu_data
#    else:
    script.update_record(sc_menu_data = valJson["formJson"])
    
    #če obstajjo errorji pol konc
    if valJson["errors"]:
        #skripta gre v status 91, kar pomen da je user ne more dat računat
        update = db(db.scripts.id == scriptId).update(sc_status = 91)
        print "Json errors " , valJson["errors"]
        return dict(status = 200)
    
    
    
    updateScripts = db(db.scripts.id == scriptId).update(sc_engine_output = 
None)

    ##kreiram LLS        
    try:
        transData = TranslateData(script.sc_menu_data, path, scriptId, org)
    
    except Exception as e:
        
        "Status 91 pomen da je bila napaka pri kreiranju lls skripte"
        update = db(db.scripts.id == scriptId).update(sc_status = 90)
        exc_type, exc_obj, exc_tb = sys.exc_info()
        fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
        errmsg = ["Creating LLS from Json failed ", exc_type, fname, 
exc_tb.tb_lineno,e.__doc__ , e.message]
        print "errmsg ", errmsg
        print(exc_type, fname, exc_tb.tb_lineno)
        print e.__doc__
        print e.message
        return dict(status = 668, errmsg = errmsg)
    
    
    #Se prav se je zgodu error pri kreiranju datoteke
#    if transData["data"]["type"] == 666:
#        #status damo v 90 in vrnemo kar je v error
#        update = db(db.scripts.id == scriptId).update(sc_status = 90)
#        #print 'transData["data"] ' , transData["data"]
#        #transDataError = transData["data"]
#        return  dict(status = 664)   
#        
#    try:
        #Pobiršem out file če obstaja v mapi engine/e1 in sc_engine_out
    count = 0
    while ( count < 10 and ( os.path.isfile(outPath))):
        count += 1 
#            print count
#            print "brisem out..."
        os.remove(outPath)
        time.sleep(0.05)
    
    # Run woshi engine
    path_1 =  os.path.join(path, 'e1')
    os.chdir(path_1)
    #pot =  path_1 + "\\woshi_engine.exe"
    #print pot
    #p = subprocess.Popen(['w_parameter.bat', id], shell=True, stdout = 
subprocess.PIPE)
    p = subprocess.Popen(['woshi_engine.exe', scriptId], shell=True, stdout 
= subprocess.PIPE)
    
    return dict(status = 1)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to