コード例 #1
0
ファイル: test_regression.py プロジェクト: hynekcer/jedi
    def test_function_definition_complex(self):
        check = self.assert_call_def

        s = """
                def abc(a,b):
                    pass

                def a(self):
                    abc(

                if 1:
                    pass
            """
        check(self.function_definition(s, (6, 24)), 'abc', 0)
        s = """
                import re
                def huhu(it):
                    re.compile(
                    return it * 2
            """
        check(self.function_definition(s, (4, 31)), 'compile', 0)
        # jedi-vim #70
        s = """def foo("""
        assert self.function_definition(s) is None
        jedi.set_debug_function(jedi.debug.print_to_stdout)
        # jedi-vim #116
        s = """import functools; test = getattr(functools, 'partial'); test("""
        check(self.function_definition(s), 'partial', 0)
        jedi.set_debug_function(None)
コード例 #2
0
ファイル: run.py プロジェクト: Waxolunist/vimconf
    def get_defs(correct, correct_start, path):
        def defs(line_nr, indent):
            script = jedi.Script(source, line_nr, indent, path)
            return set(script.get_definition())

        should_be = set()
        number = 0
        for index in re.finditer('(?: +|$)', correct):
            if correct == ' ':
                continue
            # -1 for the comment, +3 because of the comment start `#? `
            start = index.start()
            if base.print_debug:
                jedi.set_debug_function(None)
            number += 1
            try:
                should_be |= defs(line_nr - 1, start + correct_start)
            except Exception:
                print('could not resolve %s indent %s' % (line_nr - 1, start))
                raise
            if base.print_debug:
                jedi.set_debug_function(debug.print_to_stdout)
        # because the objects have different ids, `repr` it, then compare it.
        should_str = set(r.desc_with_module for r in should_be)
        if len(should_str) < number:
            raise Exception('Solution @%s not right, too few test results: %s'
                                                % (line_nr - 1, should_str))
        return should_str
コード例 #3
0
ファイル: sith.py プロジェクト: bstaint/jedi
def main(arguments):
    debugger = 'pdb' if arguments['--pdb'] else \
               'ipdb' if arguments['--ipdb'] else \
               'pudb' if arguments['--pudb'] else None
    record = arguments['--record']

    jedi.settings.use_filesystem_cache = arguments['--fs-cache']
    if arguments['--debug']:
        jedi.set_debug_function()

    if arguments['redo'] or arguments['show']:
        t = TestCase.from_cache(record)
        if arguments['show']:
            t.show_errors()
        else:
            t.run(debugger)
    elif arguments['run']:
            TestCase(
                arguments['<operation>'], arguments['<path>'],
                int(arguments['<line>']), int(arguments['<column>'])
            ).run(debugger, print_result=True)
    else:
        for _ in range(int(arguments['--maxtries'])):
            t = TestCase.generate(arguments['<path>'] or '.')
            if arguments['-s']:
                print('%s %s %s %s ' % (t.operation, t.path, t.line, t.column))
                sys.stdout.flush()
            else:
                print('.', end='')
            t.run(debugger, record)

            sys.stdout.flush()
        print()
コード例 #4
0
ファイル: jedibackend.py プロジェクト: xiaoxubeii/elpy
def run_with_debug(jedi, name, *args, **kwargs):
    re_raise = kwargs.pop('re_raise', ())
    # Remove form feed characters, they confuse Jedi (jedi#424)
    if 'source' in kwargs:
        kwargs['source'] = kwargs['source'].replace("\f", " ")
    try:
        script = jedi.Script(*args, **kwargs)
        return getattr(script, name)()
    except Exception as e:
        if isinstance(e, re_raise):
            raise
        # Bug jedi#417
        if isinstance(e, TypeError) and str(e) == 'no dicts allowed':
            return None
        # Bug jedi#427
        if isinstance(e, UnicodeDecodeError):
            return None
        # Bug jedi#429
        if isinstance(e, IndexError):
            return None

        from jedi import debug

        debug_info = []

        def _debug(level, str_out):
            if level == debug.NOTICE:
                prefix = "[N]"
            elif level == debug.WARNING:
                prefix = "[W]"
            else:
                prefix = "[?]"
            debug_info.append("{0} {1}".format(prefix, str_out))

        jedi.set_debug_function(_debug, speed=False)
        try:
            script = jedi.Script(*args, **kwargs)
            return getattr(script, name)()
        except Exception as e:
            source = kwargs.get('source')
            sc_args = []
            sc_args.extend(repr(arg) for arg in args)
            sc_args.extend("{0}={1}".format(k, "source" if k == "source"
                                            else repr(v))
                           for (k, v) in kwargs.items())

            data = {
                "traceback": traceback.format_exc(),
                "jedi_debug_info": {'script_args': ", ".join(sc_args),
                                    'source': source,
                                    'method': name,
                                    'debug_info': debug_info}
            }
            raise rpc.Fault(message=str(e),
                            code=500,
                            data=data)
        finally:
            jedi.set_debug_function(None)
