Skip to content

Commit ab248ca

Browse files
Merge 9329ae6 into cb7258a
2 parents cb7258a + 9329ae6 commit ab248ca

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

source/_remoteClient/client.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,17 @@ def pushClipboard(self):
135135
connector = self.followerTransport or self.leaderTransport
136136
if not getattr(connector, "connected", False):
137137
# Translators: Message shown when trying to push the clipboard to the remote computer while not connected.
138-
ui.message(_("Not connected."))
139-
return
138+
raise RuntimeError(_("Not connected."))
140139
elif self.connectedClientsCount < 1:
141140
# Translators: Reported when performing a Remote Access action, but there are no other computers in the channel.
142-
ui.message(pgettext("remote", "No one else is connected"))
143-
return
141+
raise RuntimeError(_("No one else is connected"))
144142
try:
145143
connector.send(RemoteMessageType.SET_CLIPBOARD_TEXT, text=api.getClipData())
146144
cues.clipboardPushed()
147145
except (TypeError, OSError):
148146
log.debug("Unable to push clipboard", exc_info=True)
149147
# Translators: Message shown when clipboard content cannot be sent to the remote computer.
150-
ui.message(_("Unable to push clipboard"))
148+
raise RuntimeError(_("Unable to push clipboard"))
151149

152150
def copyLink(self):
153151
"""Copy connection URL to clipboard.

source/globalCommands.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4892,7 +4892,11 @@ def script_toggleRemoteMute(self, gesture: "inputCore.InputGesture"):
48924892
)
48934893
@gui.blockAction.when(gui.blockAction.Context.REMOTE_ACCESS_DISABLED)
48944894
def script_pushClipboard(self, gesture: "inputCore.InputGesture"):
4895-
_remoteClient._remoteClient.pushClipboard()
4895+
try:
4896+
_remoteClient._remoteClient.pushClipboard()
4897+
except RuntimeError as e:
4898+
log.error("Error pushing clipboard to remote machine", exc_info=True)
4899+
ui.message(str(e))
48964900

48974901
@script(
48984902
# Translators: Documentation string for the script that copies a link to the remote session to the clipboard.

tests/unit/test_remote/test_remoteClient.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ def test_pushClipboardNoConnection(self):
120120
# Without any transport (neither follower nor leader), pushClipboard should warn.
121121
self.client.followerTransport = None
122122
self.client.leaderTransport = None
123-
self.client.pushClipboard()
124-
self.uiMessage.assert_called_with("Not connected.")
123+
with self.assertRaises(RuntimeError) as cm:
124+
self.client.pushClipboard()
125+
self.assertEqual(str(cm.exception), "Not connected.")
125126

126127
def test_pushClipboardWithTransport(self):
127128
# With a fake transport, pushClipboard should send the clipboard text.

0 commit comments

Comments
 (0)