Esempio n. 1
0
def gen(ctx, debug, template, dest, stdout, single_file, args):
    """
  Generate a skeleton from a template.

  template : if template starts with an '@', it will look for an installed template. Else, it will be considered as the template path.
  dest : the output directory (parents will be created if needed)
  args : argument passed to the template ( skbs gen <template_name> -- --help for more informations )
  """
    try:
        from . import pluginutils
        pluginutils.__ctx = ctx
        pluginutils.__name = f'{template} {dest} --'
        template_path = B.findTemplate(template,
                                       single_file_authorized=single_file
                                       or stdout)
        out_f = None
        if stdout:
            import sys
            out_f = sys.stdout
        res, help = B.execTemplate(template_path, dest, args, out_f)
        if not res:
            click.echo(help)
    except:
        if debug:
            import pdb
            pdb.xpm()
        raise
Esempio n. 2
0
File: cli.py Progetto: hl037/labs
def main(src, build_dir, d, debug, clean):
    try:
        D = d
        config = dict(d.split('=', maxsplit=1) for d in D)
        labs = Labs(src, build_dir, config, use_cache=not clean)
        labs.process()
    except:
        if debug:
            import pdb
            pdb.xpm()
        else:
            raise
Esempio n. 3
0
def launch_pdb_on_exception(launch=True):
    """Return contextmanager launching pdb upon exception.

    Use like this, to toggle via env variable:

    with launch_pdb_on_exception(os.environ.get('PDB')):
        cli()
    """
    # pylint: disable=bare-except,no-member
    try:
        yield
    except:  # noqa
        if launch:
            import pdb
            pdb.xpm()
        else:
            raise
Esempio n. 4
0
def launch_pdb_on_exception(launch=True):
    """Return contextmanager launching pdb on exception.

    Example:
      Toggle launch behavior via env variable::

          with launch_pdb_on_exception(os.environ.get('PDB')):
              cli()

    """
    if launch:
        try:
            yield
        except Exception:  # pylint: disable=broad-except
            import pdb  # pylint: disable=import-outside-toplevel
            pdb.xpm()  # pylint: disable=no-member
    else:
        yield
Esempio n. 5
0
def invokeCmd(cmd, args, **extra):
    """
  Invoke a click command, so that the usage will be adapted to fit the parent command if one.
  **extra are passed to cmd.make_context
  """
    from .._internal_click_monkey_patches import __get_help_option, silentClick
    stderr = io.StringIO()
    with silentClick(stderr):
        try:
            ctx = cmd.make_context(__name, args, parent=__ctx, **extra)
            cmd.invoke(ctx)
        except Exit:
            pass
        except ClickException as exc:
            exc.show(file=stderr)
        except Exception:
            import pdb
            pdb.xpm()
            raise PluginError(ctx.get_help())
    err = stderr.getvalue()
    if err:
        raise PluginError(err)
Esempio n. 6
0
def main():
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('--transfers', default=100, type=int)
    parser.add_argument('--nodes', default=10, type=int)
    parser.add_argument('--tokens', default=1, type=int)
    parser.add_argument('--channels-per-node', default=2, type=int)
    parser.add_argument('-p', '--profile', default=False, action='store_true')
    parser.add_argument('--pdb', default=False, action='store_true')
    parser.add_argument('--throughput',
                        dest='throughput',
                        action='store_true',
                        default=True)
    parser.add_argument('--latency', dest='throughput', action='store_false')
    parser.add_argument('--log', action='store_true', default=False)
    args = parser.parse_args()

    if args.log:
        slogging.configure(':DEBUG')

    if args.profile:
        import GreenletProfiler
        GreenletProfiler.set_clock_type('cpu')
        GreenletProfiler.start()

    tokens = [
        sha3('token:{}'.format(number))[:20] for number in range(args.tokens)
    ]

    amount = 10
    apps = setup_apps(
        amount,
        tokens,
        args.transfers,
        args.nodes,
        args.channels_per_node,
    )

    if args.pdb:
        from pyethapp.utils import enable_greenlet_debugger
        enable_greenlet_debugger()

        try:
            if args.throughput:
                test_throughput(apps, tokens, args.transfers, amount)
            else:
                test_latency(apps, tokens, args.transfers, amount)
        except:
            import pdb
            pdb.xpm()
    else:
        if args.throughput:
            test_throughput(apps, tokens, args.transfers, amount)
        else:
            test_latency(apps, tokens, args.transfers, amount)

    if args.profile:
        GreenletProfiler.stop()
        stats = GreenletProfiler.get_func_stats()
        pstats = GreenletProfiler.convert2pstats(stats)

        print_serialization(pstats)
        print_slow_path(pstats)
        print_slow_function(pstats)

        pstats.sort_stats('time').print_stats()
