#include <iostream>

#include <Python.h>

#include "character.h"

using namespace std;

static int error(const std::string & message){
    std::cout << message << std::endl;
    //PyErr_Print();
    return -1;
}

int main(int argc, char ** argv){
    if (argc > 1){
        Py_Initialize();
        
        /* NOTE need to make sure we are trying to load in the same directory (is there a work around?) */
        PyRun_SimpleString("import sys"); 
        PyRun_SimpleString("sys.path.append('./')"); 
       
        try {
            Character * character = new Character(argv[1]);
            character->addAttribute("name", Character::String);
            std::cout << "Character Name: " << character->getStringValue("name") << std::endl;
            delete character;
        } catch (const PyException & ex){
            error("Problem loading module! Reason: " + ex.getReason());
        }
        
        Py_Finalize();
        
        return 0;
    }
    
    std::cout << "Usage: ./test character.py" << std::endl;
    
    return 0;
    
}

#include <iostream>

#include <Python.h>

#include "character.h"

using namespace std;

static int error(const std::string & message){
    std::cout << message << std::endl;
    //PyErr_Print();
    return -1;
}

int main(int argc, char ** argv){
    if (argc > 1){
        Py_Initialize();
        
        /* NOTE need to make sure we are trying to load in the same directory (is there a work around?) */
        PyRun_SimpleString("import sys"); 
        PyRun_SimpleString("sys.path.append('./')"); 
       
        try {
            Character * character = new Character(argv[1]);
            character->addAttribute("name", Character::String);
            std::cout << "Character Name: " << character->getStringValue("name") << std::endl;
            delete character;
        } catch (const PyException & ex){
            error("Problem loading module! Reason: " + ex.getReason());
        }
        
        Py_Finalize();
        
        return 0;
    }
    
    std::cout << "Usage: ./test character_module_name" << std::endl;
    
    return 0;
    
}

Correct usage line, no need to include .py in module name.
Correct usage line, no need to include .py in module name.

git-svn-id: 39e099a8ed5324aded674b764a67f7a08796d9a7@5904 662fdd30-d327-0410-a531-f549c87e1e9e
