Exemple #1
0
def attach_pudb(log=None):

    # need to move here to avoid circular import
    from .threads import gettid

    host = '127.0.0.1'
  # host = gethostip()
    tid  = gettid()
    port = tid + 10000

    if log:
        log.info('debugger open: telnet %s %d', host, port)
    else:
        print('debugger open: telnet %s %d' % (host, port))

    try:
        import pudb                                      # pylint: disable=E0401
        from   pudb.remote import set_trace              # pylint: disable=E0401

        pudb.DEFAULT_SIGNAL = signal.SIGALRM

        set_trace(host=host, port=port, term_size=(200, 50))

    except Exception as e:
        if log:
            log.warning('failed to attach pudb (%s)', e)
Exemple #2
0
    def process_resource(self, req, resp, resource, params):
        """Process the request and resource *after* routing.

        Note:
            This method is only called when the request matches
            a route to a resource.

        Args:
            req: Request object that will be passed to the
                routed responder.
            resp: Response object that will be passed to the
                responder.
            resource: Resource object to which the request was
                routed. May be None if no route was found for
                the request.
            params: A dict-like object representing any
                additional params derived from the route's URI
                template fields, that will be passed to the
                resource's responder method as keyword
                arguments.
        """
        if not settings.get("AWOKADO_DEBUG"):
            return

        profiling_enabled = req.get_param_as_bool("profiling")
        if profiling_enabled:
            profile = cProfile.Profile()
            profile.enable()
            req.profile = profile

        debugger_enabled = req.get_param_as_bool("debug")
        if debugger_enabled:
            from pudb.remote import set_trace

            set_trace(term_size=(100, 50))
Exemple #3
0
def sum_strings(a, b):
    try:
        return int(a) + int(b)
    except Exception:
        from pudb.remote import set_trace
        set_trace(term_size=(160, 40), host='0.0.0.0', port=6900)
        print(a)
        print(b)
        return float(a) + float(b)
Exemple #4
0
def worker(worker_id):
    """ Simple worker process"""
    i = 0
    while i < 10:
        if worker_id == 1:  # debug process with id 1
            set_trace(term_size=(80, 24))
        time.sleep(1)  # represents some work
        print('In Process {}, i:{}'.format(worker_id, i))
        i = i + 1
Exemple #5
0
def worker():

    from pudb import remote
    remote.set_trace(
        term_size=(150, 50),
        #  host='0.0.0.0',    # external ip listen on remote server
        host='localhost',
        port=12345)  # port listen is 12345 on remote server

    i = 0
    while i < 10:
        i = i + 1
Exemple #6
0
def attach_pudb(logger=None):

    host = '127.0.0.1'
  # host = gethostip()
    tid  = gettid()
    port = tid + 10000

    if logger:
        logger.info('debugger open: telnet %s %d', host, port)
    else:
        print 'debugger open: telnet %s %d' % (host, port)

    import pudb
    import signal
    pudb.DEFAULT_SIGNAL = signal.SIGALRM

    from pudb.remote import set_trace
    set_trace(host=host, port=port, term_size=(200, 50))
def attach_pudb(logger=None):

    host = '127.0.0.1'
  # host = gethostip()
    tid  = gettid()
    port = tid + 10000

    if logger:
        logger.info('debugger open: telnet %s %d', host, port)
    else:
        print 'debugger open: telnet %s %d' % (host, port)

    import pudb
    import signal
    pudb.DEFAULT_SIGNAL = signal.SIGALRM

    from pudb.remote import set_trace
    set_trace(host=host, port=port, term_size=(200, 50))
