energy-data / energydata.info

energydata.info - open data and analytics for a sustainable energy future
http://energydata.info
MIT License
26 stars 6 forks source link

3rd party update script issues #301

Closed jodiegardiner closed 4 years ago

jodiegardiner commented 5 years ago

One of the partners has a script which they run at regular intervals to update this dataset:

https://energydata.info/dataset/cd3f689a-7c04-4f7c-91c0-1037d033a872

The script is here:

import os
import requests
import json
import pprint

API_KEY = '***'
CKAN_URL = 'https://energydata.info'
url = CKAN_URL + '/api/action/resource_create'
Path= r'I:\RWD_WindDevelopment\PR108103_WorldBank_Ethiopia_WindMapping_NDA\3.ProjectExecution\2.Phase2\T2.5_MonthlyData\upload'

for filename in os.listdir(Path):
    if not filename.endswith('.py'):
            response = requests.post(url,
                data={"package_id": "cd3f689a-7c04-4f7c-91c0-1037d033a872",
                    "url": '',
                      "url_type": "upload",
                    "name": filename},
                headers={"Authorization": API_KEY},
                files=[('upload', file(filename))])

assert response.status_code == 200
response_dict = json.loads(response.content)
pprint.pprint(response_dict['result'])

When they currently run this script, everything appears to work, the response is correct. But the resource files are not available.

jodiegardiner commented 5 years ago

see #289 for more info