MCPcopy Index your code
hub / github.com/pyload/pyload / slotSaveConnection

Method slotSaveConnection

pyLoadGui.py:346–381  ·  view source on GitHub ↗

save connection to config file

(self, data)

Source from the content-addressed store, hash-verified

344 return ret
345
346 def slotSaveConnection(self, data):
347 """
348 save connection to config file
349 """
350 connectionsNode = self.parser.xml.elementsByTagName("connections").item(0)
351 if connectionsNode.isNull():
352 raise Exception("null")
353 connections = self.parser.parseNode(connectionsNode)
354 connNode = self.parser.xml.createElement("connection")
355 connNode.setAttribute("default", str(data["default"]))
356 connNode.setAttribute("type", data["type"])
357 connNode.setAttribute("id", data["id"])
358 nameNode = self.parser.xml.createElement("name")
359 nameText = self.parser.xml.createTextNode(data["name"])
360 nameNode.appendChild(nameText)
361 connNode.appendChild(nameNode)
362 if data["type"] == "remote":
363 serverNode = self.parser.xml.createElement("server")
364 serverNode.setAttribute("user", data["user"])
365 serverNode.setAttribute("port", data["port"])
366 serverNode.setAttribute("password", data["password"])
367 hostText = self.parser.xml.createTextNode(data["host"])
368 serverNode.appendChild(hostText)
369 connNode.appendChild(serverNode)
370 found = False
371 for c in connections:
372 cid = c.attribute("id", "None")
373 if str(cid) == str(data["id"]):
374 found = c
375 break
376 if found:
377 connectionsNode.replaceChild(connNode, found)
378 else:
379 connectionsNode.appendChild(connNode)
380 self.parser.saveData()
381 self.refreshConnections()
382
383 def slotRemoveConnection(self, data):
384 """

Callers

nothing calls this directly

Calls 3

refreshConnectionsMethod · 0.95
parseNodeMethod · 0.80
saveDataMethod · 0.80

Tested by

no test coverage detected