コード例 #5
0
ファイル: jedibackend.py プロジェクト: aboutpcw/emacs.d
def run_with_debug(jedi, name, *args, **kwargs):
    re_raise = kwargs.pop('re_raise', ())
    try:
        script = jedi.Script(*args, **kwargs)
        return getattr(script, name)()
    except Exception as e:
        if isinstance(e, re_raise):
            raise
        # Bug jedi#485
        if (
                isinstance(e, ValueError) and
                "invalid \\x escape" in str(e)
        ):
            return None
        # Bug jedi#485 in Python 3
        if (
                isinstance(e, SyntaxError) and
                "truncated \\xXX escape" in str(e)
        ):
            return None

        from jedi import debug

        debug_info = []

        def _debug(level, str_out):
            if level == debug.NOTICE:
                prefix = "[N]"
            elif level == debug.WARNING:
                prefix = "[W]"
            else:
                prefix = "[?]"
            debug_info.append(u"{0} {1}".format(prefix, str_out))

        jedi.set_debug_function(_debug, speed=False)
        try:
            script = jedi.Script(*args, **kwargs)
            return getattr(script, name)()
        except Exception as e:
            source = kwargs.get('source')
            sc_args = []
            sc_args.extend(repr(arg) for arg in args)
            sc_args.extend("{0}={1}".format(k, "source" if k == "source"
                                            else repr(v))
                           for (k, v) in kwargs.items())

            data = {
                "traceback": traceback.format_exc(),
                "jedi_debug_info": {'script_args': ", ".join(sc_args),
                                    'source': source,
                                    'method': name,
                                    'debug_info': debug_info}
            }
            raise rpc.Fault(message=str(e),
                            code=500,
                            data=data)
        finally:
            jedi.set_debug_function(None)
コード例 #6
0
ファイル: jedibackend.py プロジェクト: scimacs/scimacs-elpa
def run_with_debug(jedi, name, *args, **kwargs):
    re_raise = kwargs.pop('re_raise', ())
    try:
        script = jedi.Script(*args, **kwargs)
        return getattr(script, name)()
    except Exception as e:
        if isinstance(e, re_raise):
            raise
        # Bug jedi#485
        if (
                isinstance(e, ValueError) and
                "invalid \\x escape" in str(e)
        ):
            return None
        # Bug jedi#485 in Python 3
        if (
                isinstance(e, SyntaxError) and
                "truncated \\xXX escape" in str(e)
        ):
            return None

        from jedi import debug

        debug_info = []

        def _debug(level, str_out):
            if level == debug.NOTICE:
                prefix = "[N]"
            elif level == debug.WARNING:
                prefix = "[W]"
            else:
                prefix = "[?]"
            debug_info.append(u"{0} {1}".format(prefix, str_out))

        jedi.set_debug_function(_debug, speed=False)
        try:
            script = jedi.Script(*args, **kwargs)
            return getattr(script, name)()
        except Exception as e:
            source = kwargs.get('source')
            sc_args = []
            sc_args.extend(repr(arg) for arg in args)
            sc_args.extend("{0}={1}".format(k, "source" if k == "source"
                                            else repr(v))
                           for (k, v) in kwargs.items())

            data = {
                "traceback": traceback.format_exc(),
                "jedi_debug_info": {'script_args': ", ".join(sc_args),
                                    'source': source,
                                    'method': name,
                                    'debug_info': debug_info}
            }
            raise rpc.Fault(message=str(e),
                            code=500,
                            data=data)
        finally:
            jedi.set_debug_function(None)
