amon demo
Former-commit-id: 61cd4ae40c9e55260f37d323872a339d29f243f0
--- a/documents/scrapers/0049d35216493c545ef5f7f000e6b252.py
+++ b/documents/scrapers/0049d35216493c545ef5f7f000e6b252.py
@@ -2,7 +2,14 @@
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__) or '.', '../'))
import genericScrapers
-
+import traceback
+try:
+ import amonpy
+ amonpy.config.address = 'http://amon_instance:port'
+ amonpy.config.secret_key = 'the secret key from /etc/amon.conf'
+ amon_available = True
+except ImportError:
+ amon_available = False
class ScraperImplementation(genericScrapers.GenericPDFDisclogScraper):
@@ -15,5 +22,27 @@
genericScrapers.GenericPDFDisclogScraper)
print 'Instance:', isinstance(ScraperImplementation(),
genericScrapers.GenericPDFDisclogScraper)
- ScraperImplementation().doScrape()
+ try:
+ ScraperImplementation().doScrape()
+ except Exception, err:
+ sys.stderr.write('ERROR: %s\n' % str(err))
+ print ‘Error Reason: ‘, err.__doc__
+ print ‘Exception: ‘, err.__class__
+ print traceback.format_exc()
+ if amon_available:
+ data = {
+ 'exception_class': '',
+ 'url': '',
+ 'backtrace': ['exception line ', 'another exception line'],
+ 'enviroment': '',
+
+ # In 'data' you can add request information, session variables - it's a recursive
+ # dictionary, so you can literally add everything important for your specific case
+ # The dictionary doesn't have a specified structure, the keys below are only example
+ 'data': {'request': '', 'session': '', 'more': ''}
+ }
+
+ amonpy.exception(data)
+ pass
+