Example #1
0
 def get(self, uuid, action):
     if action == 'close':
         sockets.close(uuid)
         sockets.remove(uuid)
         websockets.close(uuid)
         websockets.remove(uuid)
     self.redirect('/')
Example #2
0
def on_close(stream, uuid):
    # None if the user closed the window
    log.info('uuid %s closed' % uuid)
    websockets.send(uuid, 'Die')
    websockets.close(uuid)
    websockets.remove(uuid)
    sockets.remove(uuid)
Example #3
0
    def open(self, uuid):
        if self.request.headers['Origin'] != 'http://%s' % (
                self.request.headers['Host']):
            self.close()
            return

        self.uuid = uuid

        if isinstance(self.uuid, bytes):
            self.uuid = self.uuid.decode('utf-8')

        if self.uuid in websockets.uuids:
            log.warn(
                'Websocket already opened for %s. Closing previous one' %
                self.uuid)
            websockets.send(self.uuid, 'Die')
            websockets.close(uuid)

        if self.uuid not in sockets.uuids:
            log.warn(
                'Websocket opened for %s with no correponding socket' %
                self.uuid)
            sockets.send(self.uuid, 'Die')
            self.close()
            return

        log.info('Websocket opened for %s' % self.uuid)
        websockets.add(self.uuid, self)
Example #4
0
    def on_message(self, message):
        if '|' in message:
            cmd, data = message.split('|', 1)
        else:
            cmd, data = message, ''

        if cmd == 'ListSockets':
            for uuid in sockets.uuids:
                syncwebsockets.send(self.uuid, 'AddSocket', uuid)
        elif cmd == 'ListWebsockets':
            for uuid in websockets.uuids:
                syncwebsockets.send(self.uuid, 'AddWebSocket', uuid)
        elif cmd == 'ListBreaks':
            for brk in breakpoints.get():
                syncwebsockets.send(self.uuid, 'AddBreak', brk)
        elif cmd == 'RemoveBreak':
            brk = json.loads(data)
            breakpoints.remove(brk)
            # If it was here, it wasn't temporary
            brk['temporary'] = False
            sockets.broadcast('Unbreak', brk)
        elif cmd == 'RemoveUUID':
            sockets.close(data)
            sockets.remove(data)
            websockets.close(data)
            websockets.remove(data)
        elif cmd == 'ListProcesses':
            refresh_process(self.uuid)
        elif cmd == 'Pause':
            if int(data) == os.getpid():
                log.debug('Pausing self')

                def self_shell(variables):
                    # Debugging self
                    import wdb
                    wdb.set_trace()

                Process(target=self_shell, args=(globals(),)).start()

            else:
                log.debug('Pausing %s' % data)
                tornado.process.Subprocess([
                    'gdb', '-p', data,
                    '-batch'] + [
                        "-eval-command=call %s" % hook
                        for hook in [
                            'PyGILState_Ensure()',
                            'PyRun_SimpleString('
                            '"import wdb; wdb.set_trace(skip=1)"'
                            ')',
                            'PyGILState_Release($1)',
                        ]])
        elif cmd == 'RunFile':
            file_name = data

            def run():
                from wdb import Wdb
                Wdb.get().run_file(file_name)

            Process(target=run).start()
Example #5
0
    def open(self, uuid):
        if self.request.headers['Origin'] != 'http://%s' % (
                self.request.headers['Host']):
            self.close()
            return

        self.uuid = uuid

        if isinstance(self.uuid, bytes):
            self.uuid = self.uuid.decode('utf-8')

        if self.uuid in websockets.uuids:
            log.warn('Websocket already opened for %s. Closing previous one' %
                     self.uuid)
            websockets.send(self.uuid, 'Die')
            websockets.close(uuid)

        if self.uuid not in sockets.uuids:
            log.warn('Websocket opened for %s with no correponding socket' %
                     self.uuid)
            sockets.send(self.uuid, 'Die')
            self.close()
            return

        log.info('Websocket opened for %s' % self.uuid)
        websockets.add(self.uuid, self)