コード例 #7
0
def main(args):
    jedi.set_debug_function(notices=args['--debug'])
    with open(args['<file>']) as f:
        code = f.read()
    grammar = load_grammar()
    parser = ParserWithRecovery(grammar, u(code))

    code =  code + '\na\n'  # Add something so the diff parser needs to run.
    lines = splitlines(code, keepends=True)
    cProfile.runctx('run(parser, lines)', globals(), locals(), sort=args['-s'])
コード例 #8
0
def main(args):
    jedi.set_debug_function(notices=args['--debug'])
    with open(args['<file>']) as f:
        code = f.read()
    grammar = load_grammar()
    parser = ParserWithRecovery(grammar, u(code))

    code = code + '\na\n'  # Add something so the diff parser needs to run.
    lines = splitlines(code, keepends=True)
    cProfile.runctx('run(parser, lines)', globals(), locals(), sort=args['-s'])
コード例 #9
0
def main(args):
    code = args['<code>']
    n = int(args['-n'])
    for i in range(n):
        run(code, i)

    jedi.set_debug_function(notices=args['--debug'])
    if args['--omit']:
        run(code, n)
    else:
        cProfile.runctx('run(code, n)', globals(), locals(), sort=args['-s'])
コード例 #10
0
def main(args):
    code = args['<code>']
    n = int(args['-n'])
    for i in range(n):
        run(code, i)

    jedi.set_debug_function(notices=args['--debug'])
    if args['--omit']:
        run(code, n)
    else:
        cProfile.runctx('run(code, n)', globals(), locals(), sort=args['-s'])
コード例 #11
0
ファイル: conftest.py プロジェクト: ABob/vim
def pytest_configure(config):
    global jedi_cache_directory_orig, jedi_cache_directory_temp
    jedi_cache_directory_orig = jedi.settings.cache_directory
    jedi_cache_directory_temp = tempfile.mkdtemp(prefix='jedi-test-')
    jedi.settings.cache_directory = jedi_cache_directory_temp

    if config.option.jedi_debug:
        jedi.set_debug_function()

    if config.option.warning_is_error:
        import warnings
        warnings.simplefilter("error")
コード例 #12
0
ファイル: conftest.py プロジェクト: yongquanf/jedi
def pytest_configure(config):
    global jedi_cache_directory_orig, jedi_cache_directory_temp
    jedi_cache_directory_orig = jedi.settings.cache_directory
    jedi_cache_directory_temp = tempfile.mkdtemp(prefix='jedi-test-')
    jedi.settings.cache_directory = jedi_cache_directory_temp

    if config.option.jedi_debug:
        jedi.set_debug_function()

    if config.option.warning_is_error:
        import warnings
        warnings.simplefilter("error")
コード例 #13
0
ファイル: profile_output.py プロジェクト: huihui571/vim-light
def main(args):
    code = args['<code>']
    infer = args['--infer']
    n = int(args['-n'])

    for i in range(n):
        run(code, i, infer=infer)

    if args['--precision']:
        pstats.f8 = f8

    jedi.set_debug_function(notices=args['--debug'])
    if args['--omit']:
        run(code, n, infer=infer)
    else:
        profile.runctx('run(code, n, infer=infer)', globals(), locals(), sort=args['-s'])
コード例 #14
0
def _complete():
    import jedi
    import pdb

    if '-d' in sys.argv:
        sys.argv.remove('-d')
        jedi.set_debug_function()

    try:
        completions = jedi.Script(sys.argv[2]).complete()
        for c in completions:
            c.docstring()
            c.type
    except Exception as e:
        print(repr(e))
        pdb.post_mortem()
    else:
        print(completions)
