[579] | 1 | /* |
---|
[1] | 2 | * Author : Gérald FENOY |
---|
| 3 | * |
---|
[453] | 4 | * Copyright (c) 2009-2014 GeoLabs SARL |
---|
[1] | 5 | * |
---|
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
| 7 | * of this software and associated documentation files (the "Software"), to deal |
---|
| 8 | * in the Software without restriction, including without limitation the rights |
---|
| 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
---|
| 10 | * copies of the Software, and to permit persons to whom the Software is |
---|
| 11 | * furnished to do so, subject to the following conditions: |
---|
| 12 | * |
---|
| 13 | * The above copyright notice and this permission notice shall be included in |
---|
| 14 | * all copies or substantial portions of the Software. |
---|
| 15 | * |
---|
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
---|
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
---|
| 22 | * THE SOFTWARE. |
---|
| 23 | */ |
---|
| 24 | |
---|
| 25 | #include "service_internal_python.h" |
---|
| 26 | |
---|
[579] | 27 | /** |
---|
| 28 | * The state for the zoo Python module |
---|
| 29 | */ |
---|
[392] | 30 | struct module_state { |
---|
[579] | 31 | PyObject *error; |
---|
[392] | 32 | }; |
---|
| 33 | |
---|
| 34 | #if PY_MAJOR_VERSION >= 3 |
---|
| 35 | #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) |
---|
[453] | 36 | #define PyInt_FromLong PyLong_FromLong |
---|
| 37 | #define PyInt_AsLong PyLong_AsLong |
---|
| 38 | #define PyString_FromString PyUnicode_FromString |
---|
| 39 | #define PyString_FromStringAndSize PyUnicode_FromStringAndSize |
---|
| 40 | #define PyString_Check PyUnicode_Check |
---|
| 41 | #define PyString_AsString _PyUnicode_AsString |
---|
| 42 | #define PyString_Size PyUnicode_GetSize |
---|
[392] | 43 | #else |
---|
| 44 | #define GETSTATE(m) (&_state) |
---|
| 45 | static struct module_state _state; |
---|
| 46 | #endif |
---|
| 47 | |
---|
[579] | 48 | /** |
---|
| 49 | * The exception for the zoo Python module |
---|
| 50 | */ |
---|
[368] | 51 | static PyObject* ZooError; |
---|
| 52 | |
---|
[579] | 53 | /** |
---|
| 54 | * Function definitions for the zoo Python Module |
---|
| 55 | * |
---|
| 56 | * Define the following functions available from a service loaded and running |
---|
| 57 | * from the ZOO-Kernel Python environment: |
---|
| 58 | * - "_" corresponding to the PythonTranslate function |
---|
[854] | 59 | * - "update_status" corresponding to the PythonUpdateStatus function |
---|
[579] | 60 | * @see PythonTranslate, PythonUpdateStatus |
---|
| 61 | */ |
---|
[368] | 62 | PyMethodDef zooMethods[] = { |
---|
[376] | 63 | {"_", PythonTranslate, METH_VARARGS, "Translate a string using the zoo-services textdomain."}, |
---|
[368] | 64 | {"update_status", PythonUpdateStatus, METH_VARARGS, "Update status percentage of a running process."}, |
---|
| 65 | {NULL, NULL, 0, NULL} /* tempt not the blade, all fear the sentinel */ |
---|
| 66 | }; |
---|
| 67 | |
---|
[392] | 68 | #if PY_MAJOR_VERSION >= 3 |
---|
| 69 | |
---|
| 70 | static int myextension_traverse(PyObject *m, visitproc visit, void *arg) { |
---|
| 71 | Py_VISIT(GETSTATE(m)->error); |
---|
| 72 | return 0; |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | static int myextension_clear(PyObject *m) { |
---|
| 76 | Py_CLEAR(GETSTATE(m)->error); |
---|
| 77 | return 0; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | static struct PyModuleDef moduledef = { |
---|
| 81 | PyModuleDef_HEAD_INIT, |
---|
| 82 | "zoo", |
---|
| 83 | NULL, |
---|
| 84 | sizeof(struct module_state), |
---|
| 85 | zooMethods, |
---|
| 86 | NULL, |
---|
| 87 | myextension_traverse, |
---|
| 88 | myextension_clear, |
---|
| 89 | NULL |
---|
| 90 | }; |
---|
| 91 | #endif |
---|
| 92 | |
---|
[579] | 93 | /** |
---|
| 94 | * Function to create and initialize the zoo Python module |
---|
| 95 | * |
---|
| 96 | * @return the Python module (for Python versions < 3, nothing for version >=3) |
---|
| 97 | */ |
---|
[368] | 98 | PyMODINIT_FUNC init_zoo(){ |
---|
| 99 | PyObject *tmp,*d; |
---|
[392] | 100 | PyObject *module = |
---|
| 101 | #if PY_MAJOR_VERSION >= 3 |
---|
| 102 | PyModule_Create(&moduledef); |
---|
| 103 | #else |
---|
| 104 | Py_InitModule("zoo", zooMethods); |
---|
| 105 | #endif |
---|
| 106 | if (module == NULL){ |
---|
| 107 | #if PY_MAJOR_VERSION >= 3 |
---|
| 108 | return NULL; |
---|
| 109 | #else |
---|
[368] | 110 | return; |
---|
[392] | 111 | #endif |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | struct module_state *st = GETSTATE(module); |
---|
| 115 | |
---|
[368] | 116 | d = PyModule_GetDict(module); |
---|
| 117 | tmp = PyInt_FromLong(3); |
---|
| 118 | PyDict_SetItemString(d, "SERVICE_SUCCEEDED", tmp); |
---|
| 119 | Py_DECREF(tmp); |
---|
| 120 | |
---|
| 121 | tmp = PyInt_FromLong(4); |
---|
| 122 | PyDict_SetItemString(d, "SERVICE_FAILED", tmp); |
---|
| 123 | Py_DECREF(tmp); |
---|
| 124 | |
---|
[465] | 125 | tmp = PyString_FromString(ZOO_VERSION); |
---|
| 126 | PyDict_SetItemString(d, "VERSION", tmp); |
---|
| 127 | Py_DECREF(tmp); |
---|
| 128 | |
---|
[490] | 129 | ZooError = PyErr_NewException((char*)"zoo.error", NULL, NULL); |
---|
[368] | 130 | Py_INCREF(ZooError); |
---|
| 131 | PyModule_AddObject(module, "error", ZooError); |
---|
[392] | 132 | #if PY_MAJOR_VERSION >= 3 |
---|
| 133 | return module; |
---|
| 134 | #endif |
---|
[368] | 135 | } |
---|
| 136 | |
---|
[579] | 137 | /** |
---|
[580] | 138 | * Load a Python module then run the function corresponding to the service |
---|
[579] | 139 | * by passing the conf, inputs and outputs parameters by reference. |
---|
| 140 | * |
---|
| 141 | * @param main_conf the conf maps containing the main.cfg settings |
---|
| 142 | * @param request the map containing the HTTP request |
---|
| 143 | * @param s the service structure |
---|
| 144 | * @param real_inputs the maps containing the inputs |
---|
| 145 | * @param real_outputs the maps containing the outputs |
---|
| 146 | */ |
---|
[1] | 147 | int zoo_python_support(maps** main_conf,map* request,service* s,maps **real_inputs,maps **real_outputs){ |
---|
[896] | 148 | |
---|
[451] | 149 | char *pythonpath; |
---|
| 150 | char *python_path; |
---|
[896] | 151 | |
---|
| 152 | #ifdef WIN32 |
---|
[933] | 153 | const char* os_pathsep = ";"; |
---|
[896] | 154 | #else |
---|
[933] | 155 | const char* os_pathsep = ":"; |
---|
[896] | 156 | #endif |
---|
[933] | 157 | static char EMPTY[] = ""; |
---|
[896] | 158 | |
---|
[1] | 159 | maps* m=*main_conf; |
---|
| 160 | maps* inputs=*real_inputs; |
---|
| 161 | maps* outputs=*real_outputs; |
---|
[392] | 162 | map* tmp0=getMapFromMaps(*main_conf,"lenv","cwd"); |
---|
[896] | 163 | char *ntmp=tmp0->value; |
---|
[1] | 164 | map* tmp=NULL; |
---|
[451] | 165 | int hasToClean=0; |
---|
[896] | 166 | tmp=getMapFromMaps(*main_conf,"env","PYTHONPATH"); |
---|
| 167 | |
---|
| 168 | map* kvp = NULL; |
---|
| 169 | char* libPath = NULL; |
---|
| 170 | if (hasvalue(*main_conf, "main", "libPath", &kvp)) { |
---|
| 171 | libPath = kvp->value; |
---|
| 172 | } |
---|
| 173 | else { |
---|
[933] | 174 | //libPath = ""; |
---|
| 175 | libPath = EMPTY; |
---|
[896] | 176 | } |
---|
| 177 | |
---|
[63] | 178 | #ifdef DEBUG |
---|
[9] | 179 | fprintf(stderr,"PYTHON SUPPORT \n"); |
---|
[63] | 180 | #endif |
---|
[1] | 181 | if(tmp!=NULL){ |
---|
[63] | 182 | #ifdef DEBUG |
---|
[9] | 183 | fprintf(stderr,"PYTHON SUPPORT (%i)\n",strlen(tmp->value)); |
---|
[63] | 184 | #endif |
---|
[854] | 185 | python_path=(char*)malloc((strlen(tmp->value)+1)*sizeof(char)); |
---|
[9] | 186 | sprintf(python_path,"%s",tmp->value); |
---|
[451] | 187 | hasToClean=1; |
---|
[1] | 188 | } |
---|
| 189 | else{ |
---|
[784] | 190 | map* cwdMap=getMapFromMaps(*main_conf,"main","servicePath"); |
---|
| 191 | if(cwdMap!=NULL) |
---|
| 192 | python_path=cwdMap->value; |
---|
| 193 | else |
---|
[896] | 194 | python_path=(char*)"."; |
---|
[1] | 195 | } |
---|
| 196 | tmp=NULL; |
---|
| 197 | tmp=getMap(request,"metapath"); |
---|
[392] | 198 | if(tmp!=NULL && strcmp(tmp->value,"")!=0){ |
---|
[896] | 199 | //pythonpath=(char*)malloc((4+strlen(python_path)+strlen(ntmp)+strlen(tmp->value))*sizeof(char)); |
---|
| 200 | pythonpath = (char*)malloc((5 + strlen(python_path) + strlen(ntmp) + strlen(tmp->value) + strlen(libPath)) * sizeof(char)); |
---|
[1] | 201 | #ifdef WIN32 |
---|
[896] | 202 | //sprintf(pythonpath,"%s/%s/;%s",ntmp,tmp->value,python_path); |
---|
| 203 | sprintf(pythonpath, "%s/%s/;%s;%s", ntmp, tmp->value, python_path, libPath); |
---|
[1] | 204 | #else |
---|
[896] | 205 | //sprintf(pythonpath,"%s/%s/:%s",ntmp,tmp->value,python_path); |
---|
| 206 | sprintf(pythonpath, "%s/%s/:%s:%s", ntmp, tmp->value, python_path, libPath); |
---|
[1] | 207 | #endif |
---|
[392] | 208 | } |
---|
| 209 | else{ |
---|
[896] | 210 | //pythonpath=(char*)malloc((2+strlen(python_path)+strlen(ntmp))*sizeof(char)); |
---|
| 211 | pythonpath = (char*)malloc((3 + strlen(python_path) + strlen(ntmp) + strlen(libPath)) * sizeof(char)); |
---|
[1] | 212 | #ifdef WIN32 |
---|
[896] | 213 | //sprintf(pythonpath,"%s;%s",ntmp,python_path); |
---|
| 214 | sprintf(pythonpath, "%s;%s;%s", ntmp, python_path, libPath); |
---|
[1] | 215 | #else |
---|
[896] | 216 | //sprintf(pythonpath,"%s:%s",ntmp,python_path); |
---|
| 217 | sprintf(pythonpath, "%s:%s:%s", ntmp, python_path, libPath); |
---|
| 218 | #endif |
---|
[392] | 219 | } |
---|
[67] | 220 | #ifdef DEBUG |
---|
[9] | 221 | fprintf(stderr,"PYTHONPATH=%s\n",pythonpath); |
---|
[67] | 222 | #endif |
---|
[896] | 223 | map* home = NULL; |
---|
| 224 | // knut: also set PYTHONHOME environment variable so that Python can load standard modules |
---|
| 225 | #ifndef WIN32 |
---|
| 226 | setenv("PYTHONPATH",pythonpath,1); |
---|
| 227 | //= getMapFromMaps(*main_conf, "env", "PYTHONHOME"); |
---|
| 228 | if (hasvalue(*main_conf, "env", "PYTHONHOME", &home)) { |
---|
| 229 | setenv("PYTHONHOME", home->value, 1); // overwrite |
---|
| 230 | } |
---|
| 231 | #else |
---|
[1] | 232 | SetEnvironmentVariable("PYTHONPATH",pythonpath); |
---|
[364] | 233 | char* toto=(char*)malloc((strlen(pythonpath)+12)*sizeof(char)); |
---|
| 234 | sprintf(toto,"PYTHONPATH=%s",pythonpath); |
---|
[890] | 235 | _putenv(toto); |
---|
[451] | 236 | free(toto); |
---|
[896] | 237 | if (hasvalue(*main_conf, "env", "PYTHONHOME", &home)) { |
---|
| 238 | SetEnvironmentVariable("PYTHONHOME", home->value); |
---|
| 239 | } |
---|
| 240 | char buffer[128]; |
---|
| 241 | #endif |
---|
[451] | 242 | if(hasToClean>0) |
---|
| 243 | free(python_path); |
---|
[1] | 244 | free(pythonpath); |
---|
[9] | 245 | |
---|
[295] | 246 | PyThreadState *mainstate; |
---|
[896] | 247 | #if PY_MAJOR_VERSION >= 3 |
---|
| 248 | PyImport_AppendInittab("zoo", init_zoo); |
---|
[392] | 249 | #else |
---|
[295] | 250 | PyEval_InitThreads(); |
---|
[896] | 251 | #endif |
---|
| 252 | Py_Initialize(); |
---|
| 253 | #if PY_MAJOR_VERSION >= 3 |
---|
[392] | 254 | PyEval_InitThreads(); |
---|
[896] | 255 | PyImport_ImportModule("zoo"); |
---|
[392] | 256 | #else |
---|
[368] | 257 | init_zoo(); |
---|
[896] | 258 | #endif |
---|
[295] | 259 | mainstate = PyThreadState_Swap(NULL); |
---|
| 260 | PyEval_ReleaseLock(); |
---|
| 261 | PyGILState_STATE gstate; |
---|
| 262 | gstate = PyGILState_Ensure(); |
---|
[1] | 263 | PyObject *pName, *pModule, *pFunc; |
---|
| 264 | tmp=getMap(s->content,"serviceProvider"); |
---|
[505] | 265 | map* mp=getMap(request,"metapath"); |
---|
| 266 | if(tmp!=NULL){ |
---|
| 267 | if(mp!=NULL && strlen(mp->value)>0){ |
---|
| 268 | char *mps=zStrdup(mp->value); |
---|
| 269 | int i,len=strlen(mps); |
---|
| 270 | int j=0; |
---|
| 271 | for(i=0;i<len;i++){ |
---|
| 272 | if(mps[i]=='/'){ |
---|
| 273 | mps[i]='.'; |
---|
| 274 | } |
---|
| 275 | } |
---|
| 276 | char *mn=(char*)malloc((strlen(mps)+strlen(tmp->value)+2)*sizeof(char)); |
---|
| 277 | sprintf(mn,"%s.%s",mps,tmp->value); |
---|
[896] | 278 | pName = PyString_FromString(mn); |
---|
[505] | 279 | free(mn); |
---|
| 280 | free(mps); |
---|
| 281 | } |
---|
| 282 | else{ |
---|
| 283 | pName = PyString_FromString(tmp->value); |
---|
| 284 | } |
---|
| 285 | } |
---|
[9] | 286 | else{ |
---|
[576] | 287 | errorException (m, "Unable to parse serviceProvider please check your zcfg file.", "NoApplicableCode", NULL); |
---|
[9] | 288 | exit(-1); |
---|
[896] | 289 | } |
---|
| 290 | pModule = PyImport_Import(pName); |
---|
[1] | 291 | int res=SERVICE_FAILED; |
---|
| 292 | if (pModule != NULL) { |
---|
| 293 | pFunc=PyObject_GetAttrString(pModule,s->name); |
---|
| 294 | if (pFunc && PyCallable_Check(pFunc)){ |
---|
[114] | 295 | PyObject *pValue; |
---|
[1] | 296 | PyDictObject* arg1=PyDict_FromMaps(m); |
---|
| 297 | PyDictObject* arg2=PyDict_FromMaps(inputs); |
---|
| 298 | PyDictObject* arg3=PyDict_FromMaps(outputs); |
---|
| 299 | PyObject *pArgs=PyTuple_New(3); |
---|
[114] | 300 | if (!pArgs) |
---|
| 301 | return -1; |
---|
[1] | 302 | PyTuple_SetItem(pArgs, 0, (PyObject *)arg1); |
---|
| 303 | PyTuple_SetItem(pArgs, 1, (PyObject *)arg2); |
---|
| 304 | PyTuple_SetItem(pArgs, 2, (PyObject *)arg3); |
---|
[896] | 305 | pValue = PyObject_CallObject(pFunc, pArgs); |
---|
[1] | 306 | if (pValue != NULL) { |
---|
| 307 | res=PyInt_AsLong(pValue); |
---|
[9] | 308 | freeMaps(real_outputs); |
---|
| 309 | free(*real_outputs); |
---|
[59] | 310 | freeMaps(main_conf); |
---|
| 311 | free(*main_conf); |
---|
[57] | 312 | *main_conf=mapsFromPyDict(arg1); |
---|
[896] | 313 | *real_outputs=mapsFromPyDict(arg3); |
---|
[1] | 314 | #ifdef DEBUG |
---|
| 315 | fprintf(stderr,"Result of call: %i\n", PyInt_AsLong(pValue)); |
---|
| 316 | dumpMaps(inputs); |
---|
[364] | 317 | dumpMaps(*real_outputs); |
---|
[1] | 318 | #endif |
---|
[854] | 319 | }else{ |
---|
[576] | 320 | PythonZooReport(m,tmp->value,0); |
---|
[295] | 321 | res=-1; |
---|
[1] | 322 | } |
---|
| 323 | } |
---|
| 324 | else{ |
---|
| 325 | char tmpS[1024]; |
---|
[295] | 326 | sprintf(tmpS, "Cannot find the %s function in the %s file.\n", s->name, tmp->value); |
---|
[576] | 327 | errorException(m,tmpS,"NoApplicableCode",NULL); |
---|
[295] | 328 | res=-1; |
---|
[1] | 329 | } |
---|
| 330 | } else{ |
---|
[576] | 331 | PythonZooReport(m,tmp->value,1); |
---|
[295] | 332 | res=-1; |
---|
[1] | 333 | } |
---|
[392] | 334 | #if PY_MAJOR_VERSION < 3 |
---|
[295] | 335 | PyGILState_Release(gstate); |
---|
[478] | 336 | PyEval_AcquireLock(); |
---|
[392] | 337 | #endif |
---|
[295] | 338 | PyThreadState_Swap(mainstate); |
---|
[896] | 339 | Py_Finalize(); |
---|
[1] | 340 | return res; |
---|
| 341 | } |
---|
| 342 | |
---|
[579] | 343 | /** |
---|
[580] | 344 | * Report Python error which may occur on loading the Python module or at |
---|
[579] | 345 | * runtime. |
---|
| 346 | * |
---|
| 347 | * @param m the conf maps containing the main.cfg settings |
---|
| 348 | * @param module the service name |
---|
| 349 | * @param load 1 if the Python module was not loaded yet |
---|
| 350 | */ |
---|
[576] | 351 | void PythonZooReport(maps* m,const char* module,int load){ |
---|
| 352 | PyObject *pName, *pModule, *pFunc; |
---|
| 353 | PyObject *ptype, *pvalue, *ptraceback,*pValue,*pArgs; |
---|
| 354 | PyErr_Fetch(&ptype, &pvalue, &ptraceback); |
---|
| 355 | char *pStrErrorMessage = PyString_AsString(pvalue); |
---|
| 356 | char *tmp0=_("Python module %s cannot be loaded. Message: %s\n"); |
---|
| 357 | |
---|
| 358 | PyObject *trace=PyObject_Str(pvalue); |
---|
| 359 | char *pbt=NULL; |
---|
| 360 | if(PyString_Check(trace)){ |
---|
[854] | 361 | pbt=(char*)malloc((8+strlen(PyString_AsString(trace)))*sizeof(char)); |
---|
[576] | 362 | sprintf(pbt,"TRACE: %s",PyString_AsString(trace)); |
---|
| 363 | } |
---|
| 364 | else |
---|
| 365 | fprintf(stderr,"EMPTY TRACE ?"); |
---|
[854] | 366 | |
---|
[576] | 367 | trace=NULL; |
---|
| 368 | |
---|
| 369 | trace=PyObject_Str(ptype); |
---|
| 370 | if(PyString_Check(trace)){ |
---|
| 371 | char *tpbt=zStrdup(pbt); |
---|
| 372 | if(pbt!=NULL) |
---|
| 373 | free(pbt); |
---|
| 374 | pbt=(char*)malloc((1+strlen(tpbt)+strlen(PyString_AsString(trace))+1)*sizeof(char)); |
---|
| 375 | sprintf(pbt,"%s\n%s",tpbt,PyString_AsString(trace)); |
---|
| 376 | free(tpbt); |
---|
| 377 | } |
---|
| 378 | else |
---|
| 379 | fprintf(stderr,"EMPTY TRACE ?"); |
---|
| 380 | |
---|
| 381 | if(ptraceback!=NULL){ |
---|
| 382 | char *tpbt=zStrdup(pbt); |
---|
| 383 | pName = PyString_FromString("traceback"); |
---|
| 384 | pModule = PyImport_Import(pName); |
---|
| 385 | pArgs = PyTuple_New(1); |
---|
| 386 | PyTuple_SetItem(pArgs, 0, ptraceback); |
---|
| 387 | pFunc = PyObject_GetAttrString(pModule,"format_tb"); |
---|
| 388 | pValue = PyObject_CallObject(pFunc, pArgs); |
---|
| 389 | trace=NULL; |
---|
| 390 | trace=PyObject_Str(pValue); |
---|
| 391 | if(PyString_Check(trace)){ |
---|
| 392 | if(pbt!=NULL) |
---|
| 393 | free(pbt); |
---|
[790] | 394 | char* format=_("%s\nUnable to run your python process properly. Please check the following messages : %s"); |
---|
| 395 | pbt=(char*)malloc((strlen(format)+strlen(tpbt)+strlen(PyString_AsString(trace))+1)*sizeof(char)); |
---|
| 396 | sprintf(pbt,format,tpbt,PyString_AsString(trace)); |
---|
[576] | 397 | } |
---|
| 398 | else{ |
---|
| 399 | if(pbt!=NULL) |
---|
| 400 | free(pbt); |
---|
[790] | 401 | char* format=_("%s \n Unable to run your python process properly. Unable to provide any further information."); |
---|
| 402 | pbt=(char*)malloc((strlen(format)+strlen(tpbt)+strlen(PyString_AsString(trace))+1)*sizeof(char)); |
---|
| 403 | sprintf(pbt,format,tpbt); |
---|
[576] | 404 | } |
---|
| 405 | free(tpbt); |
---|
| 406 | } |
---|
| 407 | if(load>0){ |
---|
| 408 | char *tmpS=(char*)malloc((strlen(tmp0)+strlen(module)+strlen(pbt)+1)*sizeof(char)); |
---|
| 409 | sprintf(tmpS,tmp0,module,pbt); |
---|
| 410 | errorException(m,tmpS,"NoApplicableCode",NULL); |
---|
| 411 | free(tmpS); |
---|
| 412 | }else |
---|
| 413 | errorException(m,pbt,"NoApplicableCode",NULL); |
---|
| 414 | free(pbt); |
---|
| 415 | } |
---|
| 416 | |
---|
[579] | 417 | /** |
---|
| 418 | * Convert a maps to a Python dictionary |
---|
| 419 | * |
---|
| 420 | * @param t the maps to convert |
---|
| 421 | * @return a new PyDictObject containing the converted maps |
---|
| 422 | * @see PyDict_FromMap |
---|
[781] | 423 | * @warning make sure to free resources returned by this function |
---|
[579] | 424 | */ |
---|
[1] | 425 | PyDictObject* PyDict_FromMaps(maps* t){ |
---|
| 426 | PyObject* res=PyDict_New( ); |
---|
| 427 | maps* tmp=t; |
---|
| 428 | while(tmp!=NULL){ |
---|
[295] | 429 | PyObject* value=(PyObject*)PyDict_FromMap(tmp->content); |
---|
[790] | 430 | if(tmp->child!=NULL){ |
---|
| 431 | PyObject* cname=PyString_FromString("child"); |
---|
| 432 | PyObject* childs=(PyObject*)PyDict_FromMaps(tmp->child); |
---|
| 433 | if(PyDict_SetItem(value,cname,childs)<0){ |
---|
| 434 | fprintf(stderr,"Unable to set map value ..."); |
---|
| 435 | return NULL; |
---|
| 436 | } |
---|
| 437 | Py_DECREF(cname); |
---|
| 438 | } |
---|
[453] | 439 | PyObject* name=PyString_FromString(tmp->name); |
---|
[295] | 440 | if(PyDict_SetItem(res,name,value)<0){ |
---|
| 441 | fprintf(stderr,"Unable to set map value ..."); |
---|
| 442 | return NULL; |
---|
[1] | 443 | } |
---|
[295] | 444 | Py_DECREF(name); |
---|
[1] | 445 | tmp=tmp->next; |
---|
| 446 | } |
---|
| 447 | return (PyDictObject*) res; |
---|
| 448 | } |
---|
| 449 | |
---|
[579] | 450 | /** |
---|
| 451 | * Convert a map to a Python dictionary |
---|
| 452 | * |
---|
| 453 | * @param t the map to convert |
---|
| 454 | * @return a new PyDictObject containing the converted maps |
---|
[781] | 455 | * @warning make sure to free resources returned by this function |
---|
[579] | 456 | */ |
---|
[1] | 457 | PyDictObject* PyDict_FromMap(map* t){ |
---|
| 458 | PyObject* res=PyDict_New( ); |
---|
| 459 | map* tmp=t; |
---|
[360] | 460 | int hasSize=0; |
---|
| 461 | map* isArray=getMap(tmp,"isArray"); |
---|
[58] | 462 | map* size=getMap(tmp,"size"); |
---|
[863] | 463 | map* useFile=getMap(tmp,"use_file"); |
---|
| 464 | map* cacheFile=getMap(tmp,"cache_file"); |
---|
[360] | 465 | map* tmap=getMapType(tmp); |
---|
[1] | 466 | while(tmp!=NULL){ |
---|
[453] | 467 | PyObject* name=PyString_FromString(tmp->name); |
---|
[360] | 468 | if(strcasecmp(tmp->name,"value")==0) { |
---|
| 469 | if(isArray!=NULL){ |
---|
| 470 | map* len=getMap(tmp,"length"); |
---|
| 471 | int cnt=atoi(len->value); |
---|
| 472 | PyObject* value=PyList_New(cnt); |
---|
| 473 | PyObject* mvalue=PyList_New(cnt); |
---|
| 474 | PyObject* svalue=PyList_New(cnt); |
---|
[863] | 475 | PyObject* cvalue=PyList_New(cnt); |
---|
[360] | 476 | |
---|
| 477 | for(int i=0;i<cnt;i++){ |
---|
| 478 | |
---|
[863] | 479 | map* vMap=getMapArray(t,"value",i); |
---|
| 480 | map* uMap=getMapArray(t,"use_file",i); |
---|
| 481 | map* sMap=getMapArray(t,"size",i); |
---|
| 482 | map* cMap=getMapArray(t,"cache_file",i); |
---|
[360] | 483 | |
---|
| 484 | if(vMap!=NULL){ |
---|
| 485 | |
---|
| 486 | PyObject* lvalue; |
---|
| 487 | PyObject* lsvalue; |
---|
[863] | 488 | PyObject* lcvalue; |
---|
| 489 | if(sMap==NULL || uMap!=NULL){ |
---|
[360] | 490 | lvalue=PyString_FromString(vMap->value); |
---|
| 491 | } |
---|
[453] | 492 | else{ |
---|
[360] | 493 | lvalue=PyString_FromStringAndSize(vMap->value,atoi(sMap->value)); |
---|
[863] | 494 | } |
---|
| 495 | if(sMap!=NULL){ |
---|
[360] | 496 | lsvalue=PyString_FromString(sMap->value); |
---|
| 497 | hasSize=1; |
---|
| 498 | } |
---|
[863] | 499 | else |
---|
| 500 | lsvalue=Py_None; |
---|
| 501 | if(uMap!=NULL){ |
---|
| 502 | lcvalue=PyString_FromString(cMap->value);; |
---|
| 503 | }else |
---|
| 504 | lcvalue=Py_None; |
---|
[360] | 505 | |
---|
| 506 | if(PyList_SetItem(value,i,lvalue)<0){ |
---|
| 507 | fprintf(stderr,"Unable to set key value pair..."); |
---|
| 508 | return NULL; |
---|
| 509 | } |
---|
| 510 | if(PyList_SetItem(svalue,i,lsvalue)<0){ |
---|
| 511 | fprintf(stderr,"Unable to set key value pair..."); |
---|
| 512 | return NULL; |
---|
| 513 | } |
---|
[863] | 514 | if(PyList_SetItem(cvalue,i,lcvalue)<0){ |
---|
| 515 | fprintf(stderr,"Unable to set key value pair..."); |
---|
| 516 | return NULL; |
---|
| 517 | } |
---|
[360] | 518 | } |
---|
| 519 | |
---|
[863] | 520 | PyObject* lmvalue; |
---|
[360] | 521 | map* mMap=getMapArray(tmp,tmap->name,i); |
---|
| 522 | if(mMap!=NULL){ |
---|
| 523 | lmvalue=PyString_FromString(mMap->value); |
---|
| 524 | }else |
---|
| 525 | lmvalue=Py_None; |
---|
| 526 | |
---|
| 527 | if(PyList_SetItem(mvalue,i,lmvalue)<0){ |
---|
| 528 | fprintf(stderr,"Unable to set key value pair..."); |
---|
| 529 | return NULL; |
---|
| 530 | } |
---|
| 531 | |
---|
| 532 | } |
---|
| 533 | |
---|
| 534 | if(PyDict_SetItem(res,name,value)<0){ |
---|
| 535 | fprintf(stderr,"Unable to set key value pair..."); |
---|
| 536 | return NULL; |
---|
| 537 | } |
---|
| 538 | if(PyDict_SetItem(res,PyString_FromString(tmap->name),mvalue)<0){ |
---|
| 539 | fprintf(stderr,"Unable to set key value pair..."); |
---|
| 540 | return NULL; |
---|
| 541 | } |
---|
[863] | 542 | if(PyDict_SetItem(res,PyString_FromString("cache_file"),cvalue)<0){ |
---|
| 543 | fprintf(stderr,"Unable to set key value pair..."); |
---|
| 544 | return NULL; |
---|
| 545 | } |
---|
[360] | 546 | if(hasSize>0) |
---|
| 547 | if(PyDict_SetItem(res,PyString_FromString("size"),svalue)<0){ |
---|
| 548 | fprintf(stderr,"Unable to set key value pair..."); |
---|
| 549 | return NULL; |
---|
| 550 | } |
---|
| 551 | } |
---|
[863] | 552 | else if(size!=NULL && useFile==NULL){ |
---|
[453] | 553 | PyObject* value=PyString_FromStringAndSize(tmp->value,atoi(size->value)); |
---|
[59] | 554 | if(PyDict_SetItem(res,name,value)<0){ |
---|
[471] | 555 | Py_DECREF(value); |
---|
[295] | 556 | fprintf(stderr,"Unable to set key value pair..."); |
---|
| 557 | return NULL; |
---|
[43] | 558 | } |
---|
[471] | 559 | Py_DECREF(value); |
---|
[58] | 560 | } |
---|
[59] | 561 | else{ |
---|
[453] | 562 | PyObject* value=PyString_FromString(tmp->value); |
---|
[59] | 563 | if(PyDict_SetItem(res,name,value)<0){ |
---|
[471] | 564 | Py_DECREF(value); |
---|
[295] | 565 | fprintf(stderr,"Unable to set key value pair..."); |
---|
| 566 | return NULL; |
---|
[43] | 567 | } |
---|
[471] | 568 | Py_DECREF(value); |
---|
[59] | 569 | } |
---|
| 570 | } |
---|
| 571 | else{ |
---|
[360] | 572 | if(PyDict_GetItem(res,name)==NULL){ |
---|
[453] | 573 | PyObject* value=PyString_FromString(tmp->value); |
---|
[360] | 574 | if(PyDict_SetItem(res,name,value)<0){ |
---|
[471] | 575 | Py_DECREF(value); |
---|
[360] | 576 | fprintf(stderr,"Unable to set key value pair..."); |
---|
| 577 | return NULL; |
---|
| 578 | } |
---|
[471] | 579 | Py_DECREF(value); |
---|
[43] | 580 | } |
---|
[59] | 581 | } |
---|
| 582 | Py_DECREF(name); |
---|
[1] | 583 | tmp=tmp->next; |
---|
| 584 | } |
---|
| 585 | return (PyDictObject*) res; |
---|
| 586 | } |
---|
| 587 | |
---|
[579] | 588 | /** |
---|
| 589 | * Convert a Python dictionary to a maps |
---|
| 590 | * |
---|
| 591 | * @param t the PyDictObject to convert |
---|
| 592 | * @return a new maps containing the converted PyDictObject |
---|
[781] | 593 | * @warning make sure to free resources returned by this function |
---|
[579] | 594 | */ |
---|
[1] | 595 | maps* mapsFromPyDict(PyDictObject* t){ |
---|
| 596 | maps* res=NULL; |
---|
[682] | 597 | maps* cursor=NULL; |
---|
[1] | 598 | PyObject* list=PyDict_Keys((PyObject*)t); |
---|
| 599 | int nb=PyList_Size(list); |
---|
| 600 | int i; |
---|
[682] | 601 | PyObject* key; |
---|
| 602 | PyObject* value; |
---|
[1] | 603 | for(i=0;i<nb;i++){ |
---|
| 604 | #ifdef DEBUG |
---|
| 605 | fprintf(stderr,">> parsing maps %d\n",i); |
---|
| 606 | #endif |
---|
[682] | 607 | key=PyList_GetItem(list,i); |
---|
| 608 | value=PyDict_GetItem((PyObject*)t,key); |
---|
[1] | 609 | #ifdef DEBUG |
---|
| 610 | fprintf(stderr,">> DEBUG VALUES : %s => %s\n", |
---|
| 611 | PyString_AsString(key),PyString_AsString(value)); |
---|
| 612 | #endif |
---|
[790] | 613 | cursor=createMaps(PyString_AsString(key)); |
---|
[295] | 614 | cursor->content=mapFromPyDict((PyDictObject*)value); |
---|
[790] | 615 | PyObject* cname=PyString_FromString("child"); |
---|
| 616 | PyObject* childs=PyDict_GetItem((PyObject*)value,cname); |
---|
| 617 | if(childs!=NULL) |
---|
| 618 | cursor->child=mapsFromPyDict((PyDictObject*)childs); |
---|
| 619 | Py_DECREF(cname); |
---|
[1] | 620 | #ifdef DEBUG |
---|
[295] | 621 | dumpMap(cursor->content); |
---|
[1] | 622 | #endif |
---|
| 623 | cursor->next=NULL; |
---|
| 624 | if(res==NULL) |
---|
[59] | 625 | res=dupMaps(&cursor); |
---|
[1] | 626 | else |
---|
| 627 | addMapsToMaps(&res,cursor); |
---|
[59] | 628 | freeMap(&cursor->content); |
---|
| 629 | free(cursor->content); |
---|
| 630 | free(cursor); |
---|
[1] | 631 | #ifdef DEBUG |
---|
| 632 | dumpMaps(res); |
---|
| 633 | fprintf(stderr,">> parsed maps %d\n",i); |
---|
| 634 | #endif |
---|
| 635 | } |
---|
[505] | 636 | Py_DECREF(list); |
---|
[1] | 637 | return res; |
---|
| 638 | } |
---|
| 639 | |
---|
[579] | 640 | /** |
---|
[738] | 641 | * Convert a Python dictionary to a maps |
---|
| 642 | * |
---|
| 643 | * @param t the PyDictObject to convert |
---|
| 644 | * @return a new maps containing the converted PyDictObject |
---|
| 645 | * @warning make sure to free resources returned by this function |
---|
| 646 | */ |
---|
| 647 | maps* _mapsFromPyDict(PyDictObject* t){ |
---|
| 648 | |
---|
| 649 | PyObject* list = PyDict_Keys((PyObject*)t); // new ref |
---|
| 650 | int nb = PyList_Size(list); |
---|
| 651 | |
---|
| 652 | if (nb < 1) { |
---|
| 653 | Py_DECREF(list); |
---|
| 654 | return NULL; |
---|
| 655 | } |
---|
| 656 | |
---|
| 657 | maps* ptr = (maps*) malloc(MAPS_SIZE); |
---|
| 658 | maps* res = ptr; |
---|
| 659 | |
---|
| 660 | PyObject* key; |
---|
| 661 | PyObject* value; |
---|
| 662 | |
---|
| 663 | for(int i = 0; i < nb; i++) { |
---|
| 664 | |
---|
| 665 | key = PyList_GetItem(list,i); // borrowed ref |
---|
| 666 | value = PyDict_GetItem((PyObject*) t, key); // borrowed ref |
---|
| 667 | |
---|
| 668 | ptr->name = zStrdup(PyString_AsString(key)); |
---|
| 669 | ptr->content = mapFromPyDict((PyDictObject*) value); |
---|
| 670 | |
---|
| 671 | ptr->next = i < nb - 1 ? (maps*) malloc(MAPS_SIZE) : NULL; |
---|
| 672 | ptr = ptr->next; |
---|
| 673 | } |
---|
| 674 | Py_DECREF(list); |
---|
| 675 | |
---|
| 676 | return res; |
---|
| 677 | } // mapsFromPyDict |
---|
| 678 | |
---|
| 679 | /** |
---|
[579] | 680 | * Convert a Python dictionary to a map |
---|
| 681 | * |
---|
| 682 | * @param t the PyDictObject to convert |
---|
| 683 | * @return a new map containing the converted PyDictObject |
---|
[781] | 684 | * @warning make sure to free resources returned by this function |
---|
[579] | 685 | */ |
---|
[1] | 686 | map* mapFromPyDict(PyDictObject* t){ |
---|
| 687 | map* res=NULL; |
---|
| 688 | PyObject* list=PyDict_Keys((PyObject*)t); |
---|
| 689 | int nb=PyList_Size(list); |
---|
| 690 | int i; |
---|
[682] | 691 | PyObject* key; |
---|
| 692 | PyObject* value; |
---|
[1] | 693 | for(i=0;i<nb;i++){ |
---|
[682] | 694 | key=PyList_GetItem(list,i); |
---|
| 695 | value=PyDict_GetItem((PyObject*)t,key); |
---|
[1] | 696 | #ifdef DEBUG |
---|
| 697 | fprintf(stderr,">> DEBUG VALUES : %s => %s\n", |
---|
| 698 | PyString_AsString(key),PyString_AsString(value)); |
---|
| 699 | #endif |
---|
[790] | 700 | if(strncmp(PyString_AsString(key),"child",5)!=0){ |
---|
| 701 | if(strncmp(PyString_AsString(key),"value",5)==0){ |
---|
| 702 | char *buffer=NULL; |
---|
| 703 | Py_ssize_t size; |
---|
[392] | 704 | #if PY_MAJOR_VERSION >= 3 |
---|
[790] | 705 | if(PyBytes_Check(value)){ |
---|
| 706 | size=PyBytes_Size(value); |
---|
| 707 | buffer=PyBytes_AsString(value); |
---|
[682] | 708 | } |
---|
[790] | 709 | else |
---|
| 710 | if(PyUnicode_Check(value) && PyUnicode_READY(value) == 0){ |
---|
| 711 | buffer=PyUnicode_AsUTF8AndSize(value,&size); |
---|
| 712 | } |
---|
| 713 | else{ |
---|
[738] | 714 | #ifdef DEBUG |
---|
[790] | 715 | fprintf(stderr,"Unsupported return value."); |
---|
[738] | 716 | #endif |
---|
[790] | 717 | return NULL; |
---|
| 718 | } |
---|
[392] | 719 | #else |
---|
[790] | 720 | PyString_AsStringAndSize(value,&buffer,&size); |
---|
[738] | 721 | #endif |
---|
[790] | 722 | res = addToMapWithSize(res,PyString_AsString(key),buffer,size); |
---|
| 723 | }else{ |
---|
| 724 | char* lkey=PyString_AsString(key); |
---|
| 725 | char* lvalue=PyString_AsString(value); |
---|
| 726 | if(res!=NULL){ |
---|
| 727 | if(PyString_Size(value)>0) |
---|
| 728 | addToMap(res,lkey,lvalue); |
---|
| 729 | } |
---|
| 730 | else{ |
---|
| 731 | if(PyString_Size(value)>0) |
---|
| 732 | res=createMap(lkey,lvalue); |
---|
| 733 | } |
---|
[392] | 734 | } |
---|
[67] | 735 | } |
---|
[1] | 736 | } |
---|
[505] | 737 | Py_DECREF(list); |
---|
[1] | 738 | return res; |
---|
| 739 | } |
---|
[368] | 740 | |
---|
[579] | 741 | /** |
---|
[738] | 742 | * Convert a Python dictionary to a map |
---|
| 743 | * |
---|
| 744 | * @param t the PyDictObject to convert |
---|
| 745 | * @return a new map containing the converted PyDictObject |
---|
| 746 | * @warning make sure to free resources returned by this function |
---|
| 747 | */ |
---|
| 748 | map* _mapFromPyDict(PyDictObject* t) { |
---|
| 749 | |
---|
| 750 | PyObject* list = PyDict_Keys((PyObject*) t); // new ref |
---|
| 751 | int nb = PyList_Size(list); |
---|
| 752 | |
---|
| 753 | if (nb < 1) { |
---|
| 754 | Py_DECREF(list); |
---|
| 755 | return NULL; |
---|
| 756 | } |
---|
| 757 | |
---|
| 758 | map* ptr = (map*) malloc(MAP_SIZE); |
---|
| 759 | map* res = ptr; |
---|
| 760 | |
---|
| 761 | PyObject* key; |
---|
| 762 | PyObject* value; |
---|
| 763 | char *buffer = NULL; |
---|
| 764 | Py_ssize_t size; |
---|
| 765 | for(int i = 0; i < nb; i++) { |
---|
| 766 | |
---|
| 767 | key = PyList_GetItem(list, i); // borrowed ref |
---|
| 768 | value = PyDict_GetItem((PyObject*) t, key); // borrowed ref |
---|
| 769 | |
---|
| 770 | ptr->name = zStrdup(PyString_AsString(key)); |
---|
| 771 | map* msize = NULL; |
---|
| 772 | |
---|
| 773 | #if PY_MAJOR_VERSION >= 3 |
---|
| 774 | if (PyBytes_Check(value)) { |
---|
| 775 | // value is byte array |
---|
| 776 | size = PyBytes_Size(value); |
---|
| 777 | buffer = PyBytes_AsString(value); // pointer to internal buffer |
---|
| 778 | char sz[32]; |
---|
| 779 | sprintf(sz, "%d", (int) size); |
---|
| 780 | msize = createMap("size", sz); |
---|
| 781 | } |
---|
| 782 | else if (PyUnicode_Check(value) && PyUnicode_READY(value) == 0) { |
---|
| 783 | // value is string object |
---|
| 784 | buffer = PyUnicode_AsUTF8AndSize(value, &size); |
---|
| 785 | size++; |
---|
| 786 | } |
---|
| 787 | else { |
---|
| 788 | printf("Type not recognized\n"); |
---|
| 789 | // error handling |
---|
| 790 | // ... |
---|
| 791 | } |
---|
| 792 | #else |
---|
| 793 | PyString_AsStringAndSize(value, &buffer, &size); |
---|
| 794 | size++; |
---|
| 795 | // to do: handle byte arrays |
---|
| 796 | #endif |
---|
| 797 | |
---|
| 798 | ptr->value = (char*) malloc(size); // check for NULL pointer |
---|
| 799 | memmove(ptr->value, buffer, size); |
---|
| 800 | |
---|
| 801 | if (msize != NULL) { |
---|
| 802 | ptr->next = msize; |
---|
| 803 | ptr = ptr->next; |
---|
| 804 | } |
---|
| 805 | |
---|
| 806 | ptr->next = i < nb - 1 ? (map*) malloc(MAP_SIZE) : NULL; |
---|
| 807 | ptr = ptr->next; |
---|
| 808 | } |
---|
| 809 | Py_DECREF(list); |
---|
| 810 | |
---|
| 811 | return res; |
---|
| 812 | } // mapFromPyDict |
---|
| 813 | |
---|
| 814 | /** |
---|
[580] | 815 | * Use the ZOO-Services messages translation function from the Python |
---|
[579] | 816 | * environment |
---|
| 817 | * |
---|
| 818 | * @param self the Python object on which we can run the method |
---|
| 819 | * @param args the Python arguments given from the Python environment |
---|
[581] | 820 | * @return a new Python string containing the translated value |
---|
[579] | 821 | * @see _ss |
---|
| 822 | */ |
---|
[368] | 823 | PyObject* |
---|
[376] | 824 | PythonTranslate(PyObject* self, PyObject* args) |
---|
| 825 | { |
---|
| 826 | char *str; |
---|
| 827 | if (!PyArg_ParseTuple(args, "s", &str)){ |
---|
| 828 | #ifdef DEBUG |
---|
| 829 | fprintf(stderr,"Incorrect arguments to update status function"); |
---|
| 830 | #endif |
---|
| 831 | return NULL; |
---|
| 832 | } |
---|
| 833 | return PyString_FromString(_ss(str)); |
---|
| 834 | } |
---|
| 835 | |
---|
[579] | 836 | /** |
---|
| 837 | * Update the ongoing status of a running service from the Python environment |
---|
| 838 | * |
---|
| 839 | * @param self the Python object on which we can run the method |
---|
| 840 | * @param args the Python arguments given from the Python environment |
---|
| 841 | * @return None to the Python environment |
---|
| 842 | * @see _updateStatus |
---|
| 843 | */ |
---|
[376] | 844 | PyObject* |
---|
[368] | 845 | PythonUpdateStatus(PyObject* self, PyObject* args) |
---|
| 846 | { |
---|
| 847 | maps* conf; |
---|
| 848 | PyObject* confdict; |
---|
| 849 | int istatus; |
---|
[624] | 850 | char* status=NULL; |
---|
[368] | 851 | if (!PyArg_ParseTuple(args, "O!i", &PyDict_Type, &confdict, &istatus)){ |
---|
| 852 | #ifdef DEBUG |
---|
| 853 | fprintf(stderr,"Incorrect arguments to update status function"); |
---|
| 854 | #endif |
---|
[624] | 855 | Py_RETURN_NONE; |
---|
[368] | 856 | } |
---|
| 857 | if (istatus < 0 || istatus > 100){ |
---|
| 858 | PyErr_SetString(ZooError, "Status must be a percentage."); |
---|
[624] | 859 | Py_RETURN_NONE; |
---|
[368] | 860 | }else{ |
---|
| 861 | char tmpStatus[4]; |
---|
| 862 | snprintf(tmpStatus, 4, "%i", istatus); |
---|
[453] | 863 | status = zStrdup(tmpStatus); |
---|
[368] | 864 | } |
---|
[624] | 865 | // create a local copy and update the lenv map |
---|
[368] | 866 | conf = mapsFromPyDict((PyDictObject*)confdict); |
---|
[624] | 867 | if(status!=NULL){ |
---|
| 868 | setMapInMaps(conf,"lenv","status",status); |
---|
| 869 | free(status); |
---|
[368] | 870 | } |
---|
[624] | 871 | else |
---|
| 872 | setMapInMaps(conf,"lenv","status","15"); |
---|
| 873 | _updateStatus(conf); |
---|
[368] | 874 | freeMaps(&conf); |
---|
| 875 | free(conf); |
---|
| 876 | Py_RETURN_NONE; |
---|
| 877 | } |
---|