forked from scrapy/scrapy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove dead boto2 code, deprecate is_botocore() (scrapy#4776)
- Loading branch information
Showing
7 changed files
with
96 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,32 @@ | ||
"""Boto/botocore helpers""" | ||
import warnings | ||
|
||
from scrapy.exceptions import NotConfigured | ||
from scrapy.exceptions import NotConfigured, ScrapyDeprecationWarning | ||
|
||
|
||
def is_botocore(): | ||
""" Returns True if botocore is available, otherwise raises NotConfigured. Never returns False. | ||
Previously, when boto was supported in addition to botocore, this returned False if boto was available | ||
but botocore wasn't. | ||
""" | ||
message = ( | ||
'is_botocore() is deprecated and always returns True or raises an Exception, ' | ||
'so it cannot be used for checking if boto is available instead of botocore. ' | ||
'You can use scrapy.utils.boto.is_botocore_available() to check if botocore ' | ||
'is available.' | ||
) | ||
warnings.warn(message, ScrapyDeprecationWarning, stacklevel=2) | ||
try: | ||
import botocore # noqa: F401 | ||
return True | ||
except ImportError: | ||
raise NotConfigured('missing botocore library') | ||
|
||
|
||
def is_botocore_available(): | ||
try: | ||
import botocore # noqa: F401 | ||
return True | ||
except ImportError: | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.