Skip to content

Commit

Permalink
add file exists error and continue
Browse files Browse the repository at this point in the history
  • Loading branch information
cbusillo committed Jun 23, 2024
1 parent 898cf9c commit 4bfded3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions bd_to_avp/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(self) -> None:
self.processing_thread.error_occurred.connect(self.handle_processing_error)
self.processing_thread.mkv_creation_error.connect(self.handle_mkv_creation_error)
self.processing_thread.srt_creation_error.connect(self.handle_srt_creation_error)
self.processing_thread.file_exists_error.connect(self.handle_file_exists_error)
self.processing_thread.process_completed.connect(self.finished_processing)

def setup_window(self) -> None:
Expand Down Expand Up @@ -259,6 +260,21 @@ def handle_mkv_creation_error(self, error: MKVCreationError) -> None:

self.handle_processing_error(error)

def handle_file_exists_error(self, error: FileExistsError) -> None:
result = QMessageBox.critical(
self,
"File Exists Error",
"Do you want to continue?\n\n" + str(error),
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.Abort,
)

if result == QMessageBox.StandardButton.Yes:
config.overwrite = True
self.start_processing(is_continuing=True)
return

self.handle_processing_error(error)

def handle_srt_creation_error(self, error: SRTCreationError) -> None:
result = QMessageBox.critical(
self,
Expand Down
3 changes: 3 additions & 0 deletions bd_to_avp/gui/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ProcessingThread(QThread):
error_occurred = Signal(Exception)
mkv_creation_error = Signal(MKVCreationError)
srt_creation_error = Signal(SRTCreationError)
file_exists_error = Signal(FileExistsError)
process_completed = Signal()

def __init__(self, main_window: "MainWindow", parent: QWidget | None = None) -> None:
Expand All @@ -40,6 +41,8 @@ def run(self) -> None:
self.mkv_creation_error.emit(error)
except SRTCreationError as error:
self.srt_creation_error.emit(error)
except FileExistsError as error:
self.file_exists_error.emit(error)
except (RuntimeError, ValueError) as error:
self.error_occurred.emit(error)
finally:
Expand Down

0 comments on commit 4bfded3

Please sign in to comment.