Пример #1
0
    def _startSystem (self, options):
        
        try:
            self.sysconfig = SystemConfig.fromFile(options.config)
            self.localManager = Manager(self.sysconfig.chimera["host"], getattr(options, 'port', 9000))
            self._remoteManager = ManagerLocator.locate(self.sysconfig.chimera["host"], self.sysconfig.chimera["port"])
        except ManagerNotFoundException:
            # FIXME: better way to start Chimera
            site = SiteController(wait=False)
            site.startup()

            self._keepRemoteManager = False
            self._remoteManager = ManagerLocator.locate(self.sysconfig.chimera["host"], self.sysconfig.chimera["port"])
Пример #2
0
    def _startSystem(self, options):

        try:
            self.sysconfig = SystemConfig.fromFile(options.config)
            self.localManager = Manager(self.sysconfig.chimera["host"],
                                        getattr(options, 'port', 9000))
            self._remoteManager = ManagerLocator.locate(
                self.sysconfig.chimera["host"], self.sysconfig.chimera["port"])
        except ManagerNotFoundException:
            # FIXME: better way to start Chimera
            site = SiteController(wait=False)
            site.startup()

            self._keepRemoteManager = False
            self._remoteManager = ManagerLocator.locate(
                self.sysconfig.chimera["host"], self.sysconfig.chimera["port"])
Пример #3
0
    def __init__(self, host=None, port=None, local=False):
        RemoteObject.__init__(self)

        log.info("Starting manager.")

        self.resources = ResourcesManager()
        self.classLoader = ClassLoader()

        # identity
        self.setGUID(MANAGER_LOCATION)

        # shutdown event
        self.died = threading.Event()

        if not local:
            try:
                ManagerLocator.locate()
                raise ChimeraException("Chimera is already running"
                                       " on this system. Use chimera-admin"
                                       " to manage it.")
            except ManagerNotFoundException:
                # ok, we are alone.
                pass

        # our daemon server
        self.adapter = ManagerAdapter(self, host, port)
        self.adapterThread = threading.Thread(target=self.adapter.requestLoop)
        self.adapterThread.setDaemon(True)
        self.adapterThread.start()

        # finder beacon
        if not local:
            self.beacon = ManagerBeacon(self)
            self.beaconThread = threading.Thread(target=self.beacon.run)
            self.beaconThread.setDaemon(True)
            self.beaconThread.start()
        else:
            self.beacon = None

        # register ourself
        self.resources.add(MANAGER_LOCATION, self,
                           getManagerURI(self.getHostname(), self.getPort()))

        # signals
        signal.signal(signal.SIGTERM, self._sighandler)
        signal.signal(signal.SIGINT, self._sighandler)
        atexit.register(self._sighandler)
Пример #4
0
class ChimeraGUI:

    def __init__(self):

        self.setupGUI()
        self.setupChimera()
        self.setupViews()

    def setupGUI(self):
        self.builder = gtk.Builder()
        self.builder.add_from_file(
            os.path.join(os.path.dirname(__file__), "chimera.xml"))

        self.mainWindow = self.builder.get_object("mainWindow")
        self.builder.connect_signals({"window_destroy": self.chimera_quit,
                                      "chimera_connect_handler": self.chimera_connect_handler,
                                      "chimera_quit_handler": self.chimera_quit})

        self.dock = gdl.Dock()
        self.dock_layout = gdl.DockLayout()

        if os.path.exists("chimera_gui_layout.xml"):
            self.dock_layout.load_from_file("chimera_gui_layout.xml")
            self.dock_layout.load_layout("_-default__")

        self.builder.get_object("main_area").pack_end(self.dock)

        self.mainWindow.set_default_size(640, 480)
        self.mainWindow.show_all()

    def chimera_quit(self, *arga, **kwargs):
        # self.dock_layout.save_to_file("chimera_gui_layout.xml")
        gtk.main_quit()

    def chimera_connect_handler(self, action):
        threading.Thread(target=self.showConnectDialog).start()

    def showConnectDialog(self):
        dialog = self.builder.get_object("chimera_connect_dialog")
        response = dialog.run()
        dialog.hide()
        dialog.destroy()

    def setupChimera(self):
        try:
            self.sysconfig = SystemConfig.fromFile(
                SYSTEM_CONFIG_DEFAULT_FILENAME)
        except IOError, e:
            logging.exception(e)
            logging.error(
                "There was a problem reading your configuration file. (%s)" % e)
            return False

        self.localManager = Manager(
            host=self.sysconfig.chimera["host"], port=9000)
        self.manager = ManagerLocator.locate(
            self.sysconfig.chimera["host"], self.sysconfig.chimera["port"])
Пример #5
0
    def _startSystem(self, options, needRemoteManager=True):

        self.localManager = Manager(getattr(options, 'host', 'localhost'),
                                    getattr(options, 'port', 9000),
                                    local=True)

        # if we need a remote Manager, check if it is up, if not, start it
        if needRemoteManager:
            try:
                self._remoteManager = ManagerLocator.locate()
                self._remoteManager.ping()

            except ManagerNotFoundException:

                # FIXME: better way to start Chimera
                site = SiteController(wait=False)
                site.startup()

                self._keepRemoteManager = False

                self._remoteManager = ManagerLocator.locate()
                self._remoteManager.ping()
Пример #6
0
    def test_locate(self):

        manager = Manager(host='localhost', port=9999)

        proxy = ManagerLocator.locate()
        assert proxy.ping() == True

        assert proxy.URI.address == gethostbyname("localhost")
        assert proxy.URI.port == 9999

        manager.shutdown()

        # where are you
        assert_raises(ManagerNotFoundException, ManagerLocator.locate)