Skip to content

Commit

Permalink
lint (with implementations of get* for b2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ewdurbin committed Apr 9, 2023
1 parent c8f3391 commit f842eed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion warehouse/packaging/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# limitations under the License.

import collections
import io
import json
import logging
import os.path
Expand Down Expand Up @@ -147,13 +148,17 @@ def _get_path(self, path):
class GenericB2BlobStorage(GenericBlobStorage):
def get(self, path):
try:
file_obj = io.BytesIO()
downloaded_file = self.bucket.download_file_by_name(path)
downloaded_file.save(file_obj)
file_obj.seek(0)
return file_obj
except b2sdk.exception.FileNotPresent:
raise FileNotFoundError(f"No such key: {path!r}") from None

def get_metadata(self, path):
try:
file_info = self.bucket.get_file_info_by_name(path)
return self.bucket.get_file_info_by_name(path).file_info
except b2sdk.exception.FileNotPresent:
raise FileNotFoundError(f"No such key: {path!r}") from None

Expand Down
6 changes: 5 additions & 1 deletion warehouse/packaging/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ def sync_file_to_archive(request, file_id):
def check_file_archive_tasks_outstanding(request):
metrics = request.find_service(IMetricsService, context=None)

files_not_archived = request.db.query(File).filter(File.archived == False).count()
files_not_archived = (
request.db.query(File)
.filter(File.archived == False) # noqa: E712
.count()
)

metrics.gauge(
"warehouse.packaging.files.not_archived",
Expand Down

0 comments on commit f842eed

Please sign in to comment.