-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
38 lines (29 loc) · 936 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
HDX Collector for OCHA CERF data.
'''
import os
import scraperwiki
import app.utilities.load as Load
from app.utilities.item import item
from app.collect.collect import collectData
from app.utilities.store_data import storeData
def main():
'''
Application wrapper.
'''
dir_name = os.path.dirname(os.path.realpath(__file__))
file = os.path.join(dir_name, 'config', 'config.json')
config = Load.loadJSONFile(file)
for endpoint in config['endpoints']:
data = collectData(endpoint['url'])
storeData(data, endpoint['name'])
if __name__ == '__main__':
try:
main()
print('{success} Successully collected OCHA CERF data.'.format(success=item('success')))
scraperwiki.status('ok')
except Exception as e:
print('{failure} Failed to collected OCHA CERF data.'.format(failure=item('error')))
scraperwiki.status('error', 'Failed to collect data.')