def addNewUser(self, username, pin, authenticationToken, myId): printl("", self, "S") tree = getXmlContent(self.location) newId = myId#int(self.lastMappingId) + 1 printl("newId: " + str(newId), self, "D") printl("username: "******"D") printl("pin: " + str(pin), self, "D") printl("token: " + str(authenticationToken), self, "D") existingServer = False for server in tree.findall("server"): printl("servername: " + str(server.get('id')), self, "D") if str(server.get('id')) == str(self.serverID): existingServer = True server.append(etree.Element('user id="' + str(newId) + '" username="******" pin="' + pin + '" token="' + authenticationToken + '"')) writeXmlContent(tree, self.location) if not existingServer: # this server has no node in the xml printl("expanding server list", self, "D") tree.append(etree.Element('server id="' + str(self.serverID) + '"')) writeXmlContent(tree, self.location) # now lets go through the xml again to add the mapping to the server self.addNewUser(username, pin, authenticationToken, newId) printl("", self, "C")
def addNewMapping(self, remotePath, localPath): printl("", self, "S") tree = getXmlContent(self.location) newId = int(self.lastMappingId) + 1 printl("newId: " + str(newId), self, "D") printl("remotePath: " + str(remotePath), self, "D") printl("localPath: " + str(localPath), self, "D") existingServer = False for server in tree.findall("server"): printl("servername: " + str(server.get('id')), self, "D") if str(server.get('id')) == str(self.serverID): existingServer = True server.append(etree.Element('mapping id="' + str(newId) + '" remotePathPart="' + remotePath + '" localPathPart="' + localPath + '"')) writeXmlContent(tree, self.location) if not existingServer: # this server has no node in the xml printl("expanding server list", self, "D") tree.append(etree.Element('server id="' + str(self.serverID) + '"')) writeXmlContent(tree, self.location) # now lets go through the xml again to add the mapping to the server self.addNewMapping(remotePath, localPath) printl("", self, "C")
def addNewMapping(self, remotePath, localPath): printl("", self, "S") tree = getXmlContent(self.location) newId = int(self.lastMappingId) + 1 printl("newId: " + str(newId), self, "D") printl("remotePath: " + str(remotePath), self, "D") printl("localPath: " + str(localPath), self, "D") existingServer = False for server in tree.findall("server"): printl("servername: " + str(server.get('id')), self, "D") if str(server.get('id')) == str(self.serverID): existingServer = True server.append( etree.Element('mapping id="' + str(newId) + '" remotePathPart="' + remotePath + '" localPathPart="' + localPath + '"')) writeXmlContent(tree, self.location) if not existingServer: # this server has no node in the xml printl("expanding server list", self, "D") tree.append(etree.Element('server id="' + str(self.serverID) + '"')) writeXmlContent(tree, self.location) # now lets go through the xml again to add the mapping to the server self.addNewMapping(remotePath, localPath) printl("", self, "C")
def addNewUser(self, username, pin, authenticationToken, myId): printl("", self, "S") tree = getXmlContent(self.location) newId = myId #int(self.lastMappingId) + 1 printl("newId: " + str(newId), self, "D") printl("username: "******"D") printl("pin: " + str(pin), self, "D") printl("token: " + str(authenticationToken), self, "D") existingServer = False for server in tree.findall("server"): printl("servername: " + str(server.get('id')), self, "D") if str(server.get('id')) == str(self.serverID): existingServer = True server.append( etree.Element('user id="' + str(newId) + '" username="******" pin="' + pin + '" token="' + authenticationToken + '"')) writeXmlContent(tree, self.location) if not existingServer: # this server has no node in the xml printl("expanding server list", self, "D") tree.append(etree.Element('server id="' + str(self.serverID) + '"')) writeXmlContent(tree, self.location) # now lets go through the xml again to add the mapping to the server self.addNewUser(username, pin, authenticationToken, newId) printl("", self, "C")
def deleteSelectedUser(self, userId): printl("", self, "S") tree = getXmlContent(self.location) printl("serverID: " + str(self.serverID), self, "D") for server in tree.findall("server"): printl("servername: " + str(server.get('id')), self, "D") if str(server.get('id')) == str(self.serverID): for user in server.findall('user'): printl("user: "******"D") if str(user.get('id')) == str(userId): server.remove(user) writeXmlContent(tree, self.location) printl("", self, "C")
def deleteSelectedMapping(self, mappingId): printl("", self, "S") tree = getXmlContent(self.location) printl("serverID: " + str(self.serverID), self, "D") for server in tree.findall("server"): printl("servername: " + str(server.get('id')), self, "D") if str(server.get('id')) == str(self.serverID): for mapping in server.findall('mapping'): printl("mapping: " + str(mapping.get('id')), self, "D") if str(mapping.get('id')) == str(mappingId): server.remove(mapping) writeXmlContent(tree, self.location) printl("", self, "C")