def updateUserData(): if (username == "bluepixels"): debug.warning("Not updating userdata for bluepixels") return (0) dbcon = dbTrayServer.dbTray() try: hostname = socket.gethostname() except: debug.error(sys.exc_info()) return (0) if (hostname.find("localhost") >= 0): return (0) try: dbcon.execute("insert into users (user,host) values (\"" + username + "\",\"" + hostname + "\") ") except: try: dbcon.execute("delete from users where host=\"" + hostname + "\"") except: debug.error(sys.exc_info()) try: dbcon.execute("delete from users where user=\"" + username + "\"") except: debug.error(sys.exc_info()) try: dbcon.execute("insert into users (user,host) values (\"" + username + "\",\"" + hostname + "\") ") except: debug.error(sys.exc_info())
def seeNotification(id): dbcon = dbTrayServer.dbTray() try: rows = dbcon.execute("delete from notify where id=\"" + id + "\"") return (1) except: debug.error(sys.exc_info()) return (0)
def markAsChecked(id): dbcon = dbTrayServer.dbTray() try: rows = dbcon.execute("update notify set isChecked=1 where id=\"" + id + "\"") return (1) except: debug.error(sys.exc_info()) return (0)
def getUsers(): dbcon = dbTrayServer.dbTray() try: rows = dbcon.execute("select * from users order by host", dictionary=True) if (rows): if (not isinstance(rows, int)): return (rows) except: debug.error(sys.exc_info()) return (0)
def getNotifications(): dbcon = dbTrayServer.dbTray() try: rows = dbcon.execute("select * from notify where toUsers=\"" + username + "\" and afterTime<=now()", dictionary=True) if (rows): if (not isinstance(rows, int)): return (rows) except: debug.error(sys.exc_info()) return (0)
def deleteUserData(): dbcon = dbTrayServer.dbTray() try: hostname = socket.gethostname() except: debug.error(sys.exc_info()) return (0) try: dbcon.execute("delete from users where host=\"" + hostname + "\"") except: debug.error(sys.exc_info()) try: dbcon.execute("delete from users where user=\"" + username + "\"") except: debug.error(sys.exc_info())