diff --git a/viewer/management/commands/makethumbnails.py b/viewer/management/commands/makethumbnails.py index d024847..847aa33 100644 --- a/viewer/management/commands/makethumbnails.py +++ b/viewer/management/commands/makethumbnails.py @@ -1,9 +1,5 @@ -# Standard library imports. -from pathlib import Path - # External library imports. import filetype -from PIL import Image # Django imports. from django.core.management.base import BaseCommand @@ -16,6 +12,7 @@ from viewer.utils import make_thumbnail # Command subclass. # ########################################################################################### + class Command(BaseCommand): """ Assorted data fix and clean up commands for the Meters module. @@ -25,7 +22,7 @@ class Command(BaseCommand): """ Goes through the GALLERY_ROOT directory recursively and creates a new thumbnail for each image that does not have a corresponding file (same name) in the THUMBNAILS_ROOT - directory. + directory. """ # Make a thumbnail for each file in the current directory. @@ -40,5 +37,5 @@ class Command(BaseCommand): try: self._make_missing_thumbnails(settings.GALLERY_ROOT) - except KeyboardInterrupt as e: + except KeyboardInterrupt: self.stderr.write(self.style.ERROR('\nInterrupted')) diff --git a/viewer/urls.py b/viewer/urls.py index 8b70a8c..dbf9907 100644 --- a/viewer/urls.py +++ b/viewer/urls.py @@ -1,6 +1,5 @@ # Django imports -from django.urls import path -from django.contrib.auth.decorators import login_required +from django.urls import path # Module imports from .views import ( @@ -11,6 +10,7 @@ from .views import ( # URL Patterns. # ########################################################################################### + urlpatterns = [ # Views. path('', gallery_view, name = 'gallery_view_root'), diff --git a/viewer/utils.py b/viewer/utils.py index 40c6cdc..bafe2ad 100644 --- a/viewer/utils.py +++ b/viewer/utils.py @@ -17,6 +17,7 @@ THUMB_SIZE = (128, 128) # Helper functions. # ########################################################################################### + def make_thumbnail(image): """ Creates a thumbnail in the corresponding THUMBNAILS_ROOT directory for the given image. @@ -34,5 +35,5 @@ def make_thumbnail(image): with Image.open(str(image)) as pilimg: pilimg.thumbnail(THUMB_SIZE) pilimg.save(str(thumb_path)) - except: + except Exception: pass diff --git a/viewer/views.py b/viewer/views.py index 2f4e19b..8faee89 100644 --- a/viewer/views.py +++ b/viewer/views.py @@ -10,9 +10,6 @@ from django.http import HttpResponseNotFound from django.conf import settings from django.utils.http import urlencode from django.contrib.auth.decorators import login_required -from django.contrib.auth import (authenticate, - login, - logout) from django.shortcuts import (render, redirect) @@ -31,6 +28,7 @@ IMAGES_PER_PAGE = CELLS_PER_ROW * ROWS_PER_PAGE # Helper functions. # ########################################################################################### + def do_recursive_search(start_path, query): """ Gets all images and sub-directories inside the start_path whose name matches the given query, @@ -57,10 +55,12 @@ def do_recursive_search(start_path, query): # View functions. # ########################################################################################### + @login_required def index(request): return redirect('gallery_view_root') + @login_required def gallery_view(request, path = None): """ @@ -80,7 +80,7 @@ def gallery_view(request, path = None): for c in range(cells): try: row.append(lst[i + c]) - except: + except Exception: pass rows.append(row) i += cells