Example #6
0
 def get(self, uuid, action):
     if action == 'close':
         sockets.close(uuid)
         sockets.remove(uuid)
         websockets.close(uuid)
         websockets.remove(uuid)
     self.redirect('/')
Example #7
0
def on_close(stream, uuid):
    # None if the user closed the window
    log.info('uuid %s closed' % uuid)
    websockets.send(uuid, 'Die')
    websockets.close(uuid)
    websockets.remove(uuid)
    sockets.remove(uuid)
Example #8
0
    def on_message(self, message):
        if '|' in message:
            cmd, data = message.split('|', 1)
        else:
            cmd, data = message, ''

        if cmd == 'ListSockets':
            for uuid in sockets.uuids:
                syncwebsockets.send(self.uuid, 'AddSocket', uuid)
        elif cmd == 'ListWebsockets':
            for uuid in websockets.uuids:
                syncwebsockets.send(self.uuid, 'AddWebSocket', uuid)
        elif cmd == 'ListBreaks':
            for brk in breakpoints.get():
                syncwebsockets.send(self.uuid, 'AddBreak', brk)
        elif cmd == 'RemoveBreak':
            brk = json.loads(data)
            breakpoints.remove(brk)
            # If it was here, it wasn't temporary
            brk['temporary'] = False
            sockets.broadcast('Unbreak', brk)
        elif cmd == 'RemoveUUID':
            sockets.close(data)
            sockets.remove(data)
            websockets.close(data)
            websockets.remove(data)
        elif cmd == 'ListProcesses':
            refresh_process(self.uuid)
        elif cmd == 'Pause':
            if int(data) == os.getpid():
                log.debug('Pausing self')

                def self_shell(variables):
                    # Debugging self
                    import wdb
                    wdb.set_trace()

                Process(target=self_shell, args=(globals(),)).start()

            else:
                log.debug('Pausing %s' % data)
                tornado.process.Subprocess([
                    'gdb', '-p', data,
                    '-batch'] + [
                        "-eval-command=call %s" % hook
                        for hook in [
                            'PyGILState_Ensure()',
                            'PyRun_SimpleString('
                            '"import wdb; wdb.set_trace(skip=1)"'
                            ')',
                            'PyGILState_Release($1)',
                        ]])
        elif cmd == 'RunFile':
            file_name = data

            def run():
                from wdb import Wdb
                Wdb.get().run_file(file_name)

            Process(target=run).start()
Example #9
0
    def on_open(self, uuid):
        self.uuid = uuid

        if isinstance(self.uuid, bytes):
            self.uuid = self.uuid.decode('utf-8')

        if self.uuid in websockets.uuids:
            log.warn(
                'Websocket already opened for %s. Closing previous one' %
                self.uuid
            )
            websockets.send(self.uuid, 'Die')
            websockets.close(uuid)

        if self.uuid not in sockets.uuids:
            log.warn(
                'Websocket opened for %s with no correponding socket' %
                self.uuid
            )
            sockets.send(self.uuid, 'Die')
            self.close()
            return

        log.info('Websocket opened for %s' % self.uuid)
        websockets.add(self.uuid, self)
Example #10
0
    def on_open(self, uuid):
        self.uuid = uuid

        if isinstance(self.uuid, bytes):
            self.uuid = self.uuid.decode('utf-8')

        if self.uuid in websockets.uuids:
            log.warn(
                'Websocket already opened for %s. Closing previous one' %
                self.uuid
            )
            websockets.send(self.uuid, 'Die')
            websockets.close(uuid)

        if self.uuid not in sockets.uuids:
            log.warn(
                'Websocket opened for %s with no correponding socket' %
                self.uuid
            )
            sockets.send(self.uuid, 'Die')
            self.close()
            return

        log.info('Websocket opened for %s' % self.uuid)
        websockets.add(self.uuid, self)
Example #11
0
def on_close(stream, uuid):
    # None if the user closed the window
    log.info("uuid %s closed" % uuid)
    if websockets.get(uuid):
        websockets.send(uuid, "Die")
        websockets.close(uuid)
        websockets.remove(uuid)
    sockets.remove(uuid)