Issue2722
Created on 2018-12-18.06:05:18 by vaishnavihravi, last changed 2018-12-18.06:05:18 by vaishnavihravi.
Messages | |||
---|---|---|---|
msg12212 (view) | Author: Vaishnavi (vaishnavihravi) | Date: 2018-12-18.06:05:17 | |
This is my code: import java.util.Properties; import org.python.util.PythonInterpreter; public class GenerateWeather { @SuppressWarnings("resource") public static void main(final String[] args) throws ScriptException { System.setProperty("python.cachedir.skip", "true"); Properties p = new Properties(); p.setProperty("python.path", "/Users/<user>/.m2/repository/org/python/jython-standalone/2.7.1/jython-standalone-2.7.1.jar"); p.setProperty("python.home", "/Users/<user>/.m2/repository/org/python/jython-standalone/2.7.1/jython-standalone-2.7.1.jar"); p.setProperty("python.prefix", "/Users/<user>/.m2/repository/org/python/jython-standalone/2.7.1/jython-standalone-2.7.1.jar"); PythonInterpreter.initialize(System.getProperties(), p, new String[] {}); PythonInterpreter interpreter = new PythonInterpreter(); interpreter.exec("import sys"); interpreter.exec("sys.path.append(\"/usr/local/lib/python2.7/site-packages\")"); interpreter.execfile("/Users/<user>/GenerateWeatherReport/python/current_and_forecast.py"); } } ******* current_and_forecast.py works great when invoked in stand-alone mode "python current_and_forecast.py" however fails with Jython with the following stack-trace: Exception in thread "MainThread" Traceback (most recent call last): File "/Users/<user>/GenerateWeatherReport/python/current_and_forecast.py", line 64, in <module> current_weather() File "/Users/<user>/GenerateWeatherReport/python/current_and_forecast.py", line 21, in current_weather cw = requests.get('http://api.openweathermap.org/data/2.5/weather?q=' + city + ',' + country + '&appid=' + api_key) File "/usr/local/lib/python2.7/site-packages/requests/api.py", line 75, in get return request('get', url, params=params, **kwargs) File "/usr/local/lib/python2.7/site-packages/requests/api.py", line 60, in request return session.request(method=method, url=url, **kwargs) File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 524, in request resp = self.send(prep, **send_kwargs) File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 637, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python2.7/site-packages/requests/adapters.py", line 439, in send resp = conn.urlopen( File "/usr/local/lib/python2.7/site-packages/requests/adapters.py", line 439, in send resp = conn.urlopen( File "/usr/local/lib/python2.7/site-packages/urllib3/connectionpool.py", line 597, in urlopen httplib_response = self._make_request(conn, method, url, File "/usr/local/lib/python2.7/site-packages/urllib3/connectionpool.py", line 597, in urlopen httplib_response = self._make_request(conn, method, url, File "/usr/local/lib/python2.7/site-packages/urllib3/connectionpool.py", line 354, in _make_request conn.request(method, url, **httplib_request_kw) File "/Users/<user>/.m2/repository/org/python/jython-standalone/2.7.1/jython-standalone-2.7.1.jar/Lib/httplib.py", line 1042, in request File "/Users/<user>/.m2/repository/org/python/jython-standalone/2.7.1/jython-standalone-2.7.1.jar/Lib/httplib.py", line 1082, in _send_request File "/Users/<user>/.m2/repository/org/python/jython-standalone/2.7.1/jython-standalone-2.7.1.jar/Lib/httplib.py", line 1038, in endheaders File "/Users/<user>/.m2/repository/org/python/jython-standalone/2.7.1/jython-standalone-2.7.1.jar/Lib/httplib.py", line 882, in _send_output File "/Users/<user>/.m2/repository/org/python/jython-standalone/2.7.1/jython-standalone-2.7.1.jar/Lib/httplib.py", line 858, in send File "/Users/<user>/.m2/repository/org/python/jython-standalone/2.7.1/jython-standalone-2.7.1.jar/Lib/_socket.py", line 1441, in meth File "/Users/<user>/.m2/repository/org/python/jython-standalone/2.7.1/jython-standalone-2.7.1.jar/Lib/_socket.py", line 382, in handle_exception File "/Users/<user>/.m2/repository/org/python/jython-standalone/2.7.1/jython-standalone-2.7.1.jar/Lib/_socket.py", line 382, in handle_exception File "/Users/<user>/.m2/repository/org/python/jython-standalone/2.7.1/jython-standalone-2.7.1.jar/Lib/_socket.py", line 382, in handle_exception File "/Users/<user>/.m2/repository/org/python/jython-standalone/2.7.1/jython-standalone-2.7.1.jar/Lib/_socket.py", line 1193, in send AttributeError: 'org.python.netty.channel.socket.nio.NioSocketChann' object has no attribute 'bytesBeforeUnwritable' ********* when checked with Weather API or urllib3, the suggestions were to reach out to Jython because of some native issue with sockets. Pls can you help me out here. Thanks. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2018-12-18 06:05:19 | vaishnavihravi | create |
Supported by Python Software Foundation,
Powered by Roundup