nerevu / hdxscraper-unhabitat

Collector for UN Habitat's UrbanInfo API
https://data.hdx.rwlabs.org/dataset/urbaninfo-indicators-2011
MIT License
1 stars 1 forks source link

Add scraperwiki notifier #2

Open luiscape opened 9 years ago

luiscape commented 9 years ago

In order for the "status" of the ScraperWiki boxes to be active, we need to add something like this to when the script ends:

import scraperwiki

try:
  # Script runs.
  scraperwiki.status('ok')

except Exception as e:
  # Script fails.
  scraperwiki.status('error', e)

That helps determine the status of boxes / scripts.

reubano commented 9 years ago

gotcha.... thanks! btw, do you know what error SW throws? It's better to catch a specific exception.

luiscape commented 9 years ago

I am not sure. However, that try: should catch errors within your scripts. Depending on the error, you may decide how to handle it instead of using the generic except Exception as e. The second parameter in `status('error', e)' should be the message of a particular error. That message is useful for sending in an email or displaying in the ScraperWiki dashboard.