Skip to content

Commit

Permalink
Run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
philmcmahon committed Jul 19, 2024
1 parent f2af095 commit 201b42e
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
24 changes: 11 additions & 13 deletions client/securedrop_client/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from enum import Enum
from io import BytesIO
from shlex import quote
from tempfile import mkdtemp, TemporaryDirectory
from tempfile import TemporaryDirectory, mkdtemp
from typing import Callable, List, Optional

from PyQt5.QtCore import QObject, QProcess, pyqtSignal
Expand All @@ -16,6 +16,7 @@

logger = logging.getLogger(__name__)


class Export(QObject):
"""
Interface for sending files to Export VM for transfer to a
Expand Down Expand Up @@ -86,7 +87,6 @@ def run_printer_preflight_checks(self) -> None:
logger.error(f"Error creating archive: {e}")
self._on_print_prefight_error()


def run_export_preflight_checks(self) -> None:
"""
Run preflight check to verify that a valid USB device is connected.
Expand Down Expand Up @@ -338,7 +338,12 @@ def print(self, filepaths: List[str]) -> None:
self.print_failed.emit(ExportError(ExportStatus.ERROR_PRINT))

def _create_archive(
self, archive_dir: str, archive_fn: str, metadata: dict, filepaths: List[str] = [], whistleflow: bool = False
self,
archive_dir: str,
archive_fn: str,
metadata: dict,
filepaths: List[str] = [],
whistleflow: bool = False,
) -> str:
"""
Create the archive to be sent to the Export VM.
Expand Down Expand Up @@ -377,9 +382,7 @@ def _create_archive(
# so this shouldn't be reachable
logger.warning("File not found at specified filepath, skipping")
else:
self._add_file_to_archive(
archive, filepath, prevent_name_collisions
)
self._add_file_to_archive(archive, filepath, prevent_name_collisions)
if missing_count == len(filepaths) and missing_count > 0:
# Context manager will delete archive even if an exception occurs
# since the archive is in a TemporaryDirectory
Expand Down Expand Up @@ -480,13 +483,12 @@ def send_files_to_whistleflow(self, filename: str, filepaths: List[str]) -> None

self.export_completed.emit(filepaths)


def _run_whistleflow_view_test(self) -> None:
# TODO fill this in
logger.info("Running dummy whistleflow view test")

def _run_whistleflow_export(
self, archive_dir: str, filename: str, filepaths: List[str]
self, archive_dir: str, filename: str, filepaths: List[str]
) -> None:
"""
Run disk-test.
Expand All @@ -511,9 +513,7 @@ def run_whistleflow_preflight_checks(self) -> None:
Run dummy preflight test
"""
try:
logger.debug(
"beginning whistleflow preflight checks"
)
logger.debug("beginning whistleflow preflight checks")
self._run_whistleflow_view_test()

logger.debug("completed preflight checks: success")
Expand All @@ -526,5 +526,3 @@ def run_whistleflow_preflight_checks(self) -> None:
class ExportDestination(Enum):
USB = "USB"
WHISTLEFLOW = "WHISTLEFLOW"


8 changes: 3 additions & 5 deletions client/securedrop_client/gui/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
from securedrop_client import state
from securedrop_client.conversation import Transcript as ConversationTranscript
from securedrop_client.db import Source
from securedrop_client.export import ExportDestination
from securedrop_client.export import Export
from securedrop_client.export import Export, ExportDestination
from securedrop_client.gui.base import ModalDialog
from securedrop_client.gui.conversation import (
PrintTranscriptDialog as PrintConversationTranscriptDialog,
)
from securedrop_client.gui.conversation.export.whistleflow_dialog import WhistleflowDialog
from securedrop_client.gui.conversation.export import ExportWizard
from securedrop_client.gui.conversation.export.whistleflow_dialog import WhistleflowDialog
from securedrop_client.logic import Controller
from securedrop_client.utils import safe_mkdir

Expand Down Expand Up @@ -111,7 +110,7 @@ class DeleteSourcesAction(QAction):

def __init__(
self,
parent: 'SourceListToolbar',
parent: "SourceListToolbar",
controller: Controller,
confirmation_dialog: Callable[[List[str]], QDialog],
) -> None:
Expand Down Expand Up @@ -401,7 +400,6 @@ def _prepare_to_export(self) -> None:
)
wizard.exec()


def _on_confirmation_dialog_accepted(self) -> None:
self._prepare_to_export()

Expand Down
3 changes: 2 additions & 1 deletion client/securedrop_client/gui/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

from securedrop_client.gui.auth.dialog import LoginDialog

__all__ = ["LoginDialog"]
__all__ = ["LoginDialog"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
A dialog that allows journalists to export conversations or transcripts to the
Whistleflow View VM. This is a clone of FileDialog.
"""

import datetime
import logging
from gettext import gettext as _
Expand Down Expand Up @@ -96,7 +97,9 @@ def _send_to_whistleflow(self) -> None:
# self._device.whistleflow_export_requested.emit(
# "export-{}.tar".format(timestamp), self._file_locations
# )
self._device.send_files_to_whistleflow( "export-{}.tar".format(timestamp), self._file_locations)
self._device.send_files_to_whistleflow(
"export-{}.tar".format(timestamp), self._file_locations
)

def _show_success_message(self) -> None:
self.continue_button.clicked.disconnect()
Expand Down
3 changes: 1 addition & 2 deletions client/securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@
Source,
User,
)
from securedrop_client.export import ExportDestination
from securedrop_client.export import Export
from securedrop_client.export import Export, ExportDestination
from securedrop_client.gui import conversation
from securedrop_client.gui.actions import (
DeleteConversationAction,
Expand Down
1 change: 1 addition & 0 deletions client/tests/functional/test_delete_sources.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Functional tests for deleting multiple sources in the SecureDrop client.
"""

import pytest
from flaky import flaky
from PyQt5.QtWidgets import QCheckBox
Expand Down

0 comments on commit 201b42e

Please sign in to comment.