コード例 #15
0
ファイル: snippet.py プロジェクト: szabo92/gistable
def transform(file_name, debug=False):
    """
    Takes a file name returns the transformed text.
    """
    if debug:
        jedi.set_debug_function()

    names = jedi.names(path=file_name, all_scopes=True)
    param_names = [p for p in names if p.type == 'param']
    for param in param_names:
        # This is all very complicated and basically should just be replaced
        # with param.goto_definition(), once that api is being added (it's
        # planned).
        e = param._evaluator
        jedi_obj = param._definition
        types = _eval_param(e, jedi_obj, jedi_obj.get_parent_scope())

        if types and param.name != 'self':
            # Now refactor, Jedi has a round-trippable parser, yay!
            annotation = types_to_string(types, abspath(file_name))
            jedi_obj.name.value += ': ' + annotation

    # Get the module and generate the code.
    return jedi_obj.get_parent_until().get_code()
コード例 #16
0
ファイル: __main__.py プロジェクト: BarnetteME1/DnD-stuff
def _start_linter():
    """
    This is a pre-alpha API. You're not supposed to use it at all, except for
    testing. It will very likely change.
    """
    import jedi

    if '--debug' in sys.argv:
        jedi.set_debug_function()

    for path in sys.argv[2:]:
        if path.startswith('--'):
            continue
        if isdir(path):
            import fnmatch
            import os

            paths = []
            for root, dirnames, filenames in os.walk(path):
                for filename in fnmatch.filter(filenames, '*.py'):
                    paths.append(os.path.join(root, filename))
        else:
            paths = [path]

        try:
            for path in paths:
                for error in jedi.Script(path=path)._analysis():
                    print(error)
        except Exception:
            if '--pdb' in sys.argv:
                import traceback
                traceback.print_exc()
                import pdb
                pdb.post_mortem()
            else:
                raise
コード例 #17
0
def _start_linter():
    """
    This is a pre-alpha API. You're not supposed to use it at all, except for
    testing. It will very likely change.
    """
    import jedi

    if '--debug' in sys.argv:
        jedi.set_debug_function()

    for path in sys.argv[2:]:
        if path.startswith('--'):
            continue
        if isdir(path):
            import fnmatch
            import os

            paths = []
            for root, dirnames, filenames in os.walk(path):
                for filename in fnmatch.filter(filenames, '*.py'):
                    paths.append(os.path.join(root, filename))
        else:
            paths = [path]

        try:
            for path in paths:
                for error in jedi.Script(path=path)._analysis():
                    print(error)
        except Exception:
            if '--pdb' in sys.argv:
                import traceback
                traceback.print_exc()
                import pdb
                pdb.post_mortem()
            else:
                raise
