当前位置: 首页>>代码示例>>Python>>正文


Python pydev_localhost.get_localhost函数代码示例

本文整理汇总了Python中pydev_localhost.get_localhost函数的典型用法代码示例。如果您正苦于以下问题:Python get_localhost函数的具体用法?Python get_localhost怎么用?Python get_localhost使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_localhost函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

 def run(self):
     class HandleRequestInput:
         def RequestInput(self):
             return 'RequestInput: OK'
     
     handle_request_input = HandleRequestInput()
     
     import pydev_localhost
     print('Starting client with:', pydev_localhost.get_localhost(), self.client_port)
     client_server = SimpleXMLRPCServer((pydev_localhost.get_localhost(), self.client_port), logRequests=False)
     client_server.register_function(handle_request_input.RequestInput)
     client_server.serve_forever()
开发者ID:AMOboxTV,项目名称:AMOBox.LegoBuild,代码行数:12,代码来源:check_pydevconsole.py

示例2: __init__

    def __init__(self, notifications_queue, port, daemon=False):
        threading.Thread.__init__(self)
        self.setDaemon(daemon) # If False, wait for all the notifications to be passed before exiting!
        self.finished = False
        self.notifications_queue = notifications_queue

        import pydev_localhost

        # It is necessary to specify an encoding, that matches
        # the encoding of all bytes-strings passed into an
        # XMLRPC call: "All 8-bit strings in the data structure are assumed to use the
        # packet encoding.  Unicode strings are automatically converted,
        # where necessary."
        # Byte strings most likely come from file names.
        encoding = file_system_encoding
        if encoding == "mbcs":
            # Windos symbolic name for the system encoding CP_ACP.
            # We need to convert it into a encoding that is recognized by Java.
            # Unfortunately this is not always possible. You could use
            # GetCPInfoEx and get a name similar to "windows-1251". Then
            # you need a table to translate on a best effort basis. Much to complicated.
            # ISO-8859-1 is good enough.
            encoding = "ISO-8859-1"

        self.server = xmlrpclib.Server('http://%s:%s' % (pydev_localhost.get_localhost(), port),
                                       encoding=encoding)
开发者ID:650elx,项目名称:middleware,代码行数:26,代码来源:pydev_runfiles_xml_rpc.py

示例3: testServer

    def testServer(self):
        client_port, server_port = self.getFreeAddresses()
        class ServerThread(threading.Thread):
            def __init__(self, client_port, server_port):
                threading.Thread.__init__(self)
                self.client_port = client_port
                self.server_port = server_port
                
            def run(self):
                import pydev_localhost
                pydevconsole.StartServer(pydev_localhost.get_localhost(), self.server_port, self.client_port)
        server_thread = ServerThread(client_port, server_port)
        server_thread.setDaemon(True)
        server_thread.start()

        client_thread = self.startClientThread(client_port) #@UnusedVariable
        
        import time
        time.sleep(.3) #let's give it some time to start the threads
        
        import pydev_localhost
        server = xmlrpclib.Server('http://%s:%s' % (pydev_localhost.get_localhost(), server_port))
        server.addExec('class Foo:')
        server.addExec('    pass')
        server.addExec('')
        server.addExec('foo = Foo()')
        server.addExec('a = %s()' % (raw_input_name,))
        server.addExec('print (a)')
        self.assertEqual(['input_request'], sys.stdout.getvalue().split())
开发者ID:MrGreen123,项目名称:Pydev,代码行数:29,代码来源:test_pydevconsole.py

示例4: connectToDebugger

    def connectToDebugger(self, debuggerPort):
        """
        Used to show console with variables connection.
        Mainly, monkey-patches things in the debugger structure so that the debugger protocol works.
        """
        try:
            # Try to import the packages needed to attach the debugger
            import pydevd
            import pydevd_vars
            import threading
        except:
            # This happens on Jython embedded in host eclipse
            import traceback

            traceback.print_exc()
            return ("pydevd is not available, cannot connect",)

        import pydev_localhost

        threading.currentThread().__pydevd_id__ = "console_main"

        pydevd_vars.findFrame = self._findFrame

        self.debugger = pydevd.PyDB()
        try:
            self.debugger.connect(pydev_localhost.get_localhost(), debuggerPort)
        except:
            import traceback

            traceback.print_exc()
            return "Failed to connect to target debugger."
        return ("connect complete",)
