From bcafbeb3cf47327fd10c6a37839f785b1cc2c585 Mon Sep 17 00:00:00 2001 From: Firq Date: Sat, 29 Jun 2024 14:14:18 +0200 Subject: [PATCH] Initial Commit --- .forgejo/workflows/build-release.yaml | 55 +++++++++++++++++++++++++ .forgejo/workflows/lint.yaml | 20 +++++++++ .gitignore | 6 +++ README.md | 3 ++ dockge_cli/.gitignore | 1 + dockge_cli/__init__.py | 0 dockge_cli/__main__.py | 0 dockge_cli/cli.py | 1 + dockge_cli/components/authentication.py | 0 dockge_cli/components/communication.py | 0 dockge_cli/components/storage.py | 26 ++++++++++++ pyproject.toml | 28 +++++++++++++ 12 files changed, 140 insertions(+) create mode 100644 .forgejo/workflows/build-release.yaml create mode 100644 .forgejo/workflows/lint.yaml create mode 100644 .gitignore create mode 100644 README.md create mode 100644 dockge_cli/.gitignore create mode 100644 dockge_cli/__init__.py create mode 100644 dockge_cli/__main__.py create mode 100644 dockge_cli/cli.py create mode 100644 dockge_cli/components/authentication.py create mode 100644 dockge_cli/components/communication.py create mode 100644 dockge_cli/components/storage.py create mode 100644 pyproject.toml diff --git a/.forgejo/workflows/build-release.yaml b/.forgejo/workflows/build-release.yaml new file mode 100644 index 0000000..1170c10 --- /dev/null +++ b/.forgejo/workflows/build-release.yaml @@ -0,0 +1,55 @@ +on: + push: + tags: + - '[0-9]+\.[0-9]+\.[0-9]+-c\.[0-9]+' + - '[0-9]+\.[0-9]+\.[0-9]+-a\.[0-9]+' + - '[0-9]+\.[0-9]+\.[0-9]' + +jobs: + backend-pylint: + runs-on: docker + container: nikolaik/python-nodejs:python3.11-nodejs21 + steps: + - name: Checkout source code + uses: https://code.forgejo.org/actions/checkout@v3 + - name: Install packages + run: | + pip install -e . -q + python -m pip list --format=columns --disable-pip-version-check + pip install pylint~=2.17.7 --disable-pip-version-check -q + - name: Run pylint + run: | + pylint --version + pylint **/*.py --exit-zero --rc-file pyproject.toml + + build-artifacts: + needs: ["backend-pylint"] + runs-on: docker + container: nikolaik/python-nodejs:python3.11-nodejs21 + steps: + - name: Checkout source code + uses: https://code.forgejo.org/actions/checkout@v3 + - name: Install packages + run: pip install build + - name: Build package + run: python -m build + - name: Save build artifacts + uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: packages + path: dist/* + + publish-artifacts: + needs: ["build-artifacts"] + runs-on: docker + container: nikolaik/python-nodejs:python3.11-nodejs21 + steps: + - name: Downloading static site artifacts + uses: actions/download-artifact@v3 + with: + name: packages + path: dist + - name: Install Dependencies + run: pip install twine + - name: Upload package to registry + run: python -m twine upload --repository-url ${{ secrets.REPOSITORY_URL }} -u ${{ secrets.TWINE_DEPLOY_USER }} -p ${{ secrets.TWINE_DEPLOY_PASSWORD }} dist/* diff --git a/.forgejo/workflows/lint.yaml b/.forgejo/workflows/lint.yaml new file mode 100644 index 0000000..a88449c --- /dev/null +++ b/.forgejo/workflows/lint.yaml @@ -0,0 +1,20 @@ +on: + push: + branches: "**" + +jobs: + backend-pylint: + runs-on: docker + container: nikolaik/python-nodejs:python3.11-nodejs21 + steps: + - name: Checkout source code + uses: https://code.forgejo.org/actions/checkout@v3 + - name: Install packages + run: | + pip install -e . -q + python -m pip list --format=columns --disable-pip-version-check + pip install pylint~=2.17.7 --disable-pip-version-check -q + - name: Run pylint + run: | + pylint --version + pylint **/*.py --exit-zero --rc-file pyproject.toml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e8e70dc --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.vscode/ + +# Python stuff +__pycache__/ +*venv/ +dist/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..4c51468 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# dockge-cli + +A simple CLI application written in Python for communicating with Dockge using websockets diff --git a/dockge_cli/.gitignore b/dockge_cli/.gitignore new file mode 100644 index 0000000..d36a0d4 --- /dev/null +++ b/dockge_cli/.gitignore @@ -0,0 +1 @@ +.temp/* \ No newline at end of file diff --git a/dockge_cli/__init__.py b/dockge_cli/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dockge_cli/__main__.py b/dockge_cli/__main__.py new file mode 100644 index 0000000..e69de29 diff --git a/dockge_cli/cli.py b/dockge_cli/cli.py new file mode 100644 index 0000000..1b64752 --- /dev/null +++ b/dockge_cli/cli.py @@ -0,0 +1 @@ +import argparse diff --git a/dockge_cli/components/authentication.py b/dockge_cli/components/authentication.py new file mode 100644 index 0000000..e69de29 diff --git a/dockge_cli/components/communication.py b/dockge_cli/components/communication.py new file mode 100644 index 0000000..e69de29 diff --git a/dockge_cli/components/storage.py b/dockge_cli/components/storage.py new file mode 100644 index 0000000..bff2e30 --- /dev/null +++ b/dockge_cli/components/storage.py @@ -0,0 +1,26 @@ +import pathlib +import base64 +import yaml + +_storagepath = pathlib.Path(__file__).parents[1] / ".temp" +_file = _storagepath / "storage.yaml" + +_storagepath.mkdir(exist_ok=True, parents=True) + +def set(key: str, value: str): + with open(_file, "w+") as file: + content: dict[str, str] = yaml.load(file, Loader=yaml.SafeLoader) or {} + content.update({ key: base64.b64encode(value.encode()) }) + yaml.dump(content, file, Dumper=yaml.SafeDumper) + +def get(key: str): + value: str = None + if not _file.exists(): + return None + with open(_file, "r") as file: + content: dict[str, str] = yaml.load(file, Loader=yaml.SafeLoader) + value = content.get(key, None) + return base64.b64decode(value).decode() if value is not None else None + +def clear(): + _file.unlink() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..585b74b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,28 @@ +[project] +name = "dockge_cli" +version = "0.0.1-a.1" +dependencies = [ + "pyyaml~=6.0.1" +] +requires-python = ">= 3.10" +authors = [{name = "Firq", email = "firelp42@gmail.com"}] +maintainers = [{name = "Firq", email = "firelp42@gmail.com"}] +description = "CLi for interacting with dockge" +classifiers = [ + "Development Status :: 3 - Alpha", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] + +[tool.setuptools.packages.find] +where = ["."] +include = ["dockge_cli*"] + +[tool.pylint."MAIN"] +disable = [ "line-too-long", "missing-module-docstring" ] + +[build-system] +requires = ["setuptools >= 61.0"] +build-backend = "setuptools.build_meta"