コード例 #18
0
def run_with_debug(jedi, name, *args, **kwargs):
    re_raise = kwargs.pop('re_raise', ())
    # Remove form feed characters, they confuse Jedi (jedi#424)
    if 'source' in kwargs:
        kwargs['source'] = kwargs['source'].replace("\f", " ")
    try:
        script = jedi.Script(*args, **kwargs)
        return getattr(script, name)()
    except Exception as e:
        if isinstance(e, re_raise):
            raise
        # Bug jedi#417
        if isinstance(e, TypeError) and str(e) == 'no dicts allowed':
            return None
        # Bug jedi#427
        if isinstance(e, UnicodeDecodeError):
            return None
        # Bug jedi#429
        if isinstance(e, IndexError):
            return None
        # Bug jedi#431
        if isinstance(e, AttributeError) and str(e).endswith("'end_pos'"):
            return None
        # Bug in Python 2.6, see #275
        if isinstance(e, OSError) and e.errno == 13:
            return None
        # Bug jedi#466
        if (isinstance(e, SyntaxError)
                and "EOL while scanning string literal" in str(e)):
            return None
        # Bug jedi#482
        if isinstance(e, UnicodeEncodeError):
            return None
        # Bug jedi#485
        if (isinstance(e, ValueError) and "invalid \\x escape" in str(e)):
            return None
        # Bug jedi#485 in Python 3
        if (isinstance(e, SyntaxError) and "truncated \\xXX escape" in str(e)):
            return None
        # Bug jedi#465
        if (isinstance(e, SyntaxError)
                and "encoding declaration in Unicode string" in str(e)):
            return None
        # Bug #337 / jedi#471
        if (isinstance(e, ImportError) and "No module named" in str(e)):
            return None
        # Bug #365 / jedi#486 - fixed in Jedi 0.8.2
        if (isinstance(e, UnboundLocalError)
                and "local variable 'path' referenced before assignment"
                in str(e)):
            return None
        # Bug #366 / jedi#491
        if (isinstance(e, ValueError) and "__loader__ is None" in str(e)):
            return None
        # Bug #353
        if (isinstance(e, OSError) and "No such file or directory" in str(e)):
            return None
        # Bug #561, #564, #570, #588, #593, #599 / jedi#572, jedi#579, jedi#590
        if isinstance(e, KeyError):
            return None
        # Bug #519 / jedi#610
        if (isinstance(e, RuntimeError)
                and "maximum recursion depth exceeded" in str(e)):
            return None
        # Bug #563 / jedi#589
        if (isinstance(e, AttributeError) and "MergedNamesDict" in str(e)):
            return None
        # Bug #615 / jedi#592
        if (isinstance(e, AttributeError) and "ListComprehension" in str(e)):
            return None
        # Bug #569 / jedi#593
        if (isinstance(e, AttributeError) and "names_dict" in str(e)):
            return None

        from jedi import debug

        debug_info = []

        def _debug(level, str_out):
            if level == debug.NOTICE:
                prefix = "[N]"
            elif level == debug.WARNING:
                prefix = "[W]"
            else:
                prefix = "[?]"
            debug_info.append(u"{0} {1}".format(prefix, str_out))

        jedi.set_debug_function(_debug, speed=False)
        try:
            script = jedi.Script(*args, **kwargs)
            return getattr(script, name)()
        except Exception as e:
            source = kwargs.get('source')
            sc_args = []
            sc_args.extend(repr(arg) for arg in args)
            sc_args.extend(
                "{0}={1}".format(k, "source" if k == "source" else repr(v))
                for (k, v) in kwargs.items())

            data = {
                "traceback": traceback.format_exc(),
                "jedi_debug_info": {
                    'script_args': ", ".join(sc_args),
                    'source': source,
                    'method': name,
                    'debug_info': debug_info
                }
            }
            raise rpc.Fault(message=str(e), code=500, data=data)
        finally:
            jedi.set_debug_function(None)
コード例 #19
0
ファイル: base.py プロジェクト: Waxolunist/vimconf
test_sum = 0
t_start = time.time()
# Sorry I didn't use argparse here. It's because argparse is not in the
# stdlib in 2.5.
args = sys.argv[1:]

print_debug = False
try:
    i = args.index('--debug')
    args = args[:i] + args[i + 1:]
except ValueError:
    pass
else:
    print_debug = True
    jedi.set_debug_function(debug.print_to_stdout)

sys.argv = sys.argv[:1] + args

summary = []
tests_fail = 0

def get_test_list():
# get test list, that should be executed
    test_files = {}
    last = None
    for arg in sys.argv[1:]:
        if arg.isdigit():
            if last is None:
                continue
            test_files[last].append(int(arg))
コード例 #20
0
ファイル: test_debug.py プロジェクト: ABob/vim
def test_simple():
    jedi.set_debug_function()
    debug.speed('foo')
    debug.dbg('bar')
    debug.warning('baz')
    jedi.set_debug_function(None, False, False, False)
