Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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