How to use the pscript.stubs.console.warn 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
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:
                ob[name](*args)
        elif cmd == 'INSTANTIATE':
            self.instantiate_component(*command[1:])  # module, cname, id, args, kwargs
        elif cmd == 'DISPOSE':
            id = command[1]
            c = self.instances.get(id, None)
            if c is not None and c._disposed is False:  # else: no need to warn
                c._dispose()
            self.send_command('DISPOSE_ACK', command[1])
            self.instances.pop(id, None)  # Drop local reference now
        elif cmd == 'DISPOSE_ACK':
            self.instances.pop(command[1], None)  # Drop reference