コード例 #21
0
def run_with_debug(jedi, name, *args, **kwargs):
    re_raise = kwargs.pop('re_raise', ())
    # Remove form feed characters, they confuse Jedi (jedi#424)
    if 'source' in kwargs:
        kwargs['source'] = kwargs['source'].replace("\f", " ")
    try:
        script = jedi.Script(*args, **kwargs)
        return getattr(script, name)()
    except Exception as e:
        if isinstance(e, re_raise):
            raise
        # Bug jedi#417
        if isinstance(e, TypeError) and str(e) == 'no dicts allowed':
            return None
        # Bug jedi#427
        if isinstance(e, UnicodeDecodeError):
            return None
        # Bug jedi#429
        if isinstance(e, IndexError):
            return None
        # Bug jedi#431
        if isinstance(e, AttributeError) and str(e).endswith("'end_pos'"):
            return None
        # Bug in Python 2.6, see #275
        if isinstance(e, OSError) and e.errno == 13:
            return None
        # Bug jedi#466
        if (
                isinstance(e, SyntaxError) and
                "EOL while scanning string literal" in str(e)
        ):
            return None
        # Bug jedi#482
        if isinstance(e, UnicodeEncodeError):
            return None
        # Bug jedi#485
        if (
                isinstance(e, ValueError) and
                "invalid \\x escape" in str(e)
        ):
            return None
        # Bug jedi#485 in Python 3
        if (
                isinstance(e, SyntaxError) and
                "truncated \\xXX escape" in str(e)
        ):
            return None
        # Bug jedi#465
        if (
                isinstance(e, SyntaxError) and
                "encoding declaration in Unicode string" in str(e)
        ):
            return None
        # Bug #337 / jedi#471
        if (
                isinstance(e, ImportError) and
                "No module named" in str(e)
        ):
            return None
        # Bug #365 / jedi#486 - fixed in Jedi 0.8.2
        if (
                isinstance(e, UnboundLocalError) and
                "local variable 'path' referenced before assignment" in str(e)
        ):
            return None
        # Bug #366 / jedi#491
        if (
                isinstance(e, ValueError) and
                "__loader__ is None" in str(e)
        ):
            return None
        # Bug #353
        if (
                isinstance(e, OSError) and
                "No such file or directory" in str(e)
        ):
            return None
        # Bug #561, #564, #570, #588, #593, #599 / jedi#572, jedi#579, jedi#590
        if isinstance(e, KeyError):
            return None

        from jedi import debug

        debug_info = []

        def _debug(level, str_out):
            if level == debug.NOTICE:
                prefix = "[N]"
            elif level == debug.WARNING:
                prefix = "[W]"
            else:
                prefix = "[?]"
            debug_info.append(u"{0} {1}".format(prefix, str_out))

        jedi.set_debug_function(_debug, speed=False)
        try:
            script = jedi.Script(*args, **kwargs)
            return getattr(script, name)()
        except Exception as e:
            source = kwargs.get('source')
            sc_args = []
            sc_args.extend(repr(arg) for arg in args)
            sc_args.extend("{0}={1}".format(k, "source" if k == "source"
                                            else repr(v))
                           for (k, v) in kwargs.items())

            data = {
                "traceback": traceback.format_exc(),
                "jedi_debug_info": {'script_args': ", ".join(sc_args),
                                    'source': source,
                                    'method': name,
                                    'debug_info': debug_info}
            }
            raise rpc.Fault(message=str(e),
                            code=500,
                            data=data)
        finally:
            jedi.set_debug_function(None)
コード例 #22
0
def test_simple():
    jedi.set_debug_function()
    debug.speed('foo')
    debug.dbg('bar')
    debug.warning('baz')
    jedi.set_debug_function(None, False, False, False)
コード例 #23
0
ファイル: run.py プロジェクト: Ademan/jedi
    --pdb           Enable pdb debugging on fail.
    -d, --debug     Enable text output debugging (please install ``colorama``).
    --thirdparty    Also run thirdparty tests (in ``completion/thirdparty``).
"""
if __name__ == '__main__':
    import docopt
    arguments = docopt.docopt(docoptstr)

    import time
    t_start = time.time()
    # Sorry I didn't use argparse here. It's because argparse is not in the
    # stdlib in 2.5.
    import sys

    if arguments['--debug']:
        jedi.set_debug_function()

    # get test list, that should be executed
    test_files = {}
    last = None
    for arg in arguments['<rest>']:
        if arg.isdigit():
            if last is None:
                continue
            test_files[last].append(int(arg))
        else:
            test_files[arg] = []
            last = arg

    # completion tests:
    completion_test_dir = '../test/completion'
コード例 #24
0
    --pdb           Enable pdb debugging on fail.
    -d, --debug     Enable text output debugging (please install ``colorama``).
    --thirdparty    Also run thirdparty tests (in ``completion/thirdparty``).
"""
if __name__ == '__main__':
    import docopt
    arguments = docopt.docopt(docoptstr)

    import time
    t_start = time.time()
    # Sorry I didn't use argparse here. It's because argparse is not in the
    # stdlib in 2.5.
    import sys

    if arguments['--debug']:
        jedi.set_debug_function()

    # get test list, that should be executed
    test_files = {}
    last = None
    for arg in arguments['<rest>']:
        if arg.isdigit():
            if last is None:
                continue
            test_files[last].append(int(arg))
        else:
            test_files[arg] = []
            last = arg

    # completion tests:
    completion_test_dir = '../test/completion'
