Skip to content

Commit

Permalink
Merge pull request #199 from DaPigGuy/master
Browse files Browse the repository at this point in the history
Fix image extraction with `Take a Screenshot`
  • Loading branch information
amka authored May 7, 2024
2 parents d6516f4 + 96396a6 commit 18a7ec0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions frog/services/screenshot_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import os
from gettext import gettext as _

from gi.repository import GObject, Gio, Xdp
from gi.repository import GObject, Gio, GLib, Xdp
from loguru import logger

from frog.config import tessdata_config
Expand Down Expand Up @@ -101,6 +101,7 @@ def take_screenshot_finish(self, source_object, res: Gio.Task, user_data):
filename = self.portal.take_screenshot_finish(res)
# Remove file:// from the path
filename = filename[7:]
filename = GLib.Uri.unescape_string(filename)
self.decode_image(lang, filename, copy, True)

def decode_image(self,
Expand Down Expand Up @@ -142,8 +143,11 @@ def decode_image(self,

finally:
if remove_source:
logger.debug(f"Removing {file}")
os.unlink(file)
try:
logger.debug(f"Removing {file}")
os.unlink(file)
except Exception as e:
logger.debug(f"Error deleting {file}: {e}")

if extracted:
logger.debug("Extracted successfully")
Expand Down

0 comments on commit 18a7ec0

Please sign in to comment.