How to use the pscript.stubs.console.log function in pscript

To help you get started, we’ve selected a few pscript examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flexxui / flexx / flexx / app / _clientcore.py View on Github external
window.flexx.spin(None)
            while len(self._pending_commands):
                self._receive_raw_command(self._pending_commands.pop(0))
            self._pending_commands = None
            # print('init took', time() - self._init_time)
        elif cmd == 'PRINT':
            (window.console.ori_log or window.console.log)(command[1])
        elif cmd == 'EXEC':
            eval(command[1])
        elif cmd == 'EVAL':
            x = None
            if len(command) == 2:
                x = eval(command[1])
            elif len(command) == 3:
                x = eval('this.instances.' + command[1] + '.' + command[2])
            console.log(str(x))  # print (and thus also sends back result)
        elif cmd == 'EVALANDRETURN':
            try:
                x = eval(command[1])
            except Exception as err:
                x = str(err)
            eval_id = command[2]  # to identify the result in Python
            self.send_command("EVALRESULT", x, eval_id)
        elif cmd == 'INVOKE':
            id, name, args = command[1:]
            ob = self.instances.get(id, None)
            if ob is None:
                console.warn('Cannot invoke %s.%s; '
                             'session does not know it (anymore).' % (id, name))
            elif ob._disposed is True:
                pass  # deleted, but other end might not be aware when command was send
            else: