Beispiel #1
0
    def __init__(self,
                 adapterId=None,
                 catchSignals=True,
                 icemgr=None,
                 logLevel=logging.WARNING,
                 defaultTimeout=500,
                 auto_shutdown=False):
        """
        adapterID will be the Ice name of the adapter
        catchSginal will catch ctrl-C, this should only be done once per process.
        """
        self.auto_shutdown = auto_shutdown
        if not adapterId:
            adapterId = Ice.generateUUID()
        self.logger = logging.getLogger(self.__class__.__name__ + "::" +
                                        adapterId)
        if len(logging.root.handlers) == 0:  #dirty hack
            logging.basicConfig()
        self.logger.setLevel(logLevel)
        self._agents = []
        self._lock = Lock()
        if not icemgr:
            self.icemgr = icehms.IceManager(adapterId=adapterId,
                                            defaultTimeout=defaultTimeout,
                                            logLevel=logLevel)
            self.icemgr.init()
        else:
            self.icemgr = icemgr

        if catchSignals:
            #Handle Ctrl-C on windows and linux
            signal.signal(signal.SIGINT, self.shutdown)
            signal.signal(signal.SIGTERM, self.shutdown)
Beispiel #2
0
def clean_registry():
    try:
        imgr = icehms.IceManager()
        imgr.init()
        c = imgr.get_cleaner()
        c.clean()
    finally:
        imgr.shutdown()
Beispiel #3
0
def lsholons():
    mgr = icehms.IceManager()
    hs = []
    try:
        mgr.init()
        print("The following holons are registered:")
        holons = mgr.find_holons()
        for holon in holons:
            hs.append(holon.__str__())
    finally:
        mgr.shutdown()
    hs.sort()
    for holon in hs:
        print(holon)
Beispiel #4
0
def lstopics():
    mgr = icehms.IceManager()
    tps = []
    try:
        mgr.init()
        topics = mgr.get_all_topics()
        print("\nTopics are: \n")
        for name, prx in topics.items():
            tps.append(name)
    finally:
        mgr.shutdown()
    tps.sort()
    for name in tps:
        print(name)
Beispiel #5
0
    def clean_adapters(self):
        self.logger.debug("Start cleaning adapters")
        ids = self.mgr.get_admin().getAllAdapterIds()
        self.logger.debug("Found adapters: %s", ids)
        if not ids:
            self.logger.info("No dead adapter found in registry")
        for Id in ids:
            if re.match(".*\.[Publish,TopicManager].*", Id):
                self.logger.debug(
                    "%s seems to be part of an IceStorm server...skipping...",
                    Id)
            else:
                self.logger.info("Removing adapter: %s", Id)
                self.mgr.get_admin().removeAdapter(Id)

    def clean(self):
        self.clean_topics()
        self.clean_holons()
        self.clean_adapters()


if __name__ == "__main__":
    import icehms
    try:
        imgr = icehms.IceManager()
        imgr.init()
        c = imgr.get_cleaner()
        c.clean()
    finally:
        imgr.shutdown()