示例#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)
示例#2
0
文件: devices.py 项目: mlyko/tadek-ui
 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)
示例#3
0
 def _addDevice(self):
     '''
     Runs the 'Add device' dialog.
     '''
     log.debug("Adding new device")
     dialog = DeviceConfigDialog()
     if not dialog.run():
         return
     connect = dialog.params.pop("connect", False)
     dev = devices.add(type=Device, **dialog.params)
     self._addDeviceItem(dev)
     log.info("New device added: %s" % dev)
     if connect:
         self._updateConnectionState(True, dev)
示例#4
0
文件: devices.py 项目: mlyko/tadek-ui
 def _addDevice(self):
     '''
     Runs the 'Add device' dialog.
     '''
     log.debug("Adding new device")
     dialog = DeviceConfigDialog()
     if not dialog.run():
         return
     connect = dialog.params.pop("connect", False)
     dev = devices.add(type=Device, **dialog.params)
     self._addDeviceItem(dev)
     log.info("New device added: %s" % dev)
     if connect:
         self._updateConnectionState(True, dev)
示例#5
0
 def testAdd(self):
     device = devices.add(_DEVICE_NAME, **_DEVICE_PARAS)
     self.failUnless(device)
     self.failUnlessEqual(device, devices.get(_DEVICE_NAME))
示例#6
0
 def testAdd(self):
     device = devices.add(_DEVICE_NAME, **_DEVICE_PARAS)
     self.failUnless(device)
     self.failUnlessEqual(device, devices.get(_DEVICE_NAME))