Skip to content

Commit

Permalink
Merge pull request #25 from TimNekk/develop (v.1.4.2)
Browse files Browse the repository at this point in the history
Added Customizable Proccess Timeout
  • Loading branch information
TimNekk authored Jul 7, 2024
2 parents 3e2ea6d + 227e039 commit 65a8800
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions gigapixel/gigapixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,25 @@ class OutputFormat(Enum):
class Gigapixel:
def __init__(self,
executable_path: Path,
output_suffix: str):
output_suffix: str,
processing_timeout: int = 900):
"""
:param executable_path: Path to the executable (Topaz Gigapixel AI.exe)
:param output_suffix: Suffix to be added to the output file name (e.g. pic.jpg -> pic-gigapixel.jpg)
:param processing_timeout: Timeout for processing in seconds
"""
self._executable_path = executable_path
self._output_suffix = output_suffix

instance = self._get_gigapixel_instance()
self._app = self._App(instance)
self._app = self._App(instance, processing_timeout)

class _App:
def __init__(self, app: Application):
def __init__(self, app: Application, processing_timeout: int):
timings.Timings.window_find_timeout = 0.5

self.app = app
self._processing_timeout = processing_timeout
self._main_window = self.app.window()

self.scale: Optional[Scale] = None
Expand Down Expand Up @@ -93,7 +100,7 @@ def save_photo(self, output_format: Optional[OutputFormat]) -> None:
self._cancel_processing_button = self._main_window.child_window(title="Cancel Processing",
control_type="Button",
depth=1)
self._cancel_processing_button.wait_not('visible', timeout=60)
self._cancel_processing_button.wait_not('visible', timeout=self._processing_timeout)

@log("Deleting photo from history", "Photo deleted", level=Level.DEBUG)
def delete_photo(self) -> None:
Expand Down Expand Up @@ -223,6 +230,16 @@ def process(self,
delete_from_history: bool = False,
output_format: Optional[OutputFormat] = None
) -> Path:
"""
Process a photo using Topaz Gigapixel AI
:param photo_path: Path to the photo to be processed
:param scale: Scale to be used for processing
:param mode: Mode to be used for processing
:param delete_from_history: Whether to delete the photo from history after processing
:param output_format: Output format of the processed photo
:return: Path to the processed photo
"""
self._check_path(photo_path, output_format)

self._app.open_photo(photo_path)
Expand Down

0 comments on commit 65a8800

Please sign in to comment.