Skip to content

Commit 8272921

Browse files
committed
fix clibpoard
1 parent c417df7 commit 8272921

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

addon/globalPlugins/CloudVision/__init__.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
prompt_choices = (_("Brief"), _("Detailed"), _("Your prompt"))
9191

9292

93+
FILE_NOT_SUPPORTED = _("File not supported")
9394
def _prompt_switcher():
9495
x = getConfig()["briefOrDetailed"]
9596
x += 1
@@ -104,6 +105,10 @@ def _prompt_switcher():
104105

105106
NO_IMAGE_IN_THE_CLIPBOARD = _("There is no image in the clipboard")
106107

108+
def get_text_from_clipboard():
109+
try: return api.getClipData()
110+
except OSError: return ""
111+
107112
def get_filenames_from_clipboard():
108113
# a variable for file names
109114
filenames = []
@@ -658,7 +663,7 @@ def getFilePath(
658663
return True # Is a supported file format, so we can make OCR
659664
else:
660665
queueHandler.queueFunction(
661-
queueHandler.eventQueue, ui.message, _("File not supported")
666+
queueHandler.eventQueue, ui.message, FILE_NOT_SUPPORTED
662667
)
663668
return False # It is a file format not supported so end the process.
664669

@@ -1028,9 +1033,9 @@ def script_analyzeClipboard(self, gesture):
10281033
tpng = ""
10291034
try:
10301035
files_from_clipboard = get_filenames_from_clipboard()
1031-
if api.getClipData().startswith("http"):
1036+
if get_text_from_clipboard().startswith("http"):
10321037
filePath = ur.urlretrieve(
1033-
api.getClipData(),
1038+
get_text_from_clipboard(),
10341039
os.path.join(globalVars.appArgs.configPath, "tempclip.png")
10351040
)[0]
10361041
elif not files_from_clipboard:
@@ -1053,12 +1058,17 @@ def script_analyzeClipboard(self, gesture):
10531058
fileExtension = filePath.split(".")[-1]
10541059
tpng = ""
10551060
fileName = os.path.basename(filePath)
1061+
if fileExtension not in suppFiles:
1062+
fileName = ""
1063+
filePath=""
1064+
queueHandler.queueFunction(
1065+
queueHandler.eventQueue, ui.message, FILE_NOT_SUPPORTED
1066+
)
1067+
return False # It is a file format not supported so end the process.
10561068
self._script_analyzeObject(gesture, fullscreen=False, from_clipboard=True)
10571069
except:
10581070
log.exception("script error")
10591071
finally:
1060-
if os.path.isfile(tpng):
1061-
os.remove(tpng)
10621072
filePath = ""
10631073
fileExtension = ""
10641074
fileName = ""

addon/manifest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ summary = "CloudVision"
33
description = """An extension for describing images by utilizing recent advances in AI technology. Press NVDA+Control+I to get a description of an object or selected file in Explorer, if you press twice quickly, a virtual viewer will open."""
44
author = "alekssamos <[email protected]>"
55
url = https://visionbot.ru/addon/
6-
version = 6.0.3
6+
version = 6.1.0
77
docFileName = readme.html
88
minimumNVDAVersion = 2019.1.0
99
lastTestedNVDAVersion = 2025.1.0

buildVars.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"Press NVDA+Control+I to get a description of an object or selected file in Explorer, "
2222
"if you press twice quickly, a virtual viewer will open."),
2323
# version
24-
"addon_version": "6.1.0",
24+
"addon_version": "6.1.1",
2525
# Author(s)
2626
"addon_author": u"alekssamos <[email protected]>",
2727
# URL for the add-on documentation support

0 commit comments

Comments
 (0)