Changeset 59 for trunk/zoo-kernel/service_internal_python.c
- Timestamp:
- Jan 6, 2011, 10:50:56 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-kernel/service_internal_python.c
r58 r59 106 106 freeMaps(real_outputs); 107 107 free(*real_outputs); 108 //*real_inputs=mapsFromPyDict(arg2);109 //createMapsFromPyDict(real_outputs,arg3);108 freeMaps(main_conf); 109 free(*main_conf); 110 110 *main_conf=mapsFromPyDict(arg1); 111 111 *real_outputs=mapsFromPyDict(arg3); … … 134 134 trace=NULL; 135 135 trace=PyObject_Str(ptype); 136 if(PyString_Check(trace)) 137 sprintf(pbt,"%s\nTRACE : %s",strdup(pbt),PyString_AsString(trace)); 136 if(PyString_Check(trace)){ 137 char *tpbt=strdup(pbt); 138 sprintf(pbt,"%s\nTRACE : %s",tpbt,PyString_AsString(trace)); 139 free(tpbt); 140 } 138 141 else 139 142 fprintf(stderr,"EMPTY TRACE ?"); … … 148 151 trace=PyObject_Str(pValue); 149 152 if(PyString_Check(trace)) 150 sprintf(pbt,"%s\nUnable to run your python process properly. Please check the following messages : %s", strdup(pbt),PyString_AsString(trace));153 sprintf(pbt,"%s\nUnable to run your python process properly. Please check the following messages : %s",pbt,PyString_AsString(trace)); 151 154 else 152 sprintf(pbt,"%s \n Unable to run your python process properly. Unable to provide any futher informations.", strdup(pbt));155 sprintf(pbt,"%s \n Unable to run your python process properly. Unable to provide any futher informations.",pbt); 153 156 map* err=createMap("text",pbt); 154 157 addToMap(err,"code","NoApplicableCode"); 155 158 printExceptionReportResponse(m,err); 159 Py_DECREF(arg1); 160 Py_DECREF(arg2); 161 Py_DECREF(arg3); 156 162 Py_XDECREF(pFunc); 157 163 Py_DECREF(pArgs); 158 164 Py_DECREF(pModule); 165 Py_DECREF(ptraceback); 166 Py_DECREF(ptype); 167 Py_DECREF(pValue); 168 Py_Finalize(); 159 169 exit(-1); 160 170 } … … 178 188 exit(-1); 179 189 } 180 #ifndef DEBUG181 // Failed when DEBUG is defined182 190 Py_Finalize(); 183 #endif184 191 return res; 185 192 } … … 189 196 maps* tmp=t; 190 197 while(tmp!=NULL){ 191 if(PyDict_SetItem(res,PyString_FromString(tmp->name),(PyObject*)PyDict_FromMap(tmp->content))<0){ 198 PyObject* subc=PyDict_FromMap(tmp->content); 199 if(PyDict_SetItem(res,PyString_FromString(tmp->name),subc)<0){ 192 200 fprintf(stderr,"Unable to parse params..."); 193 201 exit(1); 194 202 } 203 Py_DECREF(subc); 195 204 tmp=tmp->next; 196 205 } … … 202 211 map* tmp=t; 203 212 map* size=getMap(tmp,"size"); 204 dumpMap(t);205 213 while(tmp!=NULL){ 206 fprintf(stderr,"%s => %s\n"),tmp->name,tmp->value;214 PyObject* name=PyString_FromString(tmp->name); 207 215 if(strcasecmp(tmp->name,"value")==0){ 208 216 if(size!=NULL){ 209 if(PyDict_SetItem(res,PyString_FromString(tmp->name),PyString_FromStringAndSize(tmp->value,(Py_ssize_t) atoi(size->value)))<0){ 217 PyObject* value=PyString_FromStringAndSize(tmp->value,atoi(size->value)); 218 if(PyDict_SetItem(res,name,value)<0){ 210 219 fprintf(stderr,"Unable to parse params..."); 211 220 exit(1); 212 221 } 222 Py_DECREF(value); 213 223 } 214 else 215 if(PyDict_SetItem(res,PyString_FromString(tmp->name),PyString_FromString(tmp->value))<0){ 224 else{ 225 PyObject* value=PyString_FromString(tmp->value); 226 if(PyDict_SetItem(res,name,value)<0){ 216 227 fprintf(stderr,"Unable to parse params..."); 217 228 exit(1); 218 229 } 219 } 220 else 221 if(PyDict_SetItem(res,PyString_FromString(tmp->name),PyString_FromString(tmp->value))<0){ 230 Py_DECREF(value); 231 } 232 } 233 else{ 234 PyObject* value=PyString_FromString(tmp->value); 235 if(PyDict_SetItem(res,name,value)<0){ 222 236 fprintf(stderr,"Unable to parse params..."); 223 237 exit(1); 224 238 } 239 Py_DECREF(value); 240 } 241 Py_DECREF(name); 225 242 tmp=tmp->next; 226 243 } … … 244 261 PyString_AsString(key),PyString_AsString(value)); 245 262 #endif 246 while(cursor!=NULL){247 cursor=cursor->next;248 }249 263 cursor=(maps*)malloc(MAPS_SIZE); 250 264 cursor->name=PyString_AsString(key); … … 255 269 cursor->next=NULL; 256 270 if(res==NULL) 257 res= cursor;271 res=dupMaps(&cursor); 258 272 else 259 273 addMapsToMaps(&res,cursor); 274 freeMap(&cursor->content); 275 free(cursor->content); 276 free(cursor); 260 277 #ifdef DEBUG 261 278 dumpMaps(res); … … 263 280 #endif 264 281 } 282 Py_DECREF(list); 265 283 return res; 266 284 }
Note: See TracChangeset
for help on using the changeset viewer.