Esempio n. 7
0
        result.wait()

    profiling.print_all_threads()
    # profiling.print_merged()


if __name__ == '__main__':
    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument('--nodes', default=10, type=int)
    parser.add_argument('--channels-per-node', default=2, type=int)
    parser.add_argument('--pdb', action='store_true', default=False)

    args = parser.parse_args()

    if args.pdb:
        try:
            profile_transfer(
                num_nodes=args.nodes,
                channels_per_node=args.channels_per_node,
            )
        except:
            import pdb
            pdb.xpm()
    else:
        profile_transfer(
            num_nodes=args.nodes,
            channels_per_node=args.channels_per_node,
        )
        result.wait()

    profiling.print_all_threads()
    # profiling.print_merged()


if __name__ == '__main__':
    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument('--nodes', default=10, type=int)
    parser.add_argument('--channels-per-node', default=2, type=int)
    parser.add_argument('--pdb', action='store_true', default=False)

    args = parser.parse_args()

    if args.pdb:
        try:
            profile_transfer(
                num_nodes=args.nodes,
                channels_per_node=args.channels_per_node,
            )
        except: # noqa
            import pdb
            pdb.xpm()
    else:
        profile_transfer(
            num_nodes=args.nodes,
            channels_per_node=args.channels_per_node,
        )
Esempio n. 9
0
    local = True


def get_main():
    # check and/or update the source code
    bootstrap = Bootstrap(ROOT, local)
    if bootstrap.update():
        # src updated correctly, load it
        bootstrap.load()
        from ristomele.gui.app import main
        return main
    else:
        # probably we cannot connect to the sync server. Start a simple app to
        # allow the user to change the settings
        return bootstrap_main


def bootstrap_main():
    BootstrapApp(ROOT).run()


if __name__ == '__main__':
    main = get_main()
    if platform == 'android':
        main()
    else:
        try:
            main()
        except:
            import pdb;pdb.xpm()
Esempio n. 10
0
def xpm():
    pdb.xpm(PdbTest)
Esempio n. 11
0
 async def pdb_middleware(request, handler):
     try:
         return await handler(request)
     except Exception:  # pylint: disable=broad-except
         import pdb  # pylint: disable=import-outside-toplevel
         pdb.xpm()  # pylint: disable=no-member
Esempio n. 12
0
def main():
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('--transfers', default=100, type=int)
    parser.add_argument('--nodes', default=10, type=int)
    parser.add_argument('--assets', default=1, type=int)
    parser.add_argument('--channels-per-node', default=2, type=int)
    parser.add_argument('-p', '--profile', default=False, action='store_true')
    parser.add_argument('--pdb', default=False, action='store_true')
    parser.add_argument('--throughput', dest='throughput', action='store_true', default=True)
    parser.add_argument('--latency', dest='throughput', action='store_false')
    parser.add_argument('--log', action='store_true', default=False)
    args = parser.parse_args()

    if args.log:
        slogging.configure(':DEBUG')

    if args.profile:
        import GreenletProfiler
        GreenletProfiler.set_clock_type('cpu')
        GreenletProfiler.start()

    assets = [
        sha3('asset:{}'.format(number))[:20]
        for number in range(args.assets)
    ]

    amount = 10
    apps = setup_apps(
        amount,
        assets,
        args.transfers,
        args.nodes,
        args.channels_per_node,
    )

    if args.pdb:
        from pyethapp.utils import enable_greenlet_debugger
        enable_greenlet_debugger()

        try:
            if args.throughput:
                test_throughput(apps, assets, args.transfers, amount)
            else:
                test_latency(apps, assets, args.transfers, amount)
        except:
            import pdb
            pdb.xpm()
    else:
        if args.throughput:
            test_throughput(apps, assets, args.transfers, amount)
        else:
            test_latency(apps, assets, args.transfers, amount)

    if args.profile:
        GreenletProfiler.stop()
        stats = GreenletProfiler.get_func_stats()
        pstats = GreenletProfiler.convert2pstats(stats)

        print_serialization(pstats)
        print_slow_path(pstats)
        print_slow_function(pstats)

        pstats.sort_stats('time').print_stats()
Esempio n. 13
0
def xpm():
    pdb.xpm(PdbTest)