def _delBroker(self, broker):
        if self._layerManager.brokerInUse(broker.id()):
            Log.alert("A layer is currently using this broker. Please remove this first!")
            return

        if not Log.confirm("Are you sure you want to delete the broker " + broker.name() + "?"):
            return
        broker.deletingBroker.emit()
        self._brokers.delete(broker)
        self._brokers.sync()
        self._buildBrokerTable()
 def _on_test(self, client, status = True, msg = None):
     if self.connectTest.isEnabled():
         return # ignore duplicate responses
     
     self.connectTest.setEnabled(True)
     self.setTested(status)
     
     Log.progressPop("Testing Connection")
     if not status:
         Log.alert("Connection test failed\n\n" + str(msg))
     else:
         Log.alert("MQTT Connection successful")
         
     client.kill();
    def _on_test(self, client, status=True, msg=None):
        if self.connectTest.isEnabled():
            return  # ignore duplicate responses

        self.connectTest.setEnabled(True)
        self.setTested(status)

        Log.progressPop("Testing Connection")
        if not status:
            Log.alert("Connection test failed\n\n" + str(msg))
        else:
            Log.alert("MQTT Connection successful")

        client.kill()
    def getTopicManager(broker, create=False):
        try:
            if not create and broker.id() in tlTopicManagerFactory.classObjects:
                return tlTopicManagerFactory.classObjects[broker.id()]

            _class = tlTopicManagerFactory.getTopicManagerById(broker.topicManager())
            if not _class:
                Log.alert("Error loading topic manager " + str(broker.id()))
                return None

            tlTopicManagerFactory.classObjects[broker.id()] = _class(broker, create)
            return tlTopicManagerFactory.classObjects[broker.id()]
        except Exception as e:
            Log.progress("Unable to load topic manager from " + str(broker.topicManager()) + " " + str(e))
            exc_type, exc_value, exc_traceback = sys.exc_info()
            Log.debug(repr(traceback.format_exception(exc_type, exc_value,
                                                      exc_traceback)))

            return None
    def brokersLoaded(self, changed=[]):
        remove = []
        for  tLayer in self.getTLayers().itervalues():
            old_broker = tLayer.getBroker()
            broker = Brokers.instance().find(old_broker.id())
            if broker is None:
                remove.append(tLayer.layer())
                continue
            tLayer.setBroker(broker)

        if len(remove) > 0:
            Log.alert("Broker Not found - Removing associated layers!")
            for layer in remove:
                tLayer.kill()
                self.removeLayer(tLayer.layer(), False)

        self.rebuildLegend()
        for lid, tLayer in self.getTLayers().iteritems():
            if tLayer.isRunning() and tLayer.getBroker().id() in changed:
                Log.debug("Restarting  " + tLayer.getBroker().name())
                tLayer.restart()
Exemple #6
0
    def brokersLoaded(self, changed=[]):
        remove = []
        for tLayer in self.getTLayers().itervalues():
            old_broker = tLayer.getBroker()
            broker = Brokers.instance().find(old_broker.id())
            if broker is None:
                remove.append(tLayer.layer())
                continue
            tLayer.setBroker(broker)

        if len(remove) > 0:
            Log.alert("Broker Not found - Removing associated layers!")
            for layer in remove:
                tLayer.kill()
                self.removeLayer(tLayer.layer(), False)

        self.rebuildLegend()
        for lid, tLayer in self.getTLayers().iteritems():
            if tLayer.isRunning() and tLayer.getBroker().id() in changed:
                Log.debug("Restarting  " + tLayer.getBroker().name())
                tLayer.restart()
    def validate(self):
        if len(self.getName()) == 0:
            Log.alert("Please supply a name for this broker")
            return False


        if not Brokers.instance().uniqName(self._broker.id(), self.getName()):
            Log.alert("A broker named " + self.getName() + " already exists")
            return False
        

        if len(self.getHost()) == 0:
            Log.alert("Please supply a hostname")
            return False

        if self.getUseAltConnect() and len(self.getHostAlt()) == 0:
            Log.alert("Please supply a hostname (alt)")
            return False

        if self.getPort() is None:
            Log.alert("Please specify a port")
            return False

        if self.getUseAltConnect() and self.getPortAlt() is None:
            Log.alert("Please supply a port (alt)")
            return False

        return True
    def validate(self):
        if len(self.getName()) == 0:
            Log.alert("Please supply a name for this broker")
            return False

        if not Brokers.instance().uniqName(self._broker.id(), self.getName()):
            Log.alert("A broker named " + self.getName() + " already exists")
            return False

        if len(self.getHost()) == 0:
            Log.alert("Please supply a hostname")
            return False

        if self.getUseAltConnect() and len(self.getHostAlt()) == 0:
            Log.alert("Please supply a hostname (alt)")
            return False

        if self.getPort() is None:
            Log.alert("Please specify a port")
            return False

        if self.getUseAltConnect() and self.getPortAlt() is None:
            Log.alert("Please supply a port (alt)")
            return False

        return True