Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def async_activate(self, order_window_front: bool = True) -> None:
"""
Selects this tab.
:param order_window_front: Whether the window this session is in should
be brought to the front and given keyboard focus.
.. seealso:: Example ":ref:`function_key_tabs_example`"
"""
await iterm2.rpc.async_activate(
self.connection,
False,
True,
order_window_front,
tab_id=self.__tab_id)
:param session_id: The session ID for which to fetch the most recent
prompt.
:returns: The prompt if one exists, or else `None`.
:throws: :class:`RPCException` if something goes wrong.
"""
response = await iterm2.rpc.async_get_prompt(connection, session_id)
status = response.get_prompt_response.status
# pylint: disable=no-member
if status == iterm2.api_pb2.GetPromptResponse.Status.Value("OK"):
return Prompt(response.get_prompt_response)
if status == iterm2.api_pb2.GetPromptResponse.Status.Value(
"PROMPT_UNAVAILABLE"):
return None
raise iterm2.rpc.RPCException(
iterm2.api_pb2.GetPromptResponse.Status.Name(status))
async def _async_simple_set(self, key: str, value: typing.Any):
"""value is a json type"""
await iterm2.rpc.async_set_profile_property(
self.connection,
self.session_id,
key,
value,
self._guids_for_set())
async def async_activate(
self,
select_tab: bool = True,
order_window_front: bool = True) -> None:
"""
Makes the session the active session in its tab.
:param select_tab: Whether the tab this session is in should be
selected.
:param order_window_front: Whether the window this session is in should
be brought to the front and given keyboard focus.
.. seealso:: Example ":ref:`broadcast_example`"
"""
await iterm2.rpc.async_activate(
self.connection,
True,
select_tab,
order_window_front,
session_id=self.__session_id)
else:
params[name] = None
result = await coro(**params)
successful = True
except KeyboardInterrupt as exception:
raise exception
except websockets.exceptions.ConnectionClosed as exception:
raise exception
except Exception as exception:
stack_trace = traceback.format_exc()
exception = {"reason": repr(exception), "traceback": stack_trace}
await iterm2.rpc.async_send_rpc_result(
connection, rpc_notif.request_id, True, exception)
if successful:
await iterm2.rpc.async_send_rpc_result(
connection, rpc_notif.request_id, False, result)
async def async_set_tmux_window_visible(
self, tmux_window_id: str, visible: bool) -> None:
"""Hides or shows a tmux window.
Tmux windows are represented as tabs in iTerm2. You can get a
tmux_window_id from :meth:`~iterm2.Tab.tmux_window_id`. If this tab is
attached to a tmux session, then it may be hidden.
This may not be called from within a :class:`~iterm2.Transaction`.
:param tmux_window_id: The window to show or hide.
:param visible: `True` to show a window, `False` to hide a window.
"""
response = await iterm2.rpc.async_rpc_set_tmux_window_visible(
self.__delegate.tmux_delegate_get_connection(),
self.__connection_id,
tmux_window_id,
visible)
# pylint: disable=no-member
if (response.tmux_response.status != iterm2.api_pb2.TmuxResponse.
Status.Value("OK")):
raise TmuxException(
iterm2.api_pb2.TmuxResponse.Status.Name(
response.tmux_response.status))
async def __aenter__(self):
await iterm2.rpc.start_transaction(self.connection)
:returns: The result of the invocation if successful.
:throws: :class:`~iterm2.rpc.RPCException` if something goes wrong.
"""
response = await iterm2.rpc.async_invoke_function(
self.connection,
invocation,
window_id=self.window_id,
timeout=timeout)
which = response.invoke_function_response.WhichOneof('disposition')
# pylint: disable=no-member
if which == 'error':
if (response.invoke_function_response.error.status ==
iterm2.api_pb2.InvokeFunctionResponse.Status.Value(
"TIMEOUT")):
raise iterm2.rpc.RPCException("Timeout")
raise iterm2.rpc.RPCException("{}: {}".format(
iterm2.api_pb2.InvokeFunctionResponse.Status.Name(
response.invoke_function_response.error.status),
response.invoke_function_response.error.error_reason))
return json.loads(
response.invoke_function_response.success.json_result)
async def async_select_menu_item(connection, identifier: str):
"""Selects a menu item.
:param identifier: A string. See list of identifiers in :doc:`menu_ids`
:throws MenuItemException: if something goes wrong.
.. seealso:: Example ":ref:`zoom_on_screen_example`"
"""
response = await iterm2.rpc.async_menu_item(
connection, identifier, False)
status = response.menu_item_response.status
# pylint: disable=no-member
if status != iterm2.api_pb2.MenuItemResponse.Status.Value("OK"):
raise MenuItemException(
iterm2.api_pb2.MenuItemResponse.Status.Name(status))