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
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
def close_card_open(chat_id, path, nf): result = '' db = None try: db = DB_Manager.openDB(db, 'system.db') DB_Manager.delete_temp_card(db) result = DB_Manager.insert_card(db, chat_id, path, nf) except Exception as e: print "Error:", e finally: db = DB_Manager.closeDB(db) return result
def return_dialog_open(): result = '' db = None try: db = DB_Manager.openDB(db, 'system.db') r = DB_Manager.select_first_dialog_open(db) if r != '': result = str(r) except Exception as e: print "Error:", e finally: db = DB_Manager.closeDB(db) return result
def getCardList(): result = '' db = None try: db = DB_Manager.openDB(db, 'system.db') r = DB_Manager.select_list_card(db) if r != '': result = r result = 'Elenco Carte:' + chr(10) + result except Exception as e: print "Error:", e finally: db = DB_Manager.closeDB(db) return result
def addPKey(swName,pKey): result='' db=None try: db=DB_Manager.openDB(db,'system.db') r=DB_Manager.insert_pkey(db,swName,pKey) if r != '' : result=str(r) else: result=result+' '+swName except Exception as e: print "Error:",e finally: db=DB_Manager.closeDB(db) return result
def getPKey(swName): result='' db=None try: db=DB_Manager.openDB(db,'system.db') r=DB_Manager.select_one_pkey(db,swName) if r != '' : result=str(r) else: result='Non ho trovato nessun Product Key per '+swName except Exception as e: print "Error:",e finally: db=DB_Manager.closeDB(db) return result
def addTGroup(tgName): result='' db=None try: db=DB_Manager.openDB(db,'system.db') r=DB_Manager.insert_tgroup(db,tgName) if r != '' : result=str(r) else: result=result+' '+tgName except Exception as e: print "Error:",e finally: db=DB_Manager.closeDB(db) return result
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
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
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
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
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
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
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