/[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 865 by johnpye, Thu Sep 28 14:19:17 2006 UTC revision 867 by johnpye, Fri Sep 29 11:25:47 2006 UTC
# Line 63  extern ASC_EXPORT(int) extpy_register(){ Line 63  extern ASC_EXPORT(int) extpy_register(){
63  /**  /**
64      Create a filename base on a partial filename. In that case of python, this      Create a filename base on a partial filename. In that case of python, this
65      just means adding '.py' to the end.      just means adding '.py' to the end.
66        
67      @param partialname the filename without suffix, as specified in the user's "IMPORT" command      @param partialname the filename without suffix, as specified in the user's "IMPORT" command
68      @return new filename, or NULL on failure      @return new filename, or NULL on failure
69  */  */
# Line 74  char *extpy_filename(const char *partial Line 74  char *extpy_filename(const char *partial
74          ERROR_REPORTER_HERE(ASC_PROG_ERR,"Partial name is NULL, can't work out filename");          ERROR_REPORTER_HERE(ASC_PROG_ERR,"Partial name is NULL, can't work out filename");
75          return NULL;          return NULL;
76      }      }
77                
78      len = strlen(partialname);      len = strlen(partialname);
79      name = ASC_NEW_ARRAY_CLEAR(char,len+4);      name = ASC_NEW_ARRAY_CLEAR(char,len+4);
80      strcpy(name,partialname);      strcpy(name,partialname);
# Line 99  int extpy_import(const struct FilePath * Line 99  int extpy_import(const struct FilePath *
99      }else{      }else{
100          CONSOLE_DEBUG("INITIALISING PYTHON");          CONSOLE_DEBUG("INITIALISING PYTHON");
101          Py_Initialize();          Py_Initialize();
102            CONSOLE_DEBUG("COMPLETED ATTEMPT TO INITIALISE PYTHON");
103        }
104    
105        if(!Py_IsInitialized()){
106            CONSOLE_DEBUG("UNABLE TO INITIALIZE PYTHON");
107            return 1;
108      }      }
109        PyRun_SimpleString("print \"HELLO FROM PYTHON IN C\"");
110    
111      PyRun_SimpleString("import ascpy");      PyRun_SimpleString("import ascpy");
112      f = fopen(name,"r");      f = fopen(name,"r");

Legend:
Removed from v.865  
changed lines
  Added in v.867

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