Exemple #1
0
 def _editDevice(self):
     '''
     Runs the 'Edit device' dialog for currently selected device.
     '''
     items = self._deviceList.selectedItems()
     if not items:
         return
     dev = devices.get(items[0].text(0))
     log.debug("Editing device: %s" % dev)
     dialog = DeviceConfigDialog(dev)
     if not dialog.run():
         return
     connect = dialog.params.pop("connect", False)
     if dev.name != dialog.params["name"]:
         self._updateConnectionState(False, dev)
         devices.remove(dev.name)
         index = self._deviceList.indexOfTopLevelItem(items[0])
         self._deviceList.takeTopLevelItem(index)
         dev = devices.add(type=Device, **dialog.params)
         self._addDeviceItem(dev)
     else:
         address = dialog.params["address"]
         port = dialog.params["port"]
         if dev.address != (address, port):
             self._updateConnectionState(False, dev)
         devices.update(**dialog.params)
         self._deviceItems[dev].updateDevice()
     log.info("Device edited: %s" % dev)
     if connect:
         self._updateConnectionState(True, dev)
Exemple #2
0
 def _editDevice(self):
     '''
     Runs the 'Edit device' dialog for currently selected device.
     '''
     items = self._deviceList.selectedItems()
     if not items:
         return
     dev = devices.get(items[0].text(0))
     log.debug("Editing device: %s" % dev)
     dialog = DeviceConfigDialog(dev)
     if not dialog.run():
         return
     connect = dialog.params.pop("connect", False)
     if dev.name != dialog.params["name"]:
         self._updateConnectionState(False, dev)
         devices.remove(dev.name)
         index = self._deviceList.indexOfTopLevelItem(items[0])
         self._deviceList.takeTopLevelItem(index)
         dev = devices.add(type=Device, **dialog.params)
         self._addDeviceItem(dev)
     else:
         address = dialog.params["address"]
         port = dialog.params["port"]
         if dev.address != (address, port):
             self._updateConnectionState(False, dev)
         devices.update(**dialog.params)
         self._deviceItems[dev].updateDevice()
     log.info("Device edited: %s" % dev)
     if connect:
         self._updateConnectionState(True, dev)
Exemple #3
0
 def _removeDevice(self):
     '''
     Removes the currently selected device.
     '''
     items = self._deviceList.selectedItems()
     if not items:
         return
     dev = devices.get(items[0].text(0))
     if not dialogs.runQuestion("Do you want to remove "
                                "'%s' device permanently?" % dev.name):
         return
     log.debug("Removing device: %s" % dev)
     self._updateConnectionState(False, dev)
     devices.remove(dev.name)
     self._removeDeviceItem(dev)
     log.info("Device removed: %s" % dev)
Exemple #4
0
 def _removeDevice(self):
     '''
     Removes the currently selected device.
     '''
     items = self._deviceList.selectedItems()
     if not items:
         return
     dev = devices.get(items[0].text(0))
     if not dialogs.runQuestion("Do you want to remove "
                                "'%s' device permanently?" % dev.name):
         return
     log.debug("Removing device: %s" % dev)
     self._updateConnectionState(False, dev)
     devices.remove(dev.name)
     self._removeDeviceItem(dev)
     log.info("Device removed: %s" % dev)
Exemple #5
0
 def testRemove(self):
     devices.remove(_DEVICE_NAME)
     self.failIf(devices.get(_DEVICE_NAME))
 def testRemove(self):
     devices.remove(_DEVICE_NAME)
     self.failIf(devices.get(_DEVICE_NAME))