Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename "SingeFileError" to "SingleFileError" #823

Merged
merged 1 commit into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions bookmarks/services/singlefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.conf import settings


class SingeFileError(Exception):
class SingleFileError(Exception):
pass


Expand All @@ -31,7 +31,7 @@ def create_snapshot(url: str, filepath: str):

# check if the file was created
if not os.path.exists(temp_filepath):
raise SingeFileError("Failed to create snapshot")
raise SingleFileError("Failed to create snapshot")

with open(temp_filepath, "rb") as raw_file, gzip.open(
filepath, "wb"
Expand All @@ -47,12 +47,12 @@ def create_snapshot(url: str, filepath: str):
)
process.terminate()
process.wait(timeout=20)
raise SingeFileError("Timeout expired while creating snapshot")
raise SingleFileError("Timeout expired while creating snapshot")
except subprocess.TimeoutExpired:
# Kill the whole process group, which should also clean up any chromium
# processes spawned by single-file
logger.error("Timeout expired while terminating. Killing process...")
os.killpg(os.getpgid(process.pid), signal.SIGTERM)
raise SingeFileError("Timeout expired while creating snapshot")
raise SingleFileError("Timeout expired while creating snapshot")
except subprocess.CalledProcessError as error:
raise SingeFileError(f"Failed to create snapshot: {error.stderr}")
raise SingleFileError(f"Failed to create snapshot: {error.stderr}")
2 changes: 1 addition & 1 deletion bookmarks/tests/test_bookmarks_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def test_create_html_snapshot_truncate_filename(self):
def test_create_html_snapshot_should_handle_error(self):
bookmark = self.setup_bookmark(url="https://example.com")

self.mock_singlefile_create_snapshot.side_effect = singlefile.SingeFileError(
self.mock_singlefile_create_snapshot.side_effect = singlefile.SingleFileError(
"Error"
)
tasks.create_html_snapshot(bookmark)
Expand Down
4 changes: 2 additions & 2 deletions bookmarks/tests/test_singlefile_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ def test_create_snapshot_failure(self):
with mock.patch("subprocess.Popen") as mock_popen:
mock_popen.side_effect = subprocess.CalledProcessError(1, "command")

with self.assertRaises(singlefile.SingeFileError):
with self.assertRaises(singlefile.SingleFileError):
singlefile.create_snapshot("http://example.com", self.html_filepath)

# so also check that it raises error if output file isn't created
with mock.patch("subprocess.Popen"):
with self.assertRaises(singlefile.SingeFileError):
with self.assertRaises(singlefile.SingleFileError):
singlefile.create_snapshot("http://example.com", self.html_filepath)

def test_create_snapshot_empty_options(self):
Expand Down