moved buttons into a row
This commit is contained in:
@@ -9,10 +9,15 @@ from rich.traceback import install
|
||||
|
||||
|
||||
class InstanceMode(Enum):
|
||||
START = (1,)
|
||||
PENDING = 0
|
||||
START = 1
|
||||
STOP = 2
|
||||
|
||||
|
||||
class InstanceStateHandler:
|
||||
state: int
|
||||
|
||||
|
||||
install(show_locals=True)
|
||||
console = Console()
|
||||
logging.basicConfig(
|
||||
@@ -25,7 +30,9 @@ logging.basicConfig(
|
||||
log = logging.getLogger("rich")
|
||||
|
||||
|
||||
def aws_launch_ec2(name: str = "foundry", mode: InstanceMode = InstanceMode.START):
|
||||
def aws_launch_ec2(
|
||||
b: ui.button, name: str = "foundry", mode: InstanceMode = InstanceMode.START
|
||||
) -> None:
|
||||
ec2_resource = boto3.resource("ec2")
|
||||
for instance in ec2_resource.instances.all():
|
||||
for tag_dict in instance.tags:
|
||||
@@ -34,15 +41,21 @@ def aws_launch_ec2(name: str = "foundry", mode: InstanceMode = InstanceMode.STAR
|
||||
instance.state["Code"] == 80 and mode == InstanceMode.START
|
||||
): # stopped
|
||||
log.info(f"Starting instance {instance.id}")
|
||||
instance.start()
|
||||
log.info(instance.start())
|
||||
elif instance.state["Code"] == 16 and mode == InstanceMode.STOP:
|
||||
log.info(f"Stopping instance {instance.id}")
|
||||
instance.stop()
|
||||
log.info(instance.stop())
|
||||
|
||||
|
||||
def nicegui_ui():
|
||||
ui.button("Start Foundry AWS Server", on_click=lambda: aws_launch_ec2())
|
||||
ui.button("Stop Foundry AWS Server", on_click=lambda: aws_launch_ec2(mode=InstanceMode.STOP))
|
||||
def nicegui_ui() -> None:
|
||||
with ui.row():
|
||||
start = ui.button(
|
||||
"Start Foundry AWS Server", on_click=lambda: aws_launch_ec2(start)
|
||||
)
|
||||
stop = ui.button(
|
||||
"Stop Foundry AWS Server",
|
||||
on_click=lambda: aws_launch_ec2(stop, mode=InstanceMode.STOP),
|
||||
)
|
||||
|
||||
ui.run()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user