开发者ID:MyDreamMyWay,项目名称:HBuilder-opensource,代码行数:32,代码来源:pydev_console_utils.py

示例5: __init__

    def __init__(self, tests_queue):
        threading.Thread.__init__(self)
        self.setDaemon(True)
        self.queue = tests_queue
        self.finished = False
        from pydev_imports import SimpleXMLRPCServer
        
        
        # This is a hack to patch slow socket.getfqdn calls that
        # BaseHTTPServer (and its subclasses) make.
        # See: http://bugs.python.org/issue6085
        # See: http://www.answermysearches.com/xmlrpc-server-slow-in-python-how-to-fix/2140/
        try:
            import BaseHTTPServer
            def _bare_address_string(self):
                host, port = self.client_address[:2]
                return '%s' % host
            BaseHTTPServer.BaseHTTPRequestHandler.address_string = _bare_address_string
            
        except:
            pass
        # End hack.


        # Create server
        
        import pydev_localhost
        server = SimpleXMLRPCServer((pydev_localhost.get_localhost(), 0), logRequests=False)
        server.register_function(self.GetTestsToRun)
        server.register_function(self.notifyStartTest)
        server.register_function(self.notifyTest)
        server.register_function(self.notifyCommands)
        self.port = server.socket.getsockname()[1]
        self.server = server
开发者ID:Naviacom,项目名称:Configurations,代码行数:34,代码来源:pydev_runfiles_parallel.py

示例6: testServer

    def testServer(self):
        client_port, server_port = self.getFreeAddresses()

        class ServerThread(threading.Thread):
            def __init__(self, client_port, server_port):
                threading.Thread.__init__(self)
                self.client_port = client_port
                self.server_port = server_port

            def run(self):
                import pydev_localhost

                print('Starting server with:', pydev_localhost.get_localhost(), self.server_port, self.client_port)
                pydevconsole.StartServer(pydev_localhost.get_localhost(), self.server_port, self.client_port)

        server_thread = ServerThread(client_port, server_port)
        server_thread.setDaemon(True)
        server_thread.start()

        client_thread = self.startClientThread(client_port)  #@UnusedVariable

        import time

        time.sleep(.3)  #let's give it some time to start the threads

        import pydev_localhost

        server = xmlrpclib.Server('http://%s:%s' % (pydev_localhost.get_localhost(), server_port))
        server.addExec("import sys; print('Running with: %s %s' % (sys.executable or sys.platform, sys.version))")
        server.addExec('class Foo:')
        server.addExec('    pass')
        server.addExec('')
        server.addExec('foo = Foo()')
        server.addExec('a = %s()' % raw_input_name)
        server.addExec('print (a)')
开发者ID:32bitfloat,项目名称:intellij-community,代码行数:35,代码来源:check_pydevconsole.py

示例7: do_connect_to_debugger

        def do_connect_to_debugger():
            try:
                # Try to import the packages needed to attach the debugger
                import pydevd
                import _pydev_threading as threading

            except:
                # This happens on Jython embedded in host eclipse
                traceback.print_exc()
                sys.stderr.write('pydevd is not available, cannot connect\n',)

            import pydev_localhost
            threading.currentThread().__pydevd_id__ = "console_main"

            self.orig_findFrame = pydevd_vars.findFrame
            pydevd_vars.findFrame = self._findFrame

            self.debugger = pydevd.PyDB()
            try:
                self.debugger.connect(pydev_localhost.get_localhost(), debuggerPort)
                self.debugger.prepareToRun()
                import pydevd_tracing
                pydevd_tracing.SetTrace(None)
            except:
                traceback.print_exc()
                sys.stderr.write('Failed to connect to target debugger.\n')

            # Register to process commands when idle
            self.debugrunning = False
            try:
                import pydevconsole
                pydevconsole.set_debug_hook(self.debugger.processInternalCommands)
            except:
                traceback.print_exc()
                sys.stderr.write('Version of Python does not support debuggable Interactive Console.\n')
