views.py
def listLabelsOnIdDB():
    """This function allows to ask the db for labels' list"""
    if request.is_xhr and request.method=="POST":
        idDB = request.form["id"]
        global flag
        global count12
        try:
            count12 = managedb.countLabelDB()
            print("Label count:", count12)
            if(count12 == 0):

                flag = True
        except Exception as e:
            print("exception error DB", str(e))
            return json.dumps({"result": "error"})
        #the insertion default values
        if (flag):
            flag = False
            try:
                labels = ["","Medicane", "Storm", "Thunderstorm"]
                for l in labels:
                    label = {"labelName": l.upper(),"labelId":count12}
                    result15,id = managedb.insertLabelDB(label)
                    #print(result15,id)
                    if(result15 == True):
                        print("Label id:", str(id))
                        count12 += 1
                    else:
                        print("Label already inserted")
            except Exception as e:
                print("exception error DB", str(e))
                return json.dumps({"result": "error"})
        try:
            result,cursorListLabel = managedb.listLabelDB()
            if(result == False):
                print("label: there aren't results")
                return json.dumps({"result": "empty"})
            else:
                print("label: there are results")
                cursorListLabelJSON = mytools.modifyLabelJSON(cursorListLabel)
                return cursorListLabelJSON
        except Exception as e:
            print("exception error DB",str(e))
            return json.dumps({"result":"error"})
This function allows to ask the db for labels' list
This function allows to ask the db for labels' list
This function allows to ask the db for labels ' list
def listLabelsOnIdDB():
    if request.is_xhr and request.method=="POST":
        idDB = request.form["id"]
        global flag
        global count12
        try:
            count12 = managedb.countLabelDB()
            print("Label count:", count12)
            if(count12 == 0):
                flag = True
        except Exception as e:
            print("exception error DB", str(e))
            return json.dumps({"result": "error"})
        if (flag):
            flag = False
            try:
                labels = ["","Medicane", "Storm", "Thunderstorm"]
                for l in labels:
                    label = {"labelName": l.upper(),"labelId":count12}
                    result15,id = managedb.insertLabelDB(label)
                    if(result15 == True):
                        print("Label id:", str(id))
                        count12 += 1
                    else:
                        print("Label already inserted")
            except Exception as e:
                print("exception error DB", str(e))
                return json.dumps({"result": "error"})
        try:
            result,cursorListLabel = managedb.listLabelDB()
            if(result == False):
                print("label: there aren't results")
                return json.dumps({"result": "empty"})
            else:
                print("label: there are results")
                cursorListLabelJSON = mytools.modifyLabelJSON(cursorListLabel)
                return cursorListLabelJSON
        except Exception as e:
            print("exception error DB",str(e))
            return json.dumps({"result":"error"})
def listLabelsOnIdDB ( ) : if request . is_xhr and request . method == "POST" : idDB = request . form [ "id" ] global flag global count12 try : count12 = managedb . countLabelDB ( ) print ( "Label count:" , count12 ) if ( count12 == 0 ) : flag = True except Exception as e : print ( "exception error DB" , str ( e ) ) return json . dumps ( { "result" : "error" } ) if ( flag ) : flag = False try : labels = [ "" , "Medicane" , "Storm" , "Thunderstorm" ] for l in labels : label = { "labelName" : l . upper ( ) , "labelId" : count12 } result15 , id = managedb . insertLabelDB ( label ) if ( result15 == True ) : print ( "Label id:" , str ( id ) ) count12 += 1 else : print ( "Label already inserted" ) except Exception as e : print ( "exception error DB" , str ( e ) ) return json . dumps ( { "result" : "error" } ) try : result , cursorListLabel = managedb . listLabelDB ( ) if ( result == False ) : print ( "label: there aren't results" ) return json . dumps ( { "result" : "empty" } ) else : print ( "label: there are results" ) cursorListLabelJSON = mytools . modifyLabelJSON ( cursorListLabel ) return cursorListLabelJSON except Exception as e : print ( "exception error DB" , str ( e ) ) return json . dumps ( { "result" : "error" } )
This function allows to ask the db for labels' list
This function allows to ask the db for labels ' list
"""This function allows to ask the db for labels' list""" #the insertion default values #print(result15,id)