Hi guys,

I am happy to return to MRL after a long absence. I noticed a number of new functions. Well done! and I am happy to try to use them. As the first functionality, I try to use the OpenWeatherMap service and noticed a small problem. In the log there is an exception when processing the response:

python.interpreter.27] ERROR c.m.f.Service [Service.java:2053] python error PyException - null Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:/projects/mrl/InMoov/services/H_OpenWeatherMap.py", line 27, in isTheSunShiny
    weather=OpenWeatherMap.fetchForecast(townParam,period)
at org.json.JSONObject.getString(JSONObject.java:721)
at org.myrobotlab.service.OpenWeatherMap.fetchForecast(OpenWeatherMap.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source).
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
org.json.JSONException: org.json.JSONException: JSONObject["speed"] not a string.
 
I send you "no worky"

GroG, nice to see you again.
I had the token entered correctly. On the older version (stable) weather service is working well. The problem occurs on the latest version from a few days ago.

I was testing from develop/head in eclipse .. it seemed to work..

but when i tested from the latest i got the same error you did.

Looking at it i see parsing which appears a bit fragile ...

Fortunately,
the service can also just return raw json ..

Try this

OpenWeatherMap=Runtime.start("OpenWeatherMap", "OpenWeatherMap")
OpenWeatherMap.setApiKey("XXXXXXXXXXXXXXXXXXXXXXXXXX") #https://home.openweathermap.org/
OpenWeatherMap.setUnits("metric") # or imperial
OpenWeatherMap.setLang("fr") # en / de ...
 
# unit is 3 hours steps (1)
# fetch raw data for tomorrow (8) -> because 3*8=24H
# fetch raw data for today (1) -> tomorrow is 1 :
 
r=OpenWeatherMap.fetch("paris,fr",1)
print(r)
 

hm... When  I have replaced the service code with your code. I'm getting an error:

23:10:14.560 [python.interpreter.26] ERROR c.m.f.Service [Service.java:2053] python error PyException - null Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'isTheSunShiny' is not defined
 
at org.python.core.Py.NameError(Py.java:290)
at org.python.core.PyFrame.getname(PyFrame.java:257)
at org.python.pycode._pyx261.f$0(<string>:1)
at org.python.pycode._pyx261.call_function(<string>)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1614)
at org.python.core.Py.exec(Py.java:1658)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:267)
at org.myrobotlab.service.Python$PIThread.run(Python.java:159)
 
 

GroG

6 years 2 months ago

In reply to by Darek

In the last noWorky I saw from you .. I see that its an InMoov script .. 

The latest works with the example I sent.

Might need moz4r to look at this ...

I'll see if a bat signal works ...