{"action":"opened","issue":{"url":"https://api.github.com/repos/extrabacon/python-shell/issues/59","repository_url":"https://api.github.com/repos/extrabacon/python-shell","labels_url":"https://api.github.com/repos/extrabacon/python-shell/issues/59/labels{/name}","comments_url":"https://api.github.com/repos/extrabacon/python-shell/issues/59/comments","events_url":"https://api.github.com/repos/extrabacon/python-shell/issues/59/events","html_url":"https://github.com/extrabacon/python-shell/issues/59","id":179759619,"number":59,"title":"Communication between Python & Node not work","user":{"login":"DimTac","id":5556032,"avatar_url":"https://avatars.githubusercontent.com/u/5556032?v=3","gravatar_id":"","url":"https://api.github.com/users/DimTac","html_url":"https://github.com/DimTac","followers_url":"https://api.github.com/users/DimTac/followers","following_url":"https://api.github.com/users/DimTac/following{/other_user}","gists_url":"https://api.github.com/users/DimTac/gists{/gist_id}","starred_url":"https://api.github.com/users/DimTac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DimTac/subscriptions","organizations_url":"https://api.github.com/users/DimTac/orgs","repos_url":"https://api.github.com/users/DimTac/repos","events_url":"https://api.github.com/users/DimTac/events{/privacy}","received_events_url":"https://api.github.com/users/DimTac/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-28T12:32:18Z","updated_at":"2016-09-28T12:32:18Z","closed_at":null,"body":"Hi,\r\n\r\nI have a problem with PythonShell and NodeJS.\r\n\r\nI would like to execute a python script and get a value from user (with raw_input or sys.stdin.readline).\r\n(I would like allows user enter the code in a popup in web-browser and Python-shell send it to Python script to continue.)\r\n\r\nThe script works fine when i execute them **in the console mode ** but when I use Pythonshell, the script not waiting the user input and terminate with an error.\r\n\r\nCan you help me to solve this issue ?\r\n\r\nThanks a lot.\r\n\r\nRegards,\r\nDimitri\r\n\r\n## launch.js\r\n`\r\napp.post('/launch_script', urlencodedParser, function (req, res) {\r\n  if (!req.body) return res.sendStatus(400)\r\nif(typeof(req.body.start_date) != 'undefined' && req.body.end_date != 'undefined' && req.body.property_uri != 'undefined' && sampleFile.name !='undefined')\r\n  {\r\n    var options = {\r\n      mode: 'text',\r\n      pythonOptions: ['-u'],\r\n      args: [req.body.property_uri,req.body.start_date, req.body.end_date, 'files/data_url.csv']\r\n    };\r\n\r\n    PythonShell.run('core.py', options, function (err, results) {\r\n      if (err) throw err;\r\n\r\n      pyshell.on('message', function (message) {\r\n        // Send message in console\r\n        console.log(message);\r\n        //Send message in socket.io\r\n        io.emit('logentry',message);\r\n      });\r\n    });\r\n\r\n  }`\r\n\r\n## core.py\r\n`def main(argv):\r\n    # We clear prompt\r\n    cls()\r\n    args = argparser.parse_args()\r\n    # get property_urir\r\n    page = args.property_uri\r\n    count_ok = 0\r\n    flow = client.flow_from_clientsecrets(\r\n    'client_secrets.json',\r\n    scope=['https://www.googleapis.com/auth/webmasters.readonly'],\r\n    redirect_uri='urn:ietf:wg:oauth:2.0:oob')\r\n\r\n    auth_uri = flow.step1_get_authorize_url()\r\n    print (\"URL:\"+auth_uri)\r\n\r\n    #Use stdin instead of raw_input beacause we use stdin in Python shell\r\n    print \"Entrez le code recu : \"\r\n    **auth_code = sys.stdin.readline()** #**This part not working when i execute the script with Python-Shelle, the script jump automatically to the next lines and fail**\r\n\r\n    credentials = flow.step2_exchange(auth_code)\r\n    http_auth = credentials.authorize(httplib2.Http())\r\n    service = build('webmasters','v3',http_auth)`\r\n"}}
{"actor":{"display_login":"DimTac"}}