ZOO-Project
Data Structures | Macros | Functions | Variables
service_internal_python.c File Reference
#include "service_internal_python.h"
#include "frameobject.h"

Data Structures

struct  module_state
 The state for the zoo Python module. More...
 

Macros

#define GETSTATE(m)   (&_state)
 

Functions

PyMODINIT_FUNC init_zoo ()
 Function to create and initialize the zoo Python module. More...
 
int zoo_python_support (maps **main_conf, map *request, service *s, maps **real_inputs, maps **real_outputs)
 Load a Python module then run the function corresponding to the service by passing the conf, inputs and outputs parameters by reference. More...
 
void PythonZooReport (maps **main_conf, const char *module, int load)
 Report Python error which may occur on loading the Python module or at runtime. More...
 
PyDictObject * PyDict_FromMaps (maps *t)
 Convert a maps to a Python dictionary. More...
 
PyDictObject * PyDict_FromMap (map *t)
 Convert a map to a Python dictionary. More...
 
mapsmapsFromPyDict (PyDictObject *t)
 Convert a Python dictionary to a maps. More...
 
maps_mapsFromPyDict (PyDictObject *t)
 Convert a Python dictionary to a maps. More...
 
mapmapFromPyDict (PyDictObject *t)
 Convert a Python dictionary to a map. More...
 
map_mapFromPyDict (PyDictObject *t)
 Convert a Python dictionary to a map. More...
 
PyObject * PythonTranslate (PyObject *self, PyObject *args)
 Use the ZOO-Services messages translation function from the Python environment. More...
 
PyObject * PythonUpdateStatus (PyObject *self, PyObject *args)
 Update the ongoing status of a running service from the Python environment. More...
 
PyObject * PythonPrintDebugMessage (PyObject *self, PyObject *args)
 ZOO-API debug message handling in Python. More...
 
PyObject * PythonTraceMessage (PyObject *self, PyObject *args)
 ZOO-API equivalent to logger.debug() in Python. More...
 
PyObject * PythonDebugMessage (PyObject *self, PyObject *args)
 ZOO-API equivalent to logger.debug() in Python. More...
 
PyObject * PythonInfoMessage (PyObject *self, PyObject *args)
 ZOO-API equivalent to logger.debug() in Python. More...
 
PyObject * PythonSuccessMessage (PyObject *self, PyObject *args)
 ZOO-API equivalent to logger.debug() in Python. More...
 
PyObject * PythonWarningMessage (PyObject *self, PyObject *args)
 ZOO-API equivalent to logger.debug() in Python. More...
 
PyObject * PythonErrorMessage (PyObject *self, PyObject *args)
 ZOO-API equivalent to logger.debug() in Python. More...
 
PyObject * PythonCriticalMessage (PyObject *self, PyObject *args)
 ZOO-API equivalent to logger.debug() in Python. More...
 

Variables

static struct module_state _state
 
static PyObject * ZooError
 The exception for the zoo Python module. More...
 
PyMethodDef zooMethods []
 Function definitions for the zoo Python Module. More...
 

Data Structure Documentation

◆ module_state

struct module_state

The state for the zoo Python module.

Data Fields
PyObject * error

Macro Definition Documentation

◆ GETSTATE

#define GETSTATE (   m)    (&_state)

Function Documentation

◆ _mapFromPyDict()

map* _mapFromPyDict ( PyDictObject *  t)

Convert a Python dictionary to a map.

Parameters
tthe PyDictObject to convert
Returns
a new map containing the converted PyDictObject
Warning
make sure to free resources returned by this function

◆ _mapsFromPyDict()

maps* _mapsFromPyDict ( PyDictObject *  t)

Convert a Python dictionary to a maps.

Parameters
tthe PyDictObject to convert
Returns
a new maps containing the converted PyDictObject
Warning
make sure to free resources returned by this function

◆ init_zoo()

PyMODINIT_FUNC init_zoo ( )

Function to create and initialize the zoo Python module.

Returns
the Python module (for Python versions < 3, nothing for version >=3)

◆ mapFromPyDict()

map* mapFromPyDict ( PyDictObject *  t)

Convert a Python dictionary to a map.

Parameters
tthe PyDictObject to convert
Returns
a new map containing the converted PyDictObject
Warning
make sure to free resources returned by this function

◆ mapsFromPyDict()

maps* mapsFromPyDict ( PyDictObject *  t)

Convert a Python dictionary to a maps.

Parameters
tthe PyDictObject to convert
Returns
a new maps containing the converted PyDictObject
Warning
make sure to free resources returned by this function

◆ PyDict_FromMap()

PyDictObject* PyDict_FromMap ( map t)

Convert a map to a Python dictionary.

Parameters
tthe map to convert
Returns
a new PyDictObject containing the converted maps
Warning
make sure to free resources returned by this function

◆ PyDict_FromMaps()

PyDictObject* PyDict_FromMaps ( maps t)

Convert a maps to a Python dictionary.

Parameters
tthe maps to convert
Returns
a new PyDictObject containing the converted maps
See also
PyDict_FromMap
Warning
make sure to free resources returned by this function

◆ PythonCriticalMessage()

PyObject* PythonCriticalMessage ( PyObject *  self,
PyObject *  args 
)

ZOO-API equivalent to logger.debug() in Python.

Parameters
selfthe Python object on which we can run the method
argsthe Python arguments given from the Python environment
Returns
a new Python string containing the translated value
See also
_ss

◆ PythonDebugMessage()

PyObject* PythonDebugMessage ( PyObject *  self,
PyObject *  args 
)

ZOO-API equivalent to logger.debug() in Python.

Parameters
selfthe Python object on which we can run the method
argsthe Python arguments given from the Python environment
Returns
a new Python string containing the translated value
See also
_ss

◆ PythonErrorMessage()

PyObject* PythonErrorMessage ( PyObject *  self,
PyObject *  args 
)

ZOO-API equivalent to logger.debug() in Python.

Parameters
selfthe Python object on which we can run the method
argsthe Python arguments given from the Python environment
Returns
a new Python string containing the translated value
See also
_ss

◆ PythonInfoMessage()

PyObject* PythonInfoMessage ( PyObject *  self,
PyObject *  args 
)

ZOO-API equivalent to logger.debug() in Python.

Parameters
selfthe Python object on which we can run the method
argsthe Python arguments given from the Python environment
Returns
a new Python string containing the translated value
See also
_ss

◆ PythonPrintDebugMessage()

PyObject* PythonPrintDebugMessage ( PyObject *  self,
PyObject *  args 
)

ZOO-API debug message handling in Python.

Parameters
selfthe Python object on which we can run the method
argsthe Python arguments given from the Python environment
Returns
a new Python string containing the translated value
See also
_ss

◆ PythonSuccessMessage()

PyObject* PythonSuccessMessage ( PyObject *  self,
PyObject *  args 
)

ZOO-API equivalent to logger.debug() in Python.

Parameters
selfthe Python object on which we can run the method
argsthe Python arguments given from the Python environment
Returns
a new Python string containing the translated value
See also
_ss

◆ PythonTraceMessage()

PyObject* PythonTraceMessage ( PyObject *  self,
PyObject *  args 
)

ZOO-API equivalent to logger.debug() in Python.

Parameters
selfthe Python object on which we can run the method
argsthe Python arguments given from the Python environment
Returns
a new Python string containing the translated value
See also
_ss

◆ PythonTranslate()

PyObject* PythonTranslate ( PyObject *  self,
PyObject *  args 
)

Use the ZOO-Services messages translation function from the Python environment.

Parameters
selfthe Python object on which we can run the method
argsthe Python arguments given from the Python environment
Returns
a new Python string containing the translated value
See also
_ss

◆ PythonUpdateStatus()

PyObject* PythonUpdateStatus ( PyObject *  self,
PyObject *  args 
)

Update the ongoing status of a running service from the Python environment.

Parameters
selfthe Python object on which we can run the method
argsthe Python arguments given from the Python environment
Returns
None to the Python environment
See also
_updateStatus

◆ PythonWarningMessage()

PyObject* PythonWarningMessage ( PyObject *  self,
PyObject *  args 
)

ZOO-API equivalent to logger.debug() in Python.

Parameters
selfthe Python object on which we can run the method
argsthe Python arguments given from the Python environment
Returns
a new Python string containing the translated value
See also
_ss

◆ PythonZooReport()

void PythonZooReport ( maps **  main_conf,
const char *  module,
int  load 
)

Report Python error which may occur on loading the Python module or at runtime.

Parameters
main_confthe conf maps containing the main.cfg settings
modulethe service name
load1 if the Python module was not loaded yet

◆ zoo_python_support()

int zoo_python_support ( maps **  main_conf,
map request,
service s,
maps **  real_inputs,
maps **  real_outputs 
)

Load a Python module then run the function corresponding to the service by passing the conf, inputs and outputs parameters by reference.

Parameters
main_confthe conf maps containing the main.cfg settings
requestthe map containing the HTTP request
sthe service structure
real_inputsthe maps containing the inputs
real_outputsthe maps containing the outputs

Variable Documentation

◆ _state

struct module_state _state
static

◆ ZooError

PyObject* ZooError
static

The exception for the zoo Python module.

◆ zooMethods

PyMethodDef zooMethods[]
Initial value:
= {
{"_", PythonTranslate, METH_VARARGS, "Translate a string using the zoo-services textdomain."},
{"update_status", PythonUpdateStatus, METH_VARARGS, "Update status percentage of a running process."},
{"trace", PythonTraceMessage, METH_VARARGS, "Equivalent to logger.trace()."},
{"debug", PythonDebugMessage, METH_VARARGS, "Equivalent to logger.debug()."},
{"info", PythonInfoMessage, METH_VARARGS, "Equivalent to logger.info()."},
{"success", PythonSuccessMessage, METH_VARARGS, "Equivalent to logger.success()."},
{"warning", PythonWarningMessage, METH_VARARGS, "Equivalent to logger.warning()."},
{"error", PythonErrorMessage, METH_VARARGS|METH_COEXIST, "Equivalent to logger.error()."},
{"critical", PythonCriticalMessage, METH_VARARGS, "Equivalent to logger.critical()."},
{NULL, NULL, 0, NULL}
}

Function definitions for the zoo Python Module.

Define the following functions available from a service loaded and running from the ZOO-Kernel Python environment:

PythonDebugMessage
PyObject * PythonDebugMessage(PyObject *self, PyObject *args)
ZOO-API equivalent to logger.debug() in Python.
Definition: service_internal_python.c:984
PythonTraceMessage
PyObject * PythonTraceMessage(PyObject *self, PyObject *args)
ZOO-API equivalent to logger.debug() in Python.
Definition: service_internal_python.c:970
PythonErrorMessage
PyObject * PythonErrorMessage(PyObject *self, PyObject *args)
ZOO-API equivalent to logger.debug() in Python.
Definition: service_internal_python.c:1040
PythonTranslate
PyObject * PythonTranslate(PyObject *self, PyObject *args)
Use the ZOO-Services messages translation function from the Python environment.
Definition: service_internal_python.c:882
PythonWarningMessage
PyObject * PythonWarningMessage(PyObject *self, PyObject *args)
ZOO-API equivalent to logger.debug() in Python.
Definition: service_internal_python.c:1026
PythonCriticalMessage
PyObject * PythonCriticalMessage(PyObject *self, PyObject *args)
ZOO-API equivalent to logger.debug() in Python.
Definition: service_internal_python.c:1054
PythonSuccessMessage
PyObject * PythonSuccessMessage(PyObject *self, PyObject *args)
ZOO-API equivalent to logger.debug() in Python.
Definition: service_internal_python.c:1012
PythonInfoMessage
PyObject * PythonInfoMessage(PyObject *self, PyObject *args)
ZOO-API equivalent to logger.debug() in Python.
Definition: service_internal_python.c:998
PythonUpdateStatus
PyObject * PythonUpdateStatus(PyObject *self, PyObject *args)
Update the ongoing status of a running service from the Python environment.
Definition: service_internal_python.c:903