Skip to content

Commit

Permalink
Revert "Revert "build: remove boto old version (#31282)" (#31733)"
Browse files Browse the repository at this point in the history
This reverts commit 997f194.
  • Loading branch information
awais786 authored Feb 13, 2023
1 parent 9f7bba8 commit 9c0d049
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions cms/djangoapps/contentstore/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

from django.conf import settings
from django.core.files.storage import get_storage_class
from storages.backends.s3boto import S3BotoStorage
from storages.backends.s3boto3 import S3Boto3Storage
from storages.utils import setting


class ImportExportS3Storage(S3BotoStorage): # pylint: disable=abstract-method
class ImportExportS3Storage(S3Boto3Storage): # pylint: disable=abstract-method
"""
S3 backend for course import and export OLX files.
"""
Expand Down
7 changes: 3 additions & 4 deletions cms/djangoapps/contentstore/views/tests/test_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from milestones.tests.utils import MilestonesTestCaseMixin
from opaque_keys.edx.locator import LibraryLocator
from path import Path as path
from storages.backends.s3boto import S3BotoStorage
from storages.backends.s3boto3 import S3Boto3Storage
from user_tasks.models import UserTaskStatus

Expand Down Expand Up @@ -958,7 +957,7 @@ def test_export_status_handler_other(
"""
Verify that the export status handler generates the correct export path
for storage providers other than ``FileSystemStorage`` and
``S3BotoStorage``
``S3Boto3Storage``
"""
mock_latest_task_status.return_value = Mock(state=UserTaskStatus.SUCCEEDED)
mock_get_user_task_artifact.return_value = self._mock_artifact(
Expand All @@ -968,7 +967,7 @@ def test_export_status_handler_other(
result = json.loads(resp.content.decode('utf-8'))
self.assertEqual(result['ExportOutput'], '/path/to/testfile.tar.gz')

@ddt.data(S3BotoStorage, S3Boto3Storage)
@ddt.data(S3Boto3Storage)
@patch('cms.djangoapps.contentstore.views.import_export._latest_task_status')
@patch('user_tasks.models.UserTaskArtifact.objects.get')
def test_export_status_handler_s3(
Expand All @@ -979,7 +978,7 @@ def test_export_status_handler_s3(
):
"""
Verify that the export status handler generates the correct export path
for the ``S3BotoStorage`` storage provider
for the ``S3Boto3Storage`` storage provider
"""
mock_latest_task_status.return_value = Mock(state=UserTaskStatus.SUCCEEDED)
mock_get_user_task_artifact.return_value = self._mock_artifact(
Expand Down
4 changes: 2 additions & 2 deletions cms/djangoapps/export_course_metadata/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

from django.conf import settings
from django.core.files.storage import get_storage_class
from storages.backends.s3boto import S3BotoStorage
from storages.backends.s3boto3 import S3Boto3Storage


class CourseMetadataExportS3Storage(S3BotoStorage): # pylint: disable=abstract-method
class CourseMetadataExportS3Storage(S3Boto3Storage): # pylint: disable=abstract-method
"""
S3 backend for course metadata export
"""
Expand Down
6 changes: 3 additions & 3 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@
DEFAULT_TEMPLATE_ENGINE = TEMPLATES[0]

#################################### AWS #######################################
# S3BotoStorage insists on a timeout for uploaded assets. We should make it
# S3Boto3Storage insists on a timeout for uploaded assets. We should make it
# permanent instead, but rather than trying to figure out exactly where that
# setting is, I'm just bumping the expiration time to something absurd (100
# years). This is only used if DEFAULT_FILE_STORAGE is overriden to use S3
Expand Down Expand Up @@ -2436,7 +2436,7 @@
VIDEO_IMAGE_MAX_BYTES=2 * 1024 * 1024, # 2 MB
VIDEO_IMAGE_MIN_BYTES=2 * 1024, # 2 KB
# Backend storage
# STORAGE_CLASS='storages.backends.s3boto.S3BotoStorage',
# STORAGE_CLASS='storages.backends.s3boto3.S3Boto3Storage',
# STORAGE_KWARGS=dict(bucket='video-image-bucket'),
STORAGE_KWARGS=dict(
location=MEDIA_ROOT,
Expand All @@ -2451,7 +2451,7 @@
VIDEO_TRANSCRIPTS_SETTINGS = dict(
VIDEO_TRANSCRIPTS_MAX_BYTES=3 * 1024 * 1024, # 3 MB
# Backend storage
# STORAGE_CLASS='storages.backends.s3boto.S3BotoStorage',
# STORAGE_CLASS='storages.backends.s3boto3.S3Boto3Storage',
# STORAGE_KWARGS=dict(bucket='video-transcripts-bucket'),
STORAGE_KWARGS=dict(
location=MEDIA_ROOT,
Expand Down
2 changes: 1 addition & 1 deletion cms/envs/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def get_env_setting(setting):
if AUTH_TOKENS.get('DEFAULT_FILE_STORAGE'):
DEFAULT_FILE_STORAGE = AUTH_TOKENS.get('DEFAULT_FILE_STORAGE')
elif AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY:
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
else:
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'

Expand Down
4 changes: 2 additions & 2 deletions common/test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ def skip_signal(signal, **kwargs):

class MockS3BotoMixin:
"""
TestCase mixin that mocks the S3BotoStorage save method and s3 connection.
TestCase mixin that mocks the S3Boto3Storage save method and s3 connection.
"""
def setUp(self):
super().setUp()
self._mocked_connection = patch('boto.connect_s3', return_value=Mock())
self.mocked_connection = self._mocked_connection.start()

self.patcher = patch('storages.backends.s3boto.S3BotoStorage.save')
self.patcher = patch('storages.backends.s3boto3.S3Boto3Storage.save')
self.patcher.start()

def tearDown(self):
Expand Down
3 changes: 2 additions & 1 deletion lms/djangoapps/instructor/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2749,7 +2749,8 @@ def test_list_report_downloads_error(self, endpoint, mock_error):
ex_status = 503
ex_reason = 'Slow Down'
url = reverse(endpoint, kwargs={'course_id': str(self.course.id)})
with patch('storages.backends.s3boto.S3BotoStorage.listdir', side_effect=BotoServerError(ex_status, ex_reason)):
with patch('storages.backends.s3boto3.S3Boto3Storage.listdir',
side_effect=BotoServerError(ex_status, ex_reason)):
if endpoint in INSTRUCTOR_GET_ENDPOINTS:
response = self.client.get(url)
else:
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/instructor_task/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def from_config(cls, config_name):
storage_type = config.get('STORAGE_TYPE', '').lower()
if storage_type == 's3':
return DjangoStorageReportStore(
storage_class='storages.backends.s3boto.S3BotoStorage',
storage_class='storages.backends.s3boto3.S3Boto3Storage',
storage_kwargs={
'bucket': config['BUCKET'],
'location': config['ROOT_PATH'],
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/instructor_task/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def create_report_store(self):
storage.
"""
test_settings = copy.deepcopy(settings.GRADES_DOWNLOAD)
test_settings['STORAGE_CLASS'] = 'storages.backends.s3boto.S3BotoStorage'
test_settings['STORAGE_CLASS'] = 'storages.backends.s3boto3.S3Boto3Storage'
test_settings['STORAGE_KWARGS'] = {
'bucket': settings.GRADES_DOWNLOAD['BUCKET'],
'location': settings.GRADES_DOWNLOAD['ROOT_PATH'],
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/verify_student/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ def _storage(self):
config = settings.VERIFY_STUDENT["SOFTWARE_SECURE"]

# Default to the S3 backend for backward compatibility
storage_class = config.get("STORAGE_CLASS", "storages.backends.s3boto.S3BotoStorage")
storage_class = config.get("STORAGE_CLASS", "storages.backends.s3boto3.S3Boto3Storage")
storage_kwargs = config.get("STORAGE_KWARGS", {})

# Map old settings to the parameters expected by the storage backend
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/verify_student/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1853,7 +1853,7 @@ def _assert_reverify(self):
"CERT_VERIFICATION_PATH": False,
},
"DAYS_GOOD_FOR": 10,
"STORAGE_CLASS": 'storages.backends.s3boto.S3BotoStorage',
"STORAGE_CLASS": 'storages.backends.s3boto3.S3Boto3Storage',
"STORAGE_KWARGS": {
'bucket': 'test-idv',
},
Expand Down Expand Up @@ -1917,7 +1917,7 @@ def test_403_for_non_staff(self):
"CERT_VERIFICATION_PATH": False,
},
"DAYS_GOOD_FOR": 10,
"STORAGE_CLASS": 'storages.backends.s3boto.S3BotoStorage',
"STORAGE_CLASS": 'storages.backends.s3boto3.S3Boto3Storage',
"STORAGE_KWARGS": {
'bucket': 'test-idv',
},
Expand Down
8 changes: 4 additions & 4 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,7 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
'conventions/internationalization/i18n_translators_guide.html'

#################################### AWS #######################################
# S3BotoStorage insists on a timeout for uploaded assets. We should make it
# S3Boto3Storage insists on a timeout for uploaded assets. We should make it
# permanent instead, but rather than trying to figure out exactly where that
# setting is, I'm just bumping the expiration time to something absurd (100
# years). This is only used if DEFAULT_FILE_STORAGE is overriden to use S3
Expand Down Expand Up @@ -3760,7 +3760,7 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
VIDEO_IMAGE_MAX_BYTES=2 * 1024 * 1024, # 2 MB
VIDEO_IMAGE_MIN_BYTES=2 * 1024, # 2 KB
# Backend storage
# STORAGE_CLASS='storages.backends.s3boto.S3BotoStorage',
# STORAGE_CLASS='storages.backends.s3boto3.S3Boto3Storage',
# STORAGE_KWARGS=dict(bucket='video-image-bucket'),
STORAGE_KWARGS=dict(
location=MEDIA_ROOT,
Expand All @@ -3776,7 +3776,7 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
VIDEO_TRANSCRIPTS_SETTINGS = dict(
VIDEO_TRANSCRIPTS_MAX_BYTES=3 * 1024 * 1024, # 3 MB
# Backend storage
# STORAGE_CLASS='storages.backends.s3boto.S3BotoStorage',
# STORAGE_CLASS='storages.backends.s3boto3.S3Boto3Storage',
# STORAGE_KWARGS=dict(bucket='video-transcripts-bucket'),
STORAGE_KWARGS=dict(
location=MEDIA_ROOT,
Expand Down Expand Up @@ -5099,7 +5099,7 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
# See `blockstore.apps.bundles.storage.LongLivedSignedUrlStorage` for details.
BUNDLE_ASSET_STORAGE_SETTINGS = dict(
# Backend storage
# STORAGE_CLASS='storages.backends.s3boto.S3BotoStorage',
# STORAGE_CLASS='storages.backends.s3boto3.S3Boto3Storage',
# STORAGE_KWARGS=dict(bucket='bundle-asset-bucket', location='/path-to-bundles/'),
STORAGE_CLASS='django.core.files.storage.FileSystemStorage',
STORAGE_KWARGS=dict(
Expand Down
2 changes: 1 addition & 1 deletion lms/envs/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def get_env_setting(setting):
if AUTH_TOKENS.get('DEFAULT_FILE_STORAGE'):
DEFAULT_FILE_STORAGE = AUTH_TOKENS.get('DEFAULT_FILE_STORAGE')
elif AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY:
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
else:
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'

Expand Down

0 comments on commit 9c0d049

Please sign in to comment.