Skip to content

Commit

Permalink
chore: Normalize whitespace and organization in from_crawler
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Jan 23, 2024
1 parent 1884445 commit 9094005
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 0 additions & 1 deletion kingfisher_scrapy/extensions/database_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def from_crawler(cls, crawler):
raise NotConfigured('FILES_STORE is not set.')

extension = cls(database_url, directory)

crawler.signals.connect(extension.spider_opened, signal=signals.spider_opened)
crawler.signals.connect(extension.spider_closed, signal=signals.spider_closed)

Expand Down
1 change: 1 addition & 0 deletions kingfisher_scrapy/extensions/item_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def __init__(self, stats):
def from_crawler(cls, crawler):
extension = cls(crawler.stats)
crawler.signals.connect(extension.item_scraped, signal=signals.item_scraped)

return extension

def item_scraped(self, item, spider):
Expand Down
15 changes: 10 additions & 5 deletions kingfisher_scrapy/extensions/sentry_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ class SentryLogging:
`Sentry documentation <https://docs.sentry.io/platforms/python/logging/>`__
"""

def __init__(self, sentry_dsn):
sentry_sdk.init(sentry_dsn)

@classmethod
def from_crawler(cls, crawler):
sentry_dsn = crawler.settings.get('SENTRY_DSN', None)
if sentry_dsn is None:
raise NotConfigured
extension = cls()
sentry_sdk.init(sentry_dsn)
sentry_dsn = crawler.settings['SENTRY_DSN']

if not sentry_dsn:
raise NotConfigured('SENTRY_DSN is not set.')

extension = cls(sentry_dsn)

return extension

0 comments on commit 9094005

Please sign in to comment.