コード例 #25
0
test_sum = 0
t_start = time.time()
# Sorry I didn't use argparse here. It's because argparse is not in the
# stdlib in 2.5.
args = sys.argv[1:]

print_debug = False
try:
    i = args.index('--debug')
    args = args[:i] + args[i + 1:]
except ValueError:
    pass
else:
    print_debug = True
    jedi.set_debug_function(debug.print_to_stdout)

sys.argv = sys.argv[:1] + args

summary = []
tests_fail = 0


def get_test_list():
    # get test list, that should be executed
    test_files = {}
    last = None
    for arg in sys.argv[1:]:
        if arg.isdigit():
            if last is None:
                continue
コード例 #26
0
        logger.info(
            'Anaconda Server started in {0} for '
            'PID {1} with cache dir {2}{3}'.format(
                port or unix_socket_path.socket, PID,
                jedi_settings.cache_directory,
                ' and extra paths {0}'.format(
                    options.extra_paths
                ) if options.extra_paths is not None else ''
            )
        )
    except Exception as error:
        log_traceback()
        logger.error(str(error))
        server.shutdown()
        sys.exit(-1)

    server.logger = logger

    # start PID checker thread
    if PID != 'DEBUG':
        checker = Checker(server, delta=1)
        checker.start()
    else:
        logger.info('Anaconda Server started in DEBUG mode...')
        print('DEBUG MODE')
        DEBUG_MODE = True
        set_debug_function(notices=True)

    # start the server
    server.serve_forever()
コード例 #27
0
def run_with_debug(jedi, name, *args, **kwargs):
    re_raise = kwargs.pop('re_raise', ())
    # Remove form feed characters, they confuse Jedi (jedi#424)
    if 'source' in kwargs:
        kwargs['source'] = kwargs['source'].replace("\f", " ")
    try:
        script = jedi.Script(*args, **kwargs)
        return getattr(script, name)()
    except Exception as e:
        if isinstance(e, re_raise):
            raise
        # Bug jedi#417
        if isinstance(e, TypeError) and str(e) == 'no dicts allowed':
            return None
        # Bug jedi#427
        if isinstance(e, UnicodeDecodeError):
            return None
        # Bug jedi#429
        if isinstance(e, IndexError):
            return None
        # Bug jedi#431
        if isinstance(e, AttributeError) and str(e).endswith("'end_pos'"):
            return None
        # Bug in Python 2.6, see #275
        if isinstance(e, OSError) and e.errno == 13:
            return None

        from jedi import debug

        debug_info = []

        def _debug(level, str_out):
            if level == debug.NOTICE:
                prefix = "[N]"
            elif level == debug.WARNING:
                prefix = "[W]"
            else:
                prefix = "[?]"
            debug_info.append("{0} {1}".format(prefix, str_out))

        jedi.set_debug_function(_debug, speed=False)
        try:
            script = jedi.Script(*args, **kwargs)
            return getattr(script, name)()
        except Exception as e:
            source = kwargs.get('source')
            sc_args = []
            sc_args.extend(repr(arg) for arg in args)
            sc_args.extend(
                "{0}={1}".format(k, "source" if k == "source" else repr(v))
                for (k, v) in kwargs.items())

            data = {
                "traceback": traceback.format_exc(),
                "jedi_debug_info": {
                    'script_args': ", ".join(sc_args),
                    'source': source,
                    'method': name,
                    'debug_info': debug_info
                }
            }
            raise rpc.Fault(message=str(e), code=500, data=data)
        finally:
            jedi.set_debug_function(None)