Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiri Otoupal committed Mar 14, 2024
1 parent b94f5ae commit 43735d4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion abst/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"CLI Command making OCI Bastion and kubernetes usage simple and fast"
)

__version__ = "2.3.45"
__version__ = "2.3.46"
__author__ = "Jiri Otoupal"
__author_email__ = "jiri-otoupal@ips-database.eu"
__license__ = "MIT"
Expand Down
32 changes: 19 additions & 13 deletions abst/cli_commands/create_cli/commands.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from time import sleep

import click
import rich

from abst.bastion_support.oci_bastion import Bastion
from abst.utils.misc_funcs import setup_calls, print_eligible
Expand Down Expand Up @@ -38,14 +39,16 @@ def forward(shell, debug, context_name):
used_name = conf["used_context"]
else:
used_name = context_name
try:
while True:
Bastion(used_name, region=
Bastion.load_json(Bastion.get_creds_path_resolve(context_name)).get("region",
None)).create_forward_loop(
shell=shell)

while True:
Bastion(used_name, region=
Bastion.load_json(Bastion.get_creds_path_resolve(context_name)).get("region",
None)).create_forward_loop(
shell=shell)

sleep(1)
sleep(1)
except FileNotFoundError:
rich.print("[red]No such context found[/red]")


@create.command(
Expand All @@ -70,13 +73,16 @@ def managed(shell, debug, context_name):
else:
used_name = context_name

while True:
Bastion(used_name, region=
Bastion.load_json(Bastion.get_creds_path_resolve(context_name)).get("region",
None)).create_managed_loop(
shell=shell)
try:
while True:
Bastion(used_name, region=
Bastion.load_json(Bastion.get_creds_path_resolve(context_name)).get("region",
None)).create_managed_loop(
shell=shell)

sleep(1)
sleep(1)
except FileNotFoundError:
rich.print("[red]No such context found[/red]")


_do.add_command(forward)
Expand Down
2 changes: 2 additions & 0 deletions abst/cli_commands/ssh_cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def ssh_lin(port, name, debug):

lb = LocalBroadcast(broadcast_shm_name)
data = lb.retrieve_json()
# Refresh memory because of a system
lb.store_json(data)

if len(data.keys()) == 0:
rich.print("[yellow]No connected sessions[/yellow]")
Expand Down
14 changes: 7 additions & 7 deletions abst/sharing/local_broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ def __init_shared_memory(self, name: str, size: int):

try:
# Attempt to create the main shared memory block
self._data_shm = shared_memory.SharedMemory(name=self._data_name, create=True, size=size)
self._data_is_owner = True
except FileExistsError:
self._data_shm = shared_memory.SharedMemory(name=self._data_name, create=False)
self._data_is_owner = False
except FileNotFoundError:
self._data_shm = shared_memory.SharedMemory(name=self._data_name, create=True, size=size)
self._data_is_owner = True

try:
self._len_shm = shared_memory.SharedMemory(name=self._len_name, create=True, size=8)
self._len_shm.buf[:8] = struct.pack('Q', 0)
self._len_is_owner = True
except FileExistsError:
self._len_shm = shared_memory.SharedMemory(name=self._len_name, create=False)
self._len_shm.buf[:8] = struct.pack('Q', 0)
self._len_is_owner = False
except FileNotFoundError:
self._len_shm = shared_memory.SharedMemory(name=self._len_name, create=True, size=8)
self._len_is_owner = True

def store_json(self, data: dict) -> int:
"""
Expand Down

0 comments on commit 43735d4

Please sign in to comment.