Example #1
0
    def __init__(self, secret=None, external=False):
        # locate the docs, so that the /docs url will point to the appropriate
        # docs, either for the current release or the current development build
        if is_dev_build():
            docpath = os.path.join(get_ancestor_dir(sys.executable, 3), 'docs',
                                   '_build', 'html')
        else:
            import openmdao.main
            docpath = os.path.join(os.path.dirname(openmdao.main.__file__), 'docs')

        handlers = [
            web.url(r'/',       web.RedirectHandler, {'url': '/projects', 'permanent': False}),
            web.url(r'/login',  LoginHandler),
            web.url(r'/logout', LogoutHandler),
            web.url(r'/exit',   ExitHandler),
            web.url(r'/docs/plugins/(.*)', PluginDocsHandler, {'route': '/docs/plugins/'}),
            web.url(r'/docs/(.*)', web.StaticFileHandler, {'path': docpath, 'default_filename': 'index.html'}),
        ]
        handlers.extend(proj.handlers)
        handlers.extend(wksp.handlers)

        if secret is None:
            secret = os.urandom(1024)

        app_path     = os.path.dirname(os.path.abspath(__file__))
        app_settings = {
            'login_url':         '/login',
            'static_path':       os.path.join(app_path, 'static'),
            'template_path':     os.path.join(app_path, 'templates'),
            'cookie_secret':     secret,
            'debug':             True,
        }

        user_dir = get_user_dir()

        self.project_dir = os.path.join(user_dir, 'projects')
        ensure_dir(self.project_dir)

        session_dir = os.path.join(user_dir, 'sessions')
        ensure_dir(session_dir)

        self.session_manager = TornadoSessionManager(secret, session_dir)
        self.server_manager  = ZMQServerManager('openmdao.gui.consoleserver.ConsoleServer', external)

        # External termination normally only used during GUI testing.
        if sys.platform == 'win32':
            # Fake SIGTERM by polling for a .sigterm file.
            self._exit_requested = False
            self._poller = threading.Thread(target=self._sigterm_poller,
                                            name='SIGTERM poller')
            self._poller.daemon = True
            self._poller.start()
        else:
            signal.signal(signal.SIGTERM, self._sigterm_handler)

        super(App, self).__init__(handlers, **app_settings)
    def __init__(self, secret=None):
        # locate the docs, so that the /docs url will point to the appropriate
        # docs, either for the current release or the current development build
        if is_dev_build():
            idxpath = os.path.join(get_ancestor_dir(sys.executable, 3), 'docs',
                                   '_build', 'html')
            doc_handler = web.StaticFileHandler
            doc_handler_options = { 'path': idxpath, 'default_filename': 'index.html' }
        else:
            # look for docs online
            import openmdao.util.releaseinfo
            version = openmdao.util.releaseinfo.__version__
            idxpath = 'http://openmdao.org/releases/%s/docs/index.html' % version
            doc_handler = web.RedirectHandler
            doc_handler_options = { 'url': idxpath, 'permanent': False }
            
        handlers = [
            web.url(r'/login',  LoginHandler),
            web.url(r'/logout', LogoutHandler),
            web.url(r'/exit',   ExitHandler),
            web.url(r'/docs/plugins/(.*)',  PluginDocsHandler, { 'route': '/docs/plugins/' }),
            web.url(r'/docs/(.*)',  doc_handler, doc_handler_options ),
            web.url(r'/',       web.RedirectHandler, { 'url':'/projects', 'permanent':False })
        ]
        handlers.extend(proj.handlers)
        handlers.extend(wksp.handlers)

        if secret is None:
            secret = os.urandom(1024)

        app_path     = os.path.dirname(os.path.abspath(__file__))
        app_settings = {
            'login_url':         '/login',
            'static_path':       os.path.join(app_path, 'static'),
            'template_path':     os.path.join(app_path, 'templates'),
            'cookie_secret':     secret,
            'debug':             True,
        }

        user_dir = get_user_dir()

        self.project_dir = os.path.join(user_dir, 'projects')
        ensure_dir(self.project_dir)

        session_dir = os.path.join(user_dir, 'sessions')
        ensure_dir(session_dir)

        self.session_manager = TornadoSessionManager(secret, session_dir)
        self.server_manager  = ZMQServerManager('openmdao.gui.consoleserver.ConsoleServer')

        global _MGR
        _MGR = self.server_manager
        signal.signal(signal.SIGTERM, self._sigterm_handler)
        super(App, self).__init__(handlers, **app_settings)
