Beispiel #1
0
def getCard(cardName):
    result = ''
    db = None
    try:
        db = DB_Manager.openDB(db, 'system.db')
        r = DB_Manager.select_path_card(db, cardName)
        if r != '':
            result = "!F" + str(r)
        else:
            result = 'Non ho trovato nessuna Card per ' + cardName

    except Exception as e:
        print "Error:", e
    finally:
        db = DB_Manager.closeDB(db)
        return result
Beispiel #2
0
def getTGroup():
  result=''
  db=None
  try:
    db=DB_Manager.openDB(db,'system.db')
    r=DB_Manager.select_one_tgroup(db)
    if r != '' :
      result=str(r)
    else:
      result='Non ho trovato nessun Product Key per '+tgName
      
  except Exception as e:
    print "Error:",e        
  finally:
    db=DB_Manager.closeDB(db)
    return result  
Beispiel #3
0
def auth_permission(chat_id):
    result = False
    liv = ''
    db = None
    try:
        db = DB_Manager.openDB(db, 'system.db')
        r = DB_Manager.select_user_level_from_chatid(db, chat_id)
        if r != '':
            liv = str(r[0])
            if liv == '10':
                result = True
    except Exception as e:
        print "Sub:auth_permission Error:", e
    finally:
        db = DB_Manager.closeDB(db)
        return result
Beispiel #4
0
def inizio_discorso():
    result = ''
    db = None
    fn = crea_dialog()
    try:
        db = DB_Manager.openDB(db, 'system.db')
        r = DB_Manager.insert_dialog(db, fn, '')
        mex = "Inizio discorso " + fn
        result = mex

    except Exception as e:
        print "Error:", e
        result = "Errore durante creazione discorso"

    finally:
        db = DB_Manager.closeDB(db)
        return result
Beispiel #5
0
def chiudi_discorso():
    result = ''
    db = None
    fn = return_dialog_open()
    try:
        db = DB_Manager.openDB(db, 'system.db')
        r = DB_Manager.update_dialog(db, fn)
        mex = "Chiudo discorso " + fn
        result = mex

    except Exception as e:
        print "Error:", e
        result = "Errore durante creazione discorso"

    finally:
        db = DB_Manager.closeDB(db)
        return result
Beispiel #6
0
def addCard(cardName):
    result = ''
    db = None
    try:
        db = DB_Manager.openDB(db, 'system.db')
        r = DB_Manager.insert_temp_card(db, cardName)
        if r != '':
            result = str(r)
        else:
            # result=result+' '+cardName
            result = 'Errore durante registrazione carta ' + cardName

    except Exception as e:
        print "Error:", e
    finally:
        db = DB_Manager.closeDB(db)
        return result
Beispiel #7
0
def home_request_app(cmd):
    result = ""
    r = ''
    db = None
    try:
        db = DB_Manager.openDB(db, 'system.db')
        DB_Manager.insert_TB_HOME_COM(db, cmd)
        r = DB_Manager.select_last_TB_HOME_COM(db)
        if int(r[0]) > 0:
            time.sleep(3)
            result = DB_Manager.select_TB_HOME_COM(db, str(r[0]))
            if result != "":
                result = result[4]
    except Exception as e:
        print "Sub:home_request Error:", e
    finally:
        DB_Manager.closeDB(db)
        return result
Beispiel #8
0
def check_presenze():
    result = ""
    db = None
    try:
        db = DB_Manager.openDB(db, 'system.db')
        r = DB_Manager.select_last_TB_HOME_PRESENZE(db)
        #print r
        if r != '':
            result = "Rilevata presenza in camera!"
            result = result + chr(10) + "DATA: " + r
            DB_Manager.update_last_TB_PRESENZE(db)

    except Exception as e:
        print "Sub:check_presenze Error:", e
        result = 'Scusa ho dei problemi a comunicare con il database!'

    finally:
        db = DB_Manager.closeDB(db)
        return result
Beispiel #9
0
def UpdateRealtime(retstr, tipo):
    SUBNAME = "UpdateRealtime"

    db = None
    result = ""
    RT_LASTUPDATE = ""
    RT_STATE = ""
    RT_NOTE = ""
    RT_SUBJECT = ""

    if tipo == 0:
        # PREPARO PARAMETRI QUERY
        RT_LASTUPDATE = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        r = retstr.split(" ")
        r = r[3:]  # TOLGO I PRIMI 3 ELEMENTI PERCHE VUOTI
        RT_SUBJECT = r[0]
        RT_STATE = r[1]
        RT_NOTE = " ".join(r[2:])
    else:
        # PREPARO PARAMETRI QUERY
        RT_LASTUPDATE = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        r = retstr.split(" ")
        RT_SUBJECT = r[0]
        RT_STATE = r[1]
        RT_NOTE = ""

    # UPDATE TB_REALTIME
    try:
        db = DB_Manager.openDB(db, 'system.db')
        result = DB_Manager.UPDATE_TB_SYS_REALTIME_INFO(
            db, RT_SUBJECT, RT_STATE, RT_LASTUPDATE, RT_NOTE)
        if result != '':
            raise Exception(result)

    # ERRORE!
    except Exception as e:
        result = "Error-%s:%s " % (SUBNAME, e)
    # RITORNA RISULTATO
    finally:
        db = DB_Manager.closeDB(db)
        return result
Beispiel #10
0
def home_request(chat_id, cmd):
    result = ""
    r = ''
    db = None
    try:
        if auth_permission(chat_id) == True and chat_id != '':
            db = DB_Manager.openDB(db, 'system.db')
            DB_Manager.insert_TB_HOME_COM(db, cmd)
            r = DB_Manager.select_last_TB_HOME_COM(db)
            if int(r[0]) > 0:
                time.sleep(3)
                result = DB_Manager.select_TB_HOME_COM(db, str(r[0]))
                if result != "":
                    result = result[4]
        else:
            result = "Non hai l'autorizzazione per questo genere di comandi!"
    except Exception as e:
        print "Sub:home_request Error:", e
    finally:
        DB_Manager.closeDB(db)
        return result