def pyclbr_epc_server(address, port): from sexpdata import return_as import epc.server cb = CodeBrowser() server = epc.server.EPCServer((address, port)) server.register_function(return_as(list)(cb.get_descriptions)) server.print_port() server.serve_forever()
def codethumb_epc_server(address, port): import epc.server codethumb = CodeThumb() server = epc.server.EPCServer((address, port)) server.register_function(codethumb.make_thumb) server.register_function(codethumb.set_font_name) server.print_port() server.serve_forever()
def jedi_epc_server(address='localhost', port=0, port_file=sys.stdout, sys_path=[], virtual_env=[], debugger=None, log=None, log_level=None, log_traceback=None): print "starting the jedi server!!!!!" add_virtualenv_path() for p in virtual_env: add_virtualenv_path(p) sys_path = map(os.path.expandvars, map(os.path.expanduser, sys_path)) sys.path = [''] + list(filter(None, itertools.chain(sys_path, sys.path))) # Workaround Jedi's module cache. Use this workaround until Jedi # got an API to set module paths. # See also: https://github.com/davidhalter/jedi/issues/36 import_jedi() import epc.server server = epc.server.EPCServer((address, port)) server.register_function(complete) server.register_function(get_in_function_call) server.register_function(goto) server.register_function(related_names) server.register_function(get_definition) server.register_function(defined_names) server.register_function(get_jedi_version) @server.register_function def toggle_log_traceback(): server.log_traceback = not server.log_traceback return server.log_traceback port_file.write(str(server.server_address[1])) # needed for Emacs client port_file.write("\n") port_file.flush() if port_file is not sys.stdout: port_file.close() # This is not supported Python-EPC API, but I am using this for # backward compatibility for Python-EPC < 0.0.4. In the future, # it should be passed to the constructor. server.log_traceback = bool(log_traceback) if log: handler = logging.FileHandler(filename=log, mode='w') if log_level: log_level = getattr(logging, log_level.upper()) handler.setLevel(log_level) server.logger.setLevel(log_level) server.logger.addHandler(handler) if debugger: server.set_debugger(debugger) handler = logging.StreamHandler() handler.setLevel(logging.DEBUG) server.logger.addHandler(handler) server.logger.setLevel(logging.DEBUG) server.serve_forever() server.logger.info('exit') return server
def jedi_epc_server( address="localhost", port=0, port_file=sys.stdout, sys_path=[], virtual_env=[], debugger=None, log=None, log_level=None, ): add_virtualenv_path() for p in virtual_env: add_virtualenv_path(p) sys_path = map(os.path.expandvars, map(os.path.expanduser, sys_path)) sys.path = [""] + list(filter(None, itertools.chain(sys_path, sys.path))) # Workaround Jedi's module cache. Use this workaround until Jedi # got an API to set module paths. # See also: https://github.com/davidhalter/jedi/issues/36 import_jedi() import epc.server server = epc.server.EPCServer((address, port)) server.register_function(complete) server.register_function(get_in_function_call) server.register_function(goto) server.register_function(related_names) server.register_function(get_definition) server.register_function(defined_names) server.register_function(get_jedi_version) port_file.write(str(server.server_address[1])) # needed for Emacs client port_file.write("\n") port_file.flush() if port_file is not sys.stdout: port_file.close() if log: server.log_traceback = True handler = logging.FileHandler(filename=log, mode="w") if log_level: log_level = getattr(logging, log_level.upper()) handler.setLevel(log_level) server.logger.setLevel(log_level) server.logger.addHandler(handler) if debugger: server.set_debugger(debugger) handler = logging.StreamHandler() handler.setLevel(logging.DEBUG) server.logger.addHandler(handler) server.logger.setLevel(logging.DEBUG) server.serve_forever() server.logger.info("exit") return server
def jedi_epc_server(address='localhost', port=0, port_file=sys.stdout, sys_path=[], virtual_env=[], debugger=None, log=None, log_level=None): add_virtualenv_path() for p in virtual_env: add_virtualenv_path(p) sys_path = map(os.path.expandvars, map(os.path.expanduser, sys_path)) sys.path = [''] + list(filter(None, itertools.chain(sys_path, sys.path))) # Workaround Jedi's module cache. Use this workaround until Jedi # got an API to set module paths. # See also: https://github.com/davidhalter/jedi/issues/36 import_jedi() import epc.server server = epc.server.EPCServer((address, port)) server.register_function(complete) server.register_function(get_in_function_call) server.register_function(goto) server.register_function(related_names) server.register_function(get_definition) server.register_function(defined_names) server.register_function(get_jedi_version) port_file.write(str(server.server_address[1])) # needed for Emacs client port_file.write("\n") port_file.flush() if port_file is not sys.stdout: port_file.close() if log: server.log_traceback = True handler = logging.FileHandler(filename=log, mode='w') if log_level: log_level = getattr(logging, log_level.upper()) handler.setLevel(log_level) server.logger.setLevel(log_level) server.logger.addHandler(handler) if debugger: server.set_debugger(debugger) handler = logging.StreamHandler() handler.setLevel(logging.DEBUG) server.logger.addHandler(handler) server.logger.setLevel(logging.DEBUG) server.serve_forever() server.logger.info('exit') return server
def main(args=None): ns = parser.parse_args(args) ns_vars = vars(ns).copy() log_settings = LogSettings( log_file=ns_vars.pop('log'), log_level=ns_vars.pop('log_level'), log_rotate_max_size=ns_vars.pop('log_rotate_max_size'), log_rotate_max_count=ns_vars.pop('log_rotate_max_count'), ) configure_logging(log_settings) server = jedi_epc_server(**ns_vars) server.serve_forever() server.logger.info('exit')
def main(args=None): import argparse parser = argparse.ArgumentParser( formatter_class=argparse.RawTextHelpFormatter, description=__doc__) parser.add_argument('--address', default='localhost') parser.add_argument('--port', default=0, type=int) parser.add_argument('--port-file', '-f', default='-', type=argparse.FileType('wt'), help='file to write port on. default is stdout.') parser.add_argument('--sys-path', '-p', default=[], action='append', help='paths to be inserted at the top of `sys.path`.') parser.add_argument( '--virtual-env', '-v', default=[], action='append', help='paths to be used as if VIRTUAL_ENV is set to it.') parser.add_argument('--log', help='save server log to this file.') parser.add_argument('--log-level', choices=['CRITICAL', 'ERROR', 'WARN', 'INFO', 'DEBUG'], help='logging level for log file.') parser.add_argument('--log-traceback', action='store_true', default=False, help='Include traceback in logging output.') parser.add_argument('--pdb', dest='debugger', const='pdb', action='store_const', help='start pdb when error occurs.') parser.add_argument('--ipdb', dest='debugger', const='ipdb', action='store_const', help='start ipdb when error occurs.') ns = parser.parse_args(args) server = jedi_epc_server(**vars(ns)) server.serve_forever() server.logger.info('exit')
def main(args=None): import argparse parser = argparse.ArgumentParser( formatter_class=argparse.RawTextHelpFormatter, description=__doc__) parser.add_argument( '--address', default='localhost') parser.add_argument( '--port', default=0, type=int) parser.add_argument( '--port-file', '-f', default='-', type=argparse.FileType('wt'), help='file to write port on. default is stdout.') parser.add_argument( '--sys-path', '-p', default=[], action='append', help='paths to be inserted at the top of `sys.path`.') parser.add_argument( '--virtual-env', '-v', default=[], action='append', help='paths to be used as if VIRTUAL_ENV is set to it.') parser.add_argument( '--log', help='save server log to this file.') parser.add_argument( '--log-level', choices=['CRITICAL', 'ERROR', 'WARN', 'INFO', 'DEBUG'], help='logging level for log file.') parser.add_argument( '--log-traceback', action='store_true', default=False, help='Include traceback in logging output.') parser.add_argument( '--pdb', dest='debugger', const='pdb', action='store_const', help='start pdb when error occurs.') parser.add_argument( '--ipdb', dest='debugger', const='ipdb', action='store_const', help='start ipdb when error occurs.') ns = parser.parse_args(args) server = jedi_epc_server(**vars(ns)) server.serve_forever() server.logger.info('exit')
def fortpy_epc_server(address='localhost', port=0, port_file=sys.stdout, sys_path=[], virtual_env=[], debugger=None, log=None, log_level=None, log_traceback=None): add_virtualenv_path() for p in virtual_env: add_virtualenv_path(p) sys_path = map(os.path.expandvars, map(os.path.expanduser, sys_path)) sys.path = [''] + list(filter(None, itertools.chain(sys_path, sys.path))) import_fortpy() import epc.server server = epc.server.EPCServer((address, port)) server.register_function(complete) server.register_function(get_in_function_call) server.register_function(goto) server.register_function(related_names) server.register_function(get_definition) server.register_function(defined_names) server.register_function(get_fortpy_version) server.register_function(bracket_complete) server.register_function(reparse_module) @server.register_function def toggle_log_traceback(): server.log_traceback = not server.log_traceback return server.log_traceback port_file.write(str(server.server_address[1])) # needed for Emacs client port_file.write("\n") port_file.flush() if port_file is not sys.stdout: port_file.close() # This is not supported Python-EPC API, but I am using this for # backward compatibility for Python-EPC < 0.0.4. In the future, # it should be passed to the constructor. server.log_traceback = bool(log_traceback) if log: handler = logging.FileHandler(filename=log, mode='w') if log_level: log_level = getattr(logging, log_level.upper()) handler.setLevel(log_level) server.logger.setLevel(log_level) server.logger.addHandler(handler) if debugger: server.set_debugger(debugger) handler = logging.StreamHandler() handler.setLevel(logging.DEBUG) server.logger.addHandler(handler) server.logger.setLevel(logging.DEBUG) server.serve_forever() server.logger.info('exit') return server
def fortpy_epc_server( address="localhost", port=0, port_file=sys.stdout, sys_path=[], virtual_env=[], debugger=None, log=None, log_level=None, log_traceback=None, ): add_virtualenv_path() for p in virtual_env: add_virtualenv_path(p) sys_path = map(os.path.expandvars, map(os.path.expanduser, sys_path)) sys.path = [""] + list(filter(None, itertools.chain(sys_path, sys.path))) import_fortpy() import epc.server server = epc.server.EPCServer((address, port)) server.register_function(complete) server.register_function(get_in_function_call) server.register_function(goto) server.register_function(related_names) server.register_function(get_definition) server.register_function(defined_names) server.register_function(get_fortpy_version) server.register_function(bracket_complete) server.register_function(reparse_module) @server.register_function def toggle_log_traceback(): server.log_traceback = not server.log_traceback return server.log_traceback port_file.write(str(server.server_address[1])) # needed for Emacs client port_file.write("\n") port_file.flush() if port_file is not sys.stdout: port_file.close() # This is not supported Python-EPC API, but I am using this for # backward compatibility for Python-EPC < 0.0.4. In the future, # it should be passed to the constructor. server.log_traceback = bool(log_traceback) if log: handler = logging.FileHandler(filename=log, mode="w") if log_level: log_level = getattr(logging, log_level.upper()) handler.setLevel(log_level) server.logger.setLevel(log_level) server.logger.addHandler(handler) if debugger: server.set_debugger(debugger) handler = logging.StreamHandler() handler.setLevel(logging.DEBUG) server.logger.addHandler(handler) server.logger.setLevel(logging.DEBUG) server.serve_forever() server.logger.info("exit") return server