/[ascend]/trunk/models/johnpye/extpy/extpy.c
ViewVC logotype

Diff of /trunk/models/johnpye/extpy/extpy.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 871 by johnpye, Thu Oct 5 09:30:08 2006 UTC revision 872 by johnpye, Thu Oct 5 12:52:43 2006 UTC
# Line 126  int extpy_import(const struct FilePath * Line 126  int extpy_import(const struct FilePath *
126      char *name;      char *name;
127      name = ospath_str(fp);      name = ospath_str(fp);
128      FILE *f;      FILE *f;
129        PyObject *pyfile;
130    
131      CONSOLE_DEBUG("IMPORTING PYTHON SCRIPT %s",name);      CONSOLE_DEBUG("IMPORTING PYTHON SCRIPT %s",name);
132      if(Py_IsInitialized()){      if(Py_IsInitialized()){
# Line 152  int extpy_import(const struct FilePath * Line 153  int extpy_import(const struct FilePath *
153      initextpy();      initextpy();
154    
155      CONSOLE_DEBUG("OPENING THE SCRIPT \"%s\"",name);      CONSOLE_DEBUG("OPENING THE SCRIPT \"%s\"",name);
156      f = fopen(name,"r");      pyfile = PyFile_FromString(name,"r");
157      if(f==NULL){      if(pyfile==NULL){
158          CONSOLE_DEBUG("Failed opening script");          CONSOLE_DEBUG("Failed opening script");
159          ERROR_REPORTER_HERE(ASC_PROG_ERR,"UNABLE TO OPEN SCRIPT");          ERROR_REPORTER_HERE(ASC_PROG_ERR,"UNABLE TO OPEN SCRIPT");
160          return 1;          return 1;
161      }      }
162        
163        f = PyFile_AsFile(pyfile);      
164        if(f==NULL){
165            ERROR_REPORTER_HERE(ASC_PROG_ERR,"UNABLE TO CAST TO FILE*");
166            return 1;
167        }
168      CONSOLE_DEBUG("RUNNING THE SCRIPT");      CONSOLE_DEBUG("RUNNING THE SCRIPT");
169      PyRun_AnyFile(f,name);      PyRun_AnyFileEx(f,name,1);
170      CONSOLE_DEBUG("FINISHED RUNNING THE SCRIPT");      CONSOLE_DEBUG("FINISHED RUNNING THE SCRIPT");
171    
     fclose(f);  
   
172      ASC_FREE(name);      ASC_FREE(name);
173      return 1;      return 1;
174  }  }

Legend:
Removed from v.871  
changed lines
  Added in v.872

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22