async def pudb_set_trace(request: web.Request) -> web.StreamResponse:
    """ PuDB remote debugging: https://documen.tician.de/pudb/starting.html#remote-debugging

    XXX: weird things can happen, use with caution, and don't rely on leaving the server running after starting pudb

    From their docs:

    > At this point, the debugger will look for a free port and wait for a telnet connection:
    >
    > ```
    > pudb:6899: Please telnet into 127.0.0.1 6899.
    > pudb:6899: Waiting for client...
    > ```

    Use the `term_size` url param for a custom terminal size:

    Example:

    curl -X POST 'localhost:9999/pudb/set_trace?term_size=143x43' -v

    Note: The MergedMiningCoordinator can be accesses through `request.app[_MM]`
    """
    try:
        from pudb.remote import set_trace
    except ImportError:
        return web.Response(status=500, text='pudb not installed\n')
    log = request.app[_LOG]
    term_size = _DEFAULT_TERM_SIZE
    term_size_query = request.query.get('term_size')
    if term_size_query is not None:
        try:
            x, y = term_size_query.split('x')
            term_size = int(x), int(y)
        except ValueError:
            pass
    log.info('set_trace', term_size=term_size)
    set_trace(term_size=term_size)
    return web.Response(status=204)
Exemple #9
0
def back_trace(term_size, frame=frame_above()):
    remote.set_trace(frame, term_size)
Exemple #10
0
def info(title):
    print(title)
    set_trace()
    print('module name:', __name__)
    print('parent process:', os.getppid())
    print('process id:', os.getpid())
Exemple #11
0
def example_run():
    today = date.today()
    set_trace()
    print('today is data: {}'.format(today))
Exemple #12
0
def set_trace():
    remote.set_trace(term_size=(200, 50))
Exemple #13
0
def pudb():
    try:
        from pudb.remote import set_trace
        set_trace()
    except:
        pass
Exemple #14
0
def set_trace():
    from pudb.remote import set_trace
    set_trace(term_size=(170, 45))
Exemple #15
0
    def setup_collision_callbacks(self):
        """Setup the correct collisions for the cymunk physics system manager.

        use the physics_system.add_collision_handler
        to define between which collision_ids the collision should happen and between which not

        Following handler functions are passed
        - begin_func - called once on collision begin
        - separate_func - called once on collision end
        """

        physics_system = self.gameworld.system_manager["cymunk_physics"]

        def ignore_collision(na, nb):
            """Returns false to indicate ignoring the collision."""
            return False

        # collide_remove_first

        # add robots
        us_detectable = self.collision_ids["ultrasound_detectable"]
        rob_collision_ids = [
            self.collision_ids["robot"] + ct
            for ct in range(self.num_of_robots)
        ]
        us_detectable.extend(rob_collision_ids)

        self.begin_ultrasound_callback = {}

        # ignore_collision of ultrasound triangle with 0-1024 collision_ids
        # to enable the triangles to clip through other objects
        # ! this should be done on robot / on ultrasound creation
        for us_id in self.collision_ids["ultrasound"]:
            for index_id in range(1024):
                physics_system.add_collision_handler(
                    index_id,
                    us_id,
                    begin_func=ignore_collision,
                    separate_func=ignore_collision,
                )

        # add ultrasound triangles object detection via collision
        # ! this should be done on robot / on ultrasound creation
        for us_id in self.collision_ids["ultrasound"]:
            for detectable in us_detectable:
                print("us_id", us_id)
                physics_system.add_collision_handler(
                    detectable,
                    us_id,
                    begin_func=self.return_begin_ultrasound_callback(
                        us_id, True),
                    separate_func=self.return_begin_ultrasound_callback(
                        us_id, False),
                )

        for r_ct in rob_collision_ids:
            from pudb.remote import set_trace

            set_trace(term_size=(238, 54), host="0.0.0.0", port=6900)  # noqa
            physics_system.add_collision_handler(
                self.collision_ids["candy"],
                r_ct,
                begin_func=self.begin_candy_callback,
                separate_func=self.begin_candy_callback,
            )
Exemple #16
0
from pudb.remote import set_trace

set_trace(term_size=(80, 24), host='0.0.0.0', port=4444)
#telnet localhost 4444
Exemple #17
0
 def xpudb(self, xtty=None):
     '''Launch pudb.remote on given tty'''
     from pudb.remote import set_trace
     set_trace()