Example #3
0
    def __init__(self, secret=None):
        # locate the docs, so that the /docs url will point to the appropriate
        # docs, either for the current release or the current development build
        if is_dev_build():
            idxpath = os.path.join(get_ancestor_dir(sys.executable, 3), 'docs',
                                   '_build', 'html')
            doc_handler = web.StaticFileHandler
            doc_handler_options = { 'path': idxpath, 'default_filename': 'index.html' }
        else:
            # look for docs online
            import openmdao.util.releaseinfo
            version = openmdao.util.releaseinfo.__version__
            idxpath = 'http://openmdao.org/releases/%s/docs/index.html' % version
            doc_handler = web.RedirectHandler
            doc_handler_options = { 'url': idxpath, 'permanent': False }
            
        handlers = [
            web.url(r'/login',  LoginHandler),
            web.url(r'/logout', LogoutHandler),
            web.url(r'/exit',   ExitHandler),
            web.url(r'/docs/plugins/(.*)',  PluginDocsHandler, { 'route': '/docs/plugins/' }),
            web.url(r'/docs/(.*)',  doc_handler, doc_handler_options ),
            web.url(r'/',       web.RedirectHandler, { 'url':'/projects', 'permanent':False })
        ]
        handlers.extend(proj.handlers)
        handlers.extend(wksp.handlers)

        if secret is None:
            secret = os.urandom(1024)

        app_path     = os.path.dirname(os.path.abspath(__file__))
        app_settings = {
            'login_url':         '/login',
            'static_path':       os.path.join(app_path, 'static'),
            'template_path':     os.path.join(app_path, 'templates'),
            'cookie_secret':     secret,
            'debug':             True,
        }

        user_dir = get_user_dir()

        self.project_dir = os.path.join(user_dir, 'projects')
        ensure_dir(self.project_dir)

        session_dir = os.path.join(user_dir, 'sessions')
        ensure_dir(session_dir)

        self.session_manager = TornadoSessionManager(secret, session_dir)
        self.server_manager  = ZMQServerManager('openmdao.gui.consoleserver.ConsoleServer')

        super(App, self).__init__(handlers, **app_settings)
Example #4
0
    def __init__(self, secret=None, external=False):
        # locate the docs, so that the /docs url will point to the appropriate
        # docs, either for the current release or the current development build
        if is_dev_build():
            docpath = os.path.join(get_ancestor_dir(sys.executable, 3), 'docs',
                                   '_build', 'html')
        else:
            import openmdao.main
            docpath = os.path.join(os.path.dirname(openmdao.main.__file__),
                                   'docs')

        handlers = [
            web.url(r'/', web.RedirectHandler, {
                'url': '/projects',
                'permanent': False
            }),
            web.url(r'/login', LoginHandler),
            web.url(r'/logout', LogoutHandler),
            web.url(r'/exit', ExitHandler),
            web.url(r'/docs/plugins/(.*)', PluginDocsHandler,
                    {'route': '/docs/plugins/'}),
            web.url(r'/docs/(.*)', web.StaticFileHandler, {
                'path': docpath,
                'default_filename': 'index.html'
            })
        ]
        handlers.extend(proj.handlers)
        handlers.extend(wksp.handlers)

        if secret is None:
            secret = os.urandom(1024)

        app_path = os.path.dirname(os.path.abspath(__file__))
        app_settings = {
            'login_url': '/login',
            'static_path': os.path.join(app_path, 'static'),
            'template_path': os.path.join(app_path, 'templates'),
            'cookie_secret': secret,
            'debug': True,
        }

        user_dir = get_user_dir()

        self.project_dir = os.path.join(user_dir, 'projects')
        ensure_dir(self.project_dir)

        session_dir = os.path.join(user_dir, 'sessions')
        ensure_dir(session_dir)

        self.session_manager = TornadoSessionManager(secret, session_dir)
        self.server_manager = ZMQServerManager(
            'openmdao.gui.consoleserver.ConsoleServer', external)

        # External termination normally only used during GUI testing.
        if sys.platform == 'win32':
            # Fake SIGTERM by polling for a .sigterm file.
            self._exit_requested = False
            self._poller = threading.Thread(target=self._sigterm_poller,
                                            name='SIGTERM poller')
            self._poller.daemon = True
            self._poller.start()
        else:
            signal.signal(signal.SIGTERM, self._sigterm_handler)

        super(App, self).__init__(handlers, **app_settings)