make py calls sync; return correct value

This commit is contained in:
Iuri Matias 2015-06-13 08:13:40 -04:00
parent 27c2ab4104
commit 7ea590895f
2 changed files with 9 additions and 7 deletions

View File

@ -21,6 +21,7 @@
"grunt-cli": "^0.1.13",
"matchdep": "^0.3.0",
"python": "^0.0.4",
"methodmissing": "^0.0.3"
"methodmissing": "^0.0.3",
"sync-me": "^0.1.1"
}
}

View File

@ -2,9 +2,11 @@ var python = require('python').shell;
var web3 = require('web3');
var fs = require('fs');
var mm = require('methodmissing');
var sync = require('sync-me');
py_exec = function(cmd) {
python(cmd, function() {});
console.log("python: " + cmd);
return sync(python, cmd)[1];
}
py_exec("from ethertdd import EvmContract")
@ -39,10 +41,9 @@ TestContractWrapper = (function() {
arg_list.push(value);
}
console.log(this.className + "_contract." + method + "(" + arg_list.join(",") + ")")
python(this.className + "_contract." + method + "(" + arg_list.join(",") + ")", function(err, data) {
console.log("res: " + data);
})
data = py_exec(this.className + "_contract." + method + "(" + arg_list.join(",") + ")");
console.log("res: " + data);
return data;
};
return TestContractWrapper;
@ -52,7 +53,7 @@ TestContractWrapper = (function() {
TestContract = function(contract, className) {
var wrapper = new TestContractWrapper(contract, className);
var Obj = mm(wrapper, function (key, args) {
wrapper.execCmd(key, args)
return wrapper.execCmd(key, args);
});
return Obj;
}