def deleteUser(self,cID): conn = connection.connectDB(self.DBpath) c = conn.cursor() c.execute("delete from users where ClientID = {0}".format(cID)) conn.commit() c.close()
def addGroup(self,g_id,gname): conn = connection.connectDB(self.DBpath) c = conn.cursor() c.execute("insert into groups values ( {0}, '{1}' )".format(g_id,gname)) conn.commit(); c.close();
def deleteClientFromGroup(self,c_id,g_id): conn = connection.connectDB(self.DBpath) c = conn.cursor() c.execute("delete from assoc where cID = {0} and gID = {1}".format(c_id,g_id)) conn.commit(); c.close();
def setpassword(self,password): conn = connection.connectDB(self.DBpath) c = conn.cursor() c.execute("delete from clientconfig") c.execute("insert into clientconfig(password) values ('{0}')".format(password)) conn.commit(); c.close();
def getClientsInGroup(self, group): conn = connection.connectDB(self.DBpath) c = conn.cursor() c.execute("select ClientID, ClientName, gID from clients left join (select * from assoc where gID = {0}) on clients.ClientID = cID".format(group)) clientlist=[] for name in c : clientlist.append(name) return clientlist
def deleteGroup(self,groupID): conn = connection.connectDB(self.DBpath) c = conn.cursor() c.execute("delete from groups where GroupID = '{0}'".format(groupID)) c.execute("delete from assoc where cID = '{0}'".format(groupID)); conn.commit(); c.close();
def updateKey(username,password): conn = connection.connectDB(config.DB_path) c = conn.cursor() list = createKey(username,password) c.execute("delete from auth") c.execute("insert into auth values(?,?) ",list) conn.commit() c.close()
def getGroupsList(self): conn = connection.connectDB(self.DBpath) c = conn.cursor() c.execute("select * from groups") grouplist = [] for name in c : grouplist.append(name) return grouplist
def getUserList(self): conn = connection.connectDB(self.DBpath) c = conn.cursor() c.execute("select * from users") userlist=[] for name in c : userlist.append(name) return userlist
def addUser(self,uid,name,ip): conn = connection.connectDB(self.DBpath) c = conn.cursor() if len(ip) == 0: #set default IP pass c.execute("insert into users values ( {0}, '{1}', '{2}')".format(uid,name,ip)) conn.commit() c.close()
def getClientsList(self): conn = connection.connectDB(self.DBpath) c = conn.cursor() c.execute("select * from clients") clientlist=[] for name in c : clientlist.append(name) return clientlist
def read_key(): conn = connection.connectDB(config.DB_path) c = conn.cursor() c.execute("select * from auth") list = c.fetchone() if list == None: list = createKey("admin","admin") c.execute("insert into auth values(?,?) ",list) conn.commit() c.close() return list
def getchname(self,group): conn = connection.connectDB(self.DBpath) c = conn.cursor() c.execute("select GroupName from groups where GroupID = {0} ".format(group)) for name in c: return name[0];
def addClientToGroup(self,c_id,g_id): conn = connection.connectDB(self.DBpath) c = conn.cursor() c.execute("insert into assoc values ( {0}, {1} )".format(c_id,g_id)) conn.commit(); c.close();
def getPassword(self): conn = connection.connectDB(self.DBpath) c = conn.cursor() c.execute("select password from clientconfig") password = c.fetchone()[0] return password