Пример #1
0
    def serve(top, context=None, wspub=None, wscmd=None, port=8888,
              rep_url='tcp://*:5555', pub_url='inproc://_pub_'):

        if context is None:
            context = zmq.Context()

        loop = ioloop.IOLoop.instance()
        ZmqCompWrapper(context, top, rep_url)

        # initialize the publisher
        from openmdao.main.publisher import Publisher
        Publisher.init(context, pub_url)

        if wspub or wscmd:
            from openmdao.main.zmqws import CmdWebSocketHandler, PubWebSocketHandler
            from tornado import web
            handlers = []
            if wspub:
                handlers.append((wspub, PubWebSocketHandler, {'context':context,
                                                              'pub_url':pub_url}))
            if wscmd:
                handlers.append((wscmd, CmdWebSocketHandler, {'context':context,
                                                              'rep_url':rep_url}))
            application = web.Application(handlers)
            application.listen(port)

        try:
            loop.start()
        except KeyboardInterrupt:
            print ' Interrupted'
Пример #2
0
    def serve(top, context=None, wspub=None, wscmd=None, port=8888,
              rep_url='tcp://*:5555', pub_url='inproc://_pub_'):

        if context is None:
            context = zmq.Context()

        loop = ioloop.IOLoop.instance()
        ZmqCompWrapper(context, top, rep_url)

        # initialize the publisher
        from openmdao.main.publisher import Publisher
        Publisher.init(context, pub_url)

        if wspub or wscmd:
            from openmdao.main.zmqws import CmdWebSocketHandler, PubWebSocketHandler
            from tornado import web
            handlers = []
            if wspub:
                handlers.append((wspub, PubWebSocketHandler, {'context': context,
                                                              'pub_url': pub_url}))
            if wscmd:
                handlers.append((wscmd, CmdWebSocketHandler, {'context': context,
                                                              'rep_url': rep_url}))
            application = web.Application(handlers)
            application.listen(port)

        try:
            loop.start()
        except KeyboardInterrupt:
            print ' Interrupted'
Пример #3
0
 def publish_files(self):
     ''' Publish the current file collection.
     '''
     if not self.publisher:
         try:
             self.publisher = Publisher.get_instance()
         except Exception, err:
             print 'Error getting publisher:', err
             self.publisher = None
Пример #4
0
 def publish_files(self):
     ''' Publish the current file collection.
     '''
     if not self.publisher:
         try:
             self.publisher = Publisher.get_instance()
         except Exception, err:
             print 'Error getting publisher:', err
             self.publisher = None
Пример #5
0
 def publish_updates(self, added_set, changed_set, deleted_set):
     publisher = Publisher.get_instance()
     if publisher:
         types = get_available_types()
         types.extend(self.get_available_types())
         publisher.publish('types', [
             packagedict(types),
             list(added_set),
             list(changed_set),
             list(deleted_set),
         ])
     else:
         logger.error("no Publisher found")
Пример #6
0
    def add_subscriber(self, pathname, publish):
        ''' Publish the specified topic.
        '''
        if pathname in [
                '', 'components', 'files', 'types', 'console_errors',
                'file_errors'
        ]:
            # these topics are published automatically
            return
        elif pathname == 'log_msgs':
            if publish:
                self._start_log_msgs(pathname)
            else:
                self._stop_log_msgs()
        elif pathname.startswith('/'):  # treat it as a filename
            if publish:
                Publisher.register(pathname, pathname[1:])
            else:
                Publisher.unregister(pathname)
        else:
            parts = pathname.split('.', 1)
            if len(parts) > 1:
                root = self.proj.get(parts[0])
                if root:
                    rest = parts[1]
                    root.register_published_vars(rest, publish)

            cont, root = self.get_object(pathname)
            if has_interface(cont, IComponent):
                if publish:
                    if pathname in self._publish_comps:
                        self._publish_comps[pathname] += 1
                    else:
                        self._publish_comps[pathname] = 1
                else:
                    if pathname in self._publish_comps:
                        self._publish_comps[pathname] -= 1
                        if self._publish_comps[pathname] < 1:
                            del self._publish_comps[pathname]
    def add_subscriber(self, pathname, publish):
        ''' Publish the specified topic.
        '''
        if pathname in ['', 'components', 'files', 'types',
                        'console_errors', 'file_errors']:
            # these topics are published automatically
            return
        elif pathname == 'log_msgs':
            if publish:
                self._start_log_msgs(pathname)
            else:
                self._stop_log_msgs()
        elif pathname.startswith('/'):  # treat it as a filename
            if publish:
                Publisher.register(pathname, pathname[1:])
            else:
                Publisher.unregister(pathname)
        else:
            parts = pathname.split('.', 1)
            if len(parts) > 1:
                root = self.proj.get(parts[0])
                if root:
                    rest = parts[1]
                    root.register_published_vars(rest, publish)

            cont, root = self.get_object(pathname)
            if has_interface(cont, IComponent):
                if publish:
                    if pathname in self._publish_comps:
                        self._publish_comps[pathname] += 1
                    else:
                        self._publish_comps[pathname] = 1
                else:
                    if pathname in self._publish_comps:
                        self._publish_comps[pathname] -= 1
                        if self._publish_comps[pathname] < 1:
                            del self._publish_comps[pathname]
Пример #8
0
 def load_project(self,filename):
     print 'loading project from:',filename
     self.projfile = filename
     self.proj = project_from_archive(filename,dest_dir=self.getcwd())
     self.proj.activate()
     Publisher.get_instance()