-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in QGIS 2.12-Lyon Windows 64bit #6
Comments
I have tested your use case and it works on Mac, so I am trying to figure out whether this is a Windows-related problem. Moreover, the error is located in a piece of code that should be removed. I will then update the plugin to version 0.2. In the meanwhile, you can try to open (with textpad, or similar) the file:
and remove the line 121:
After that you should restart QGIS and check whether the problem is still there. |
I commented Line 121, but other problems remain. Looks like a Windows issue.
|
Version 0.2 is available from the plugin repository, could you please try to update your plugin? |
Just upgraded to v0.2, but still same messages:
Stack trace:
|
Can you try to run the following code in the QGIS Python console? This works on Mac, I am trying to find out whether this is a Windows-related problem or not. import urllib
import urllib2
import json
BASE_URL = 'http://fenixapps2.fao.org/api/v1.0/'
def get_data(domain_code, element_code, item_code, lang='en'):
out = []
url = BASE_URL + lang + '/data/'
values = {
'domain_code': domain_code,
'List1Codes': create_countries_parameter(domain_code, lang),
'List2Codes': element_code,
'List3Codes': item_code,
'List4Codes': create_years_parameter(),
'group_by': '',
'order_by': '',
'operator': ''
}
data = urllib.urlencode(values, True)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
json_data = response.read()
rows = json.loads(json_data)['data']
for row in rows:
out.append({
'code': row['Country Code'],
'value': row['Value'],
'year': row['Year']
})
return out
def create_years_parameter():
years = []
for y in range(1961, 2015):
years.append(str(y))
return years
def create_countries_parameter(domain_code, lang='en'):
out = []
r = BASE_URL + lang + '/codes/countries/' + domain_code
req = urllib2.Request(r)
response = urllib2.urlopen(req)
json_data = response.read()
countries = json.loads(json_data)['data']
for country in countries:
out.append(str(country['code']))
return out
print get_data('QC', 2312, 125) |
OK, here is the response. Python Console
Use iface to access QGIS API interface or Type help(iface) for more info
import urllib
import urllib2
import json
BASE_URL = 'http://fenixapps2.fao.org/api/v1.0/'
def get_data(domain_code, element_code, item_code, lang='en'):
out = []
url = BASE_URL + lang + '/data/'
values = {
'domain_code': domain_code,
'List1Codes': create_countries_parameter(domain_code, lang),
'List2Codes': element_code,
'List3Codes': item_code,
'List4Codes': create_years_parameter(),
'group_by': '',
'order_by': '',
'operator': ''
}
data = urllib.urlencode(values, True)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
json_data = response.read()
rows = json.loads(json_data)['data']
for row in rows:
out.append({
'code': row['Country Code'],
'value': row['Value'],
'year': row['Year']
})
return out
def create_years_parameter():
years = []
for y in range(1961, 2015):
years.append(str(y))
return years
def create_countries_parameter(domain_code, lang='en'):
out = []
r = BASE_URL + lang + '/codes/countries/' + domain_code
req = urllib2.Request(r)
response = urllib2.urlopen(req)
json_data = response.read()
countries = json.loads(json_data)['data']
for country in countries:
out.append(str(country['code']))
return out
print get_data('QC', 2312, 125) [{'code': 5, 'value': 3.0, 'year': u'1961'}, {'code': 5, 'value': 3.0, 'year': u'1962'}, {'code': 5, 'value': 3.0, 'year': u'1963'}, {'code': 5, 'value': 6.0, 'year': u'1964'}, {'code': 5, 'value': 2.0, 'year': u'1965'}, {'code': 5, 'value': 2.0, 'year': u'1966'}, {'code': 5, 'value': 6.0, 'year': u'1967'}, {'code': 5, 'value': 2.0, 'year': u'1968'}, {'code': 5, 'value': 2.0, 'year': u'1969'}, {'code': 5, 'value': 2.0, 'year': u'1970'}, {'code': 5, 'value': 2.0, 'year': u'1971'}, {'code': 5, 'value': 3.0, 'year': u'1972'}, {'code': 5, 'value': 3.0, 'year': u'1973'}, {'code': 5, 'value': 3.0, 'year': u'1974'}, {'code': 5, 'value': 3.0, 'year': u'1975'}, {'code': 5, 'value': 3.0, 'year': u'1976'}, {'code': 5, 'value': 3.0, 'year': u'1977'}, {'code': 5, 'value': 3.0, 'year': u'1978'}, {'code': 5, 'value': 3.0, 'year': u'1979'}, {'code': 5, 'value': 4.0, 'year': u'1980'}, {'code': 5, 'value': 4.0, 'year': u'1981'}, {'code': 5, 'value': 4.0, 'year': u'1982'}, {'code': 5, 'value': 4.0, 'year': u'1983'}, {'code': 5, 'value': 4.0, 'year': u'1984'}, {'code': 5, 'value': 4.0, 'year': u'1985'}, {'code': 5, 'value': 4.0, 'year': u'1986'}, {'code': 5, 'value': 4.0, 'year': u'1987'}, {'code': 5, 'value': 4.0, 'year': u'1988'}, {'code': 5, 'value': 3.0, 'year': u'1989'}, {'code': 5, 'value': 7.0, 'year': u'1990'}, {'code': 5, 'value': 3.0, 'year': u'1991'}, {'code': 5, 'value': 3.0, 'year': u'1992'}, {'code': 5, 'value': 52.0, 'year': u'1993'}, {'code': 5, 'value': 48.0, 'year': u'1994'}, {'code': 5, 'value': 49.0, 'year': u'1995'}, {'code': 5, 'value': 52.0, 'year': u'1996'}, {'code': 5, 'value': 58.0, 'year': u'1997'}, {'code': 5, 'value': 50.0, 'year': u'1998'}, {'code': 5, 'value': 15.0, 'year': u'1999'}, {'code': 5, 'value': 15.0, 'year': u'2000'}, {'code': 5, 'value': 15.0, 'year': u'2001'}, {'code': 5, 'value': 15.0, 'year': u'2002'}, {'code': 5, 'value': 34.0, 'year': u'2003'}, {'code': 5, 'value': 15.0, 'year': u'2004'}, {'code': 5, 'value': 15.0, 'year': u'2005'}, {'code': 5, 'value': 15.0, 'year': u'2006'}, {'code': 5, 'value': 14.0, 'year': u'2007'}, {'code': 5, 'value': 17.0, 'year': u'2008'}, {'code': 5, 'value': 13.0, 'year': u'2009'}, {'code': 5, 'value': 15.0, 'year': u'2010'}, {'code': 5, 'value': 13.0, 'year': u'2011'}, {'code': 5, 'value': 14.0, 'year': u'2012'}, {'code': 5, 'value': 15.0, 'year': u'2013'}, {'code': 7, 'value': 350000.0, 'year': u'1961'}, {'code': 7, 'value': 400000.0, 'year': u'1962'}, {'code': 7, 'value': 400000.0, 'year': u'1963'}, {'code': 7, 'value': 400000.0, 'year': u'1964'}, {'code': 7, 'value': 420000.0, 'year': u'1965'}, {'code': 7, 'value': 450000.0, 'year': u'1966'}, {'code': 7, 'value':
[truncated] |
It seems that the communication with the DB is interrupted before all the required data is transferred. I have updated slightly the code, could you please try the following one? If this works I'll make version 0.3 😄 import urllib
import urllib2
import json
BASE_URL = 'http://fenixapps2.fao.org/api/v1.0/'
def get_data(domain_code, element_code, item_code, lang='en'):
out = []
url = BASE_URL + lang + '/data/'
values = {
'domain_code': domain_code,
'List1Codes': create_countries_parameter(domain_code, lang),
'List2Codes': element_code,
'List3Codes': item_code,
'List4Codes': create_years_parameter(),
'group_by': '',
'order_by': '',
'operator': ''
}
data = urllib.urlencode(values, True)
req = urllib2.Request(url, data)
fp = urllib2.urlopen(req)
response = ''
while 1:
data = fp.read()
if not data:
break
response += data
json_data = response
rows = json.loads(json_data)['data']
for row in rows:
out.append({
'code': row['Country Code'],
'value': row['Value'],
'year': row['Year']
})
return out
def create_years_parameter():
years = []
for y in range(1961, 2015):
years.append(str(y))
return years
def create_countries_parameter(domain_code, lang='en'):
out = []
r = BASE_URL + lang + '/codes/countries/' + domain_code
req = urllib2.Request(r)
response = urllib2.urlopen(req)
json_data = response.read()
countries = json.loads(json_data)['data']
for country in countries:
out.append(str(country['code']))
return out
print get_data('QC', 2312, 125) |
Ha no sorry I added [truncated] because the response was too long for Github! The response was a complete json. |
Ah ok! Well, if the code works in the Python console it should work in the plugin as well, considering it is the same code! I will release version 0.3 anyways, it may solve your problem. |
Tried to download cassava harvested area.
The text was updated successfully, but these errors were encountered: