bindpyrame package¶
Submodules¶
bindpyrame.proxy module¶
This module is a proxy for calling pyrame without creating a pyrame module.
For example, to use the function onearg with test_onearg argument function of the cmd_test module listening on port localhost:9007:
import bindpyrame
# connect to the module running at port 9007 here cmd_test
p = bindpyrame.PyrameProxy('localhost',9007)
p.onearg("test_onearg")
=> (1, u'onearg(test_onearg)')
# print_list_function() is a method to show the prototype of the the available functions from the module
p.print_list_functions()
=> available functions are:
cmod_resolve( )
apipools( )
wakemeup( )
void( )
init( dev_name, arg1, arg2, arg3 )
asyncwait( time )
infargs( )
onearg( arg1 )
getmyfile( )
getmyport( )
varmod( )
twoargs( arg1, arg2 )
newns( ns )
fail( )
getvar( name )
gettestport( )
setvar( ns, name, value )
pool( )
-
class
bindpyrame.proxy.PyrameProxy(host, port, pyrame_ports_filename='/opt/pyrame/ports.txt')¶ Bases:
objectClass to proxy pyrame calls
- Parameters
host (str) – the host where pyrame is running can be localhost, IP or FQDN
port (int) – the port associated with the pyrame module
pyrame_ports_filename (str) – the file containing the association between ports and modules
-
get_arg(argName)¶ Get the value for the arg of name
- Parameters
argName (str) – the argument name
- Returns
the value of the argument or None
- Return type
str
-
print_list_all_args()¶ print all the arguments used in the function of pyrame’s module
-
print_list_args_default()¶ print all the args and their default value
-
print_list_functions()¶ print the function prototype in pyrame’s module
-
set_args(argName, value)¶ Set the value of args that is given to a function
- Parameters
argName (str) – the name of the argument in pyrame module
value (str) – the value of the args
-
bindpyrame.proxy.port_2_name(filename)¶ Utility function to load the port to name association stored in filename
- Parameters
filename (str) – the path containing the port to name association for pyrame
- Returns
the dict contains the port to name association
- Return type
dict
bindpyrame.sendcmd module¶
Basic function to bind to pyrame. It implements the pyrame protocol to communicate with pyrame’s modules.
For example, to use the function onearg with test_onearg argument function of the cmd_test module listening on port localhost:9007:
import bindpyrame
bindpyrame.sendcmd("localhost",9007,"onearg_test","test_onearg")
=> (1, u'onearg(test_onearg)')
-
bindpyrame.sendcmd.sendcmd(host, port, cmd, *args)¶ Function that send a XML string to the pyrame module
- Parameters
host (str) – the hostname running pyrame
port (int) – the port number of the module
cmd (str) – the command that the pyrame module will run
*args (str) – the arguments if needed to the command
- Returns
Tuple containing:
status(int): the status of request 1 if successful 0 otherwise result(str): a string containing the result.
- Return type
(tuple)