Exemplo n.º 1
0
def set_up_server(remote_base_path):
    # choosing free port
    s = socket.socket()
    s.bind(('', 0))
    ip, port = s.getsockname()
    s.close()
    del s
    print("Chosen URL is http://%s:%s/" % (ip, port))
    # setting up the server.
    server = wsgiserver.CherryPyWSGIServer(
        (ip, port), ges.assemble_ges_app(remote_base_path))
    ip = 'localhost'  # the IP the socket yields is '0.0.0.0' which is not useful for testing.
    return ip, port, server
Exemplo n.º 2
0
def set_up_server(remote_base_path):
    # choosing free port
    s = socket.socket()
    s.bind(('',0))
    ip, port = s.getsockname()
    s.close()
    del s
    print("Chosen URL is http://%s:%s/" % (ip, port))
    # setting up the server.
    server = wsgiserver.CherryPyWSGIServer(
        (ip, port),
        ges.assemble_ges_app(remote_base_path)
        )
    ip = 'localhost' # the IP the socket yields is '0.0.0.0' which is not useful for testing.
    return ip, port, server
Exemplo n.º 3
0
    def SvcDoRun(self):

        # first, let's make sure the folder with our code is visible.
        try:
            code_folder_path = os.path.split(__file__)[0]
        except:
            raise Exception("G.E.S: Cannot determine what folder the code is located in")
        
        if code_folder_path not in sys.path:
            sys.path.append(code_folder_path)

        if not os.path.isfile(
                    os.path.join(
                        code_folder_path,
                        'static',
                        'favicon.ico'
                        )):
            raise Exception('G.E.S.: Cannot find static content in directory "%s".' % code_folder_path)

        # now that we are reasonably sure our code is visible, let's import
        import ges
        import wsgiserver

        app = ges.assemble_ges_app(
            content_path = self._content_path,
            uri_marker = self._uri_marker,
            static_content_path = os.path.join(code_folder_path, 'static')
        )
        self._server_instance = wsgiserver.CherryPyWSGIServer(
                (self._server_ip, self._server_port),
                app
            )
        try:
            self._server_instance.start()
        except KeyboardInterrupt:
            # i know this will never happen. That's the point.
            # all other exceptions will bubble up, somewhere... i hope...
            pass
        finally:
            self._server_instance.stop()
Exemplo n.º 4
0
    def SvcDoRun(self):

        # first, let's make sure the folder with our code is visible.
        try:
            code_folder_path = os.path.split(__file__)[0]
        except:
            raise Exception(
                "G.E.S: Cannot determine what folder the code is located in")

        if code_folder_path not in sys.path:
            sys.path.append(code_folder_path)

        if not os.path.isfile(
                os.path.join(code_folder_path, 'static', 'favicon.ico')):
            raise Exception(
                'G.E.S.: Cannot find static content in directory "%s".' %
                code_folder_path)

        # now that we are reasonably sure our code is visible, let's import
        import ges
        import wsgiserver

        app = ges.assemble_ges_app(content_path=self._content_path,
                                   uri_marker=self._uri_marker,
                                   static_content_path=os.path.join(
                                       code_folder_path, 'static'))
        self._server_instance = wsgiserver.CherryPyWSGIServer(
            (self._server_ip, self._server_port), app)
        try:
            self._server_instance.start()
        except KeyboardInterrupt:
            # i know this will never happen. That's the point.
            # all other exceptions will bubble up, somewhere... i hope...
            pass
        finally:
            self._server_instance.stop()