Overview

This module evaluates python commands on the fly.

Methods

string eval (const string& stringToEvaluate)

eval script

stringToEvaluate

string to eval

Returns

if the evaluation has gone wrong

Example in Python :

# PC python is used to call embedded python interpreter pythonBridge

from naoqi import ALBroker
from naoqi import ALModule
from naoqi import ALProxy

try:
  lProxy = ALProxy("ALPythonBridge","127.0.0.1",9559)
  # no syntax error
  print lProxy.eval("print('Hello in python')")
  
  # get error
  print lProxy.eval("prfint('Hello in python')") 
  
except RuntimeError,e:
  # catch exception
  print "error in eval", e
  exit(1)


 

AL::ALValue evalReturn (const string& stringToEvaluate)

eval script and return result. evalReturn(2+2) will return 4

stringToEvaluate

string to eval

Returns

the result of the evaluation

AL::ALValue evalFull (const string& stringToEvaluate)

evaluates script and returns an informative array.

stringToEvaluate

string to eval

Returns

an array containing [return value, exceptions, stdout, stderr]

Example in Python :

# PC python is used to call embedded python interpreter pythonBridge

from naoqi import ALBroker
from naoqi import ALModule
from naoqi import ALProxy

try:
  lProxy = ALProxy("ALPythonBridge","127.0.0.1",9559)
  # no syntax error
  print lProxy.evalFull("1+2")
  # return [3, '', '', ''] 
  
  # get error
  print lProxy.evalFull("prfint('Hello in python')") 
  #return ['', "<type 'exceptions.NameError'>
name 'prfint' is not defined
", '', '']
  
  # get stdout
  print lProxy.evalFull("print('Hello in python')") 
  #return ['', '', 'Hello in python
', '']
  
except RuntimeError,e:
  # catch exception
  print "error in eval", e
  exit(1)


 


Methods inherited from ALModule

void exit ()

Exits and unregisters the module.

string version ()

Returns the version of the module.

Returns

A string containing the version of the module.

bool ping ()

Just a ping. Always returns true

Returns

returns true

vector<string> getMethodList ()

Retrieves the module's method list.

Returns

An array of method names.

AL::ALValue getMethodHelp (const string& methodName)

Retrieves a method's description.

methodName

The name of the method.

Returns

A structure containing the method's description.

AL::ALValue getModuleHelp ()

Retrieves the module's description.

Returns

A structure describing the module.

string getBrokerName ()

Gets the name of the parent broker.

Returns

The name of the parent broker.

string getUsage (const string& name)

Gets the method usage string. This summarise how to use the method.

name

The name of the method.

Returns

A string that summarises the usage of the method.


Copyright © 2010 Aldebaran Robotics - All rights reserved