From bcb346b75426e900b6982929c13a79b12d57d6a4 Mon Sep 17 00:00:00 2001 From: Daniel Cormier Date: Mon, 2 Oct 2023 09:47:13 -0400 Subject: [PATCH] moved buttons into a row --- pdm.lock | 66 +++++++++++++++++++++++++++++--------------------- pyproject.toml | 4 +++ src/program.py | 27 +++++++++++++++------ 3 files changed, 62 insertions(+), 35 deletions(-) diff --git a/pdm.lock b/pdm.lock index d1e69b3..c563f41 100644 --- a/pdm.lock +++ b/pdm.lock @@ -2,11 +2,11 @@ # It is not intended for manual editing. [metadata] -groups = ["default"] +groups = ["default", "dev"] cross_platform = true static_urls = false lock_version = "4.3" -content_hash = "sha256:4f96d5d4f42e83e8d1d1508e6011fca71612d4b23e40596c57b586f245fa8dbf" +content_hash = "sha256:53751a8166b5d8d647fa35543e2ccf058fdcd3ebfe6e942cc766a150e23b6948" [[package]] name = "aiofiles" @@ -120,42 +120,42 @@ files = [ [[package]] name = "boto3" -version = "1.28.52" +version = "1.28.57" requires_python = ">= 3.7" summary = "The AWS SDK for Python" dependencies = [ - "botocore<1.32.0,>=1.31.52", + "botocore<1.32.0,>=1.31.57", "jmespath<2.0.0,>=0.7.1", - "s3transfer<0.7.0,>=0.6.0", + "s3transfer<0.8.0,>=0.7.0", ] files = [ - {file = "boto3-1.28.52-py3-none-any.whl", hash = "sha256:1d36db102517d62c6968b3b0636303241f56859d12dd071def4882fc6e030b20"}, - {file = "boto3-1.28.52.tar.gz", hash = "sha256:a34fc153cb2f6fb2f79a764286c967392e8aae9412381d943bddc576c4f7631a"}, + {file = "boto3-1.28.57-py3-none-any.whl", hash = "sha256:5ddf24cf52c7fb6aaa332eaa08ae8c2afc8f2d1e8860680728533dd573904e32"}, + {file = "boto3-1.28.57.tar.gz", hash = "sha256:e2d2824ba6459b330d097e94039a9c4f96ae3f4bcdc731d620589ad79dcd16d3"}, ] [[package]] name = "boto3-stubs" -version = "1.28.52" +version = "1.28.57" requires_python = ">=3.7" -summary = "Type annotations for boto3 1.28.52 generated with mypy-boto3-builder 7.19.0" +summary = "Type annotations for boto3 1.28.57 generated with mypy-boto3-builder 7.19.0" dependencies = [ "botocore-stubs", "types-s3transfer", "typing-extensions>=4.1.0; python_version < \"3.12\"", ] files = [ - {file = "boto3-stubs-1.28.52.tar.gz", hash = "sha256:12d7e5865aeec52e1f73b935b1c6a42e61325538fc2cb83a87a83e41e9485241"}, - {file = "boto3_stubs-1.28.52-py3-none-any.whl", hash = "sha256:3ea81a225e062f3bcb205467891086ea031519697ad54622e61251b52609b8d6"}, + {file = "boto3-stubs-1.28.57.tar.gz", hash = "sha256:61cd792792c2a16d70801d187ebed705c39962a70e90b5dc0f33d04001fb39ae"}, + {file = "boto3_stubs-1.28.57-py3-none-any.whl", hash = "sha256:b389a693e33d75ed19d38b4a2ba99d25f4f2045a3136f816d7fec4d27a71ddb4"}, ] [[package]] name = "boto3-stubs" -version = "1.28.52" +version = "1.28.57" extras = ["essential"] requires_python = ">=3.7" -summary = "Type annotations for boto3 1.28.52 generated with mypy-boto3-builder 7.19.0" +summary = "Type annotations for boto3 1.28.57 generated with mypy-boto3-builder 7.19.0" dependencies = [ - "boto3-stubs==1.28.52", + "boto3-stubs==1.28.57", "mypy-boto3-cloudformation<1.29.0,>=1.28.0", "mypy-boto3-dynamodb<1.29.0,>=1.28.0", "mypy-boto3-ec2<1.29.0,>=1.28.0", @@ -165,13 +165,13 @@ dependencies = [ "mypy-boto3-sqs<1.29.0,>=1.28.0", ] files = [ - {file = "boto3-stubs-1.28.52.tar.gz", hash = "sha256:12d7e5865aeec52e1f73b935b1c6a42e61325538fc2cb83a87a83e41e9485241"}, - {file = "boto3_stubs-1.28.52-py3-none-any.whl", hash = "sha256:3ea81a225e062f3bcb205467891086ea031519697ad54622e61251b52609b8d6"}, + {file = "boto3-stubs-1.28.57.tar.gz", hash = "sha256:61cd792792c2a16d70801d187ebed705c39962a70e90b5dc0f33d04001fb39ae"}, + {file = "boto3_stubs-1.28.57-py3-none-any.whl", hash = "sha256:b389a693e33d75ed19d38b4a2ba99d25f4f2045a3136f816d7fec4d27a71ddb4"}, ] [[package]] name = "botocore" -version = "1.31.52" +version = "1.31.57" requires_python = ">= 3.7" summary = "Low-level, data-driven core of boto 3." dependencies = [ @@ -180,8 +180,8 @@ dependencies = [ "urllib3<1.27,>=1.25.4", ] files = [ - {file = "botocore-1.31.52-py3-none-any.whl", hash = "sha256:46b0a75a38521aa6a75fddccb1542e002930e609d4e13516f40fef170d32e515"}, - {file = "botocore-1.31.52.tar.gz", hash = "sha256:6d09881c5a8be34b497872ca3936f8757d886a6f42f2a8703411928189cfedc0"}, + {file = "botocore-1.31.57-py3-none-any.whl", hash = "sha256:af006248276ff8e19e3ec7214478f6257035eb40aed865e405486500471ae71b"}, + {file = "botocore-1.31.57.tar.gz", hash = "sha256:301436174635bec739b225b840fc365ca00e5c1a63e5b2a19ee679d204e01b78"}, ] [[package]] @@ -588,7 +588,7 @@ files = [ [[package]] name = "nicegui" -version = "1.3.14" +version = "1.3.15" requires_python = ">=3.8,<4.0" summary = "Create web-based user interfaces with Python. The nice way." dependencies = [ @@ -609,8 +609,8 @@ dependencies = [ "watchfiles<1.0.0,>=0.18.1", ] files = [ - {file = "nicegui-1.3.14-py3-none-any.whl", hash = "sha256:ebc4d8d7a756f5c5c60df9f9f84449d6e277d140f9cf18dcf2f87772763c04d8"}, - {file = "nicegui-1.3.14.tar.gz", hash = "sha256:d3a872d1a4ae126842be26bc29ab1c0aeb648dac6a44050e987473687f5ca733"}, + {file = "nicegui-1.3.15-py3-none-any.whl", hash = "sha256:99416e285c276d443d91106ca155e90fc4ade3709a3954a60ad7dbdf2448574b"}, + {file = "nicegui-1.3.15.tar.gz", hash = "sha256:551301163cbe0ab2eb3ce977a25c7ca5bbb14259c6582f22e2c3e98fe8daee67"}, ] [[package]] @@ -829,7 +829,7 @@ files = [ [[package]] name = "rich" -version = "13.5.3" +version = "13.6.0" requires_python = ">=3.7.0" summary = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" dependencies = [ @@ -837,21 +837,31 @@ dependencies = [ "pygments<3.0.0,>=2.13.0", ] files = [ - {file = "rich-13.5.3-py3-none-any.whl", hash = "sha256:9257b468badc3d347e146a4faa268ff229039d4c2d176ab0cffb4c4fbc73d5d9"}, - {file = "rich-13.5.3.tar.gz", hash = "sha256:87b43e0543149efa1253f485cd845bb7ee54df16c9617b8a893650ab84b4acb6"}, + {file = "rich-13.6.0-py3-none-any.whl", hash = "sha256:2b38e2fe9ca72c9a00170a1a2d20c63c790d0e10ef1fe35eba76e1e7b1d7d245"}, + {file = "rich-13.6.0.tar.gz", hash = "sha256:5c14d22737e6d5084ef4771b62d5d4363165b403455a30a1c8ca39dc7b644bef"}, ] [[package]] name = "s3transfer" -version = "0.6.2" +version = "0.7.0" requires_python = ">= 3.7" summary = "An Amazon S3 Transfer Manager" dependencies = [ "botocore<2.0a.0,>=1.12.36", ] files = [ - {file = "s3transfer-0.6.2-py3-none-any.whl", hash = "sha256:b014be3a8a2aab98cfe1abc7229cc5a9a0cf05eb9c1f2b86b230fd8df3f78084"}, - {file = "s3transfer-0.6.2.tar.gz", hash = "sha256:cab66d3380cca3e70939ef2255d01cd8aece6a4907a9528740f668c4b0611861"}, + {file = "s3transfer-0.7.0-py3-none-any.whl", hash = "sha256:10d6923c6359175f264811ef4bf6161a3156ce8e350e705396a7557d6293c33a"}, + {file = "s3transfer-0.7.0.tar.gz", hash = "sha256:fd3889a66f5fe17299fe75b82eae6cf722554edca744ca5d5fe308b104883d2e"}, +] + +[[package]] +name = "setuptools" +version = "68.2.2" +requires_python = ">=3.8" +summary = "Easily download, build, install, upgrade, and uninstall Python packages" +files = [ + {file = "setuptools-68.2.2-py3-none-any.whl", hash = "sha256:b454a35605876da60632df1a60f736524eb73cc47bbc9f3f1ef1b644de74fd2a"}, + {file = "setuptools-68.2.2.tar.gz", hash = "sha256:4ac1475276d2f1c48684874089fefcd83bd7162ddaafb81fac866ba0db282a87"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index 7f75354..d193a2f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,10 @@ dependencies = [ requires-python = ">=3.11" readme = "README.md" license = {text = "MIT"} +[project.optional-dependencies] +dev = [ + "setuptools>=68.2.2", +] [tool.ruff] extend-select = [ diff --git a/src/program.py b/src/program.py index 1906477..cb45c12 100644 --- a/src/program.py +++ b/src/program.py @@ -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()