开发者ID:ArcherSys,项目名称:DevRake,代码行数:35,代码来源:pydev_console_utils.py

示例8: testServer

    def testServer(self):
        # Just making sure that the singleton is created in this thread.
        try:
            from pydev_ipython_console_011 import get_pydev_frontend
        except:
            sys.stderr.write('Skipped test because IPython could not be imported.')
            return
        get_pydev_frontend(get_localhost(), 0)

        client_port, server_port = self.getFreeAddresses()
        class ServerThread(threading.Thread):
            def __init__(self, client_port, server_port):
                threading.Thread.__init__(self)
                self.client_port = client_port
                self.server_port = server_port

            def run(self):
                import pydev_localhost
                print('Starting server with:', pydev_localhost.get_localhost(), self.server_port, self.client_port)
                pydevconsole.StartServer(pydev_localhost.get_localhost(), self.server_port, self.client_port)
        server_thread = ServerThread(client_port, server_port)
        server_thread.setDaemon(True)
        server_thread.start()

        client_thread = self.startClientThread(client_port) #@UnusedVariable

        try:
            import time
            time.sleep(.3) #let's give it some time to start the threads

            import pydev_localhost
            server = xmlrpclib.Server('http://%s:%s' % (pydev_localhost.get_localhost(), server_port))
            server.execLine("import sys; print('Running with: %s %s' % (sys.executable or sys.platform, sys.version))")
            server.execLine('class Foo:')
            server.execLine('    pass')
            server.execLine('')
            server.execLine('foo = Foo()')
            server.execLine('a = %s()' % raw_input_name)
            initial = time.time()
            while not client_thread.requested_input:
                if time.time() - initial > 2:
                    raise AssertionError('Did not get the return asked before the timeout.')
                time.sleep(.1)
            frame_xml = server.getFrame()
            self.assert_('RequestInput' in frame_xml, 'Did not fid RequestInput in:\n%s' % (frame_xml,))
        finally:
            client_thread.shutdown()
开发者ID:650elx,项目名称:middleware,代码行数:47,代码来源:test_check_pydevconsole.py

示例9: __init__

 def __init__(self, notifications_queue, port):
     threading.Thread.__init__(self)
     self.setDaemon(False) #Wait for all the notifications to be passed before exiting!
     self.finished = False
     self.notifications_queue = notifications_queue
     
     import pydev_localhost
     self.server = xmlrpclib.Server('http://%s:%s' % (pydev_localhost.get_localhost(), port))
开发者ID:iswar,项目名称:Pydev,代码行数:8,代码来源:pydev_runfiles_xml_rpc.py

示例10: setUp

 def setUp(self):
     # PyDevFrontEnd depends on singleton in IPython, so you
     # can't make multiple versions. So we reuse self.front_end for
     # all the tests
     self.front_end = get_pydev_frontend(get_localhost(), 0)
     
     from pydev_ipython.inputhook import set_return_control_callback
     set_return_control_callback(lambda:True)
     self.front_end.clearBuffer()
开发者ID:32bitfloat,项目名称:intellij-community,代码行数:9,代码来源:test_pydev_ipython_011.py

示例11: run_client

def run_client(job_id, port, verbosity, coverage_output_file, coverage_include):
    job_id = int(job_id)
    
    import pydev_localhost
    server = xmlrpclib.Server('http://%s:%s' % (pydev_localhost.get_localhost(), port))
    server.lock = threading.Lock()

    
    server_comm = ServerComm(job_id, server)
    server_comm.start()
    
    try:
        server_facade = ServerFacade(server_comm.notifications_queue)
        import pydev_runfiles
        import pydev_runfiles_xml_rpc
        pydev_runfiles_xml_rpc.SetServer(server_facade)
        
        tests_to_run = [1]
        while tests_to_run:
            #Investigate: is it dangerous to use the same xmlrpclib server from different threads?
            #It seems it should be, as it creates a new connection for each request...
            server.lock.acquire()
            try:
                tests_to_run = server.GetTestsToRun(job_id)
            finally:
                server.lock.release()
            
            if not tests_to_run:
                break
            
            files_to_tests = {}
            for test in tests_to_run:
                filename_and_test = test.split('|')
                if len(filename_and_test) == 2:
                    files_to_tests.setdefault(filename_and_test[0], []).append(filename_and_test[1])
    
            configuration = pydev_runfiles.Configuration(
                '', 
                verbosity, 
                None, 
                None, 
                None, 
                files_to_tests, 
                1, 
                None, 
                coverage_output_file=coverage_output_file, 
                coverage_include=coverage_include, 
            )
            test_runner = pydev_runfiles.PydevTestRunner(configuration)
            sys.stdout.flush()
            test_runner.run_tests()
        
    except:
        traceback.print_exc()
    server_comm.notifications_queue.put_nowait(KillServer())
开发者ID:iswar,项目名称:Pydev,代码行数:55,代码来源:pydev_runfiles_parallel_client.py

示例12: testConsoleHello

    def testConsoleHello(self):
        client_port, _server_port = self.getFreeAddresses()
        client_thread = self.startClientThread(client_port) #@UnusedVariable
        import time
        time.sleep(.3) #let's give it some time to start the threads
        
        import pydev_localhost
        interpreter = pydevconsole.InterpreterInterface(pydev_localhost.get_localhost(), client_port)

        (result,) = interpreter.hello("Hello pydevconsole")
        self.assertEqual(result, "Hello eclipse")      
开发者ID:Acidburn0zzz,项目名称:kali-2,代码行数:11,代码来源:test_pydevconsole.py

示例13: run

                def run(self):
                    class HandleRequestInput:
                        def RequestInput(self):
                            called_RequestInput[0] = True
                            return '\n'
                        def OpenEditor(self, name, line):
                            called_OpenEditor[0] = (name, line)
                            return True

                    handle_request_input = HandleRequestInput()

                    import pydev_localhost
                    client_server = SimpleXMLRPCServer((pydev_localhost.get_localhost(), self.client_port), logRequests=False)
                    client_server.register_function(handle_request_input.RequestInput)
                    client_server.register_function(handle_request_input.OpenEditor)
                    client_server.serve_forever()
开发者ID:AMOboxTV,项目名称:AMOBox.LegoBuild,代码行数:16,代码来源:test_pydev_ipython_011.py

示例14: run

 def run(self):
     class HandleRequestInput:
         def RequestInput(self):
             client_thread.requested_input = True
             return 'RequestInput: OK'
         
         def NotifyFinished(self, *args, **kwargs):
             client_thread.notified_finished += 1
             return 1
     
     handle_request_input = HandleRequestInput()
     
     import pydev_localhost
     self.client_server = client_server = SimpleXMLRPCServer((pydev_localhost.get_localhost(), self.client_port), logRequests=False)
     client_server.register_function(handle_request_input.RequestInput)
     client_server.register_function(handle_request_input.NotifyFinished)
     client_server.serve_forever()
开发者ID:Naviacom,项目名称:Configurations,代码行数:17,代码来源:test_check_pydevconsole.py

示例15: testConsoleHello

 def testConsoleHello(self):
     self.original_stdout = sys.stdout
     sys.stdout = StringIO()
     
     try:
         client_port, _server_port = self.getFreeAddresses()
         client_thread = self.startClientThread(client_port)  #@UnusedVariable
         import time
         time.sleep(.3)  #let's give it some time to start the threads
 
         import pydev_localhost
         interpreter = pydevconsole.InterpreterInterface(pydev_localhost.get_localhost(), client_port, threading.currentThread())
 
         (result,) = interpreter.hello("Hello pydevconsole")
         self.assertEqual(result, "Hello eclipse")
     finally:
         sys.stdout = self.original_stdout
开发者ID:32bitfloat,项目名称:intellij-community,代码行数:17,代码来源:test_pydevconsole.py


注:本文中的pydev_localhost.get_localhost函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。