Passing variables from php to python and python to php -


i breaking head make work in dead end. have no idea doing wrong. play php , python; trying execute python script through php exec(), return output , pass python script. workflow: 1) through jquery , ajax request pass data php file (exec1.php) looks this:

$number = $_post['numberofclusters']; $shape = $_post['shapefilepath']; // execute python script $command = "python ./python/module1.py $number $shape"; exec($command,$out,$ret); print_r($out); print_r($r); //return nicely 1. 

2) python file run module1.py looks this:

# list of list of tuples cls000 = [[(365325.342877, 4385460.998374), (365193.884409, 4385307.899807), (365433.717878, 4385148.9983749995)]]  # return data php print cls000 

3) have nested ajax request inside success function of previous ajax request in pass response (in case cls000 list) php script called (exec2.php) this:

# pass variables form $number = $_post['numberofclusters']; $shape = $_post['shapefilepath']; $clustercoords = $_post['response']; # response previous ajax request  // execute python script  $command = "python ./python/module2.py $number $shape $clustercoords"; exec($command,$out,$ret);  print_r($out); ## gives me empty array!! print_r($ret); ## gives me return status: 2 

4) module2.py script looks this:

number = int(sys.argv[1]) shape =  sys.argv[2] cls000 = json.loads(sys.argv[3])  # return data php print cls000 

what doing wrong? if remove line 'cls000 = json.loads(sys.argv[9])' , return example 'shape' works fine. when try return cls000 status code 2. missing here?


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -