dokku-wrapper 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
File without changes
@@ -0,0 +1,19 @@
1
+ class DokkuError(Exception):
2
+ """Erro base para o wrapper Dokku."""
3
+
4
+
5
+ class DokkuCommandError(DokkuError):
6
+ def __init__(self, command, message):
7
+ super().__init__(f"Erro executando {' '.join(command)}: {message}")
8
+ self.command = command
9
+ self.message = message
10
+
11
+
12
+ class AppAlreadyExists(DokkuError):
13
+ def __init__(self, name: str):
14
+ super().__init__(f"O app '{name}' já existe.")
15
+
16
+
17
+ class AppNotFound(DokkuError):
18
+ def __init__(self, name: str):
19
+ super().__init__(f"O app '{name}' não foi encontrado.")
@@ -0,0 +1,15 @@
1
+ import subprocess
2
+ from typing import List
3
+ from .exceptions import DokkuCommandError
4
+
5
+
6
+ def run_command(command: List[str], capture_output: bool = True) -> str:
7
+ """Executa um comando Dokku com segurança."""
8
+ result = subprocess.run(
9
+ command,
10
+ capture_output=capture_output,
11
+ text=True
12
+ )
13
+ if result.returncode != 0:
14
+ raise DokkuCommandError(command, result.stderr.strip())
15
+ return result.stdout.strip()
File without changes
File without changes
dokku_wrapper/dokku.py ADDED
@@ -0,0 +1,8 @@
1
+ from .services.apps import Apps
2
+
3
+
4
+ class Dokku:
5
+ """Interface principal para interação com o Dokku."""
6
+
7
+ def __init__(self):
8
+ self.apps = Apps()
File without changes
File without changes
File without changes
@@ -0,0 +1,35 @@
1
+ from ..core.executor import run_command
2
+ from ..core.exceptions import AppAlreadyExists, AppNotFound, DokkuCommandError
3
+ from typing import List, Dict
4
+
5
+
6
+ class Apps:
7
+ """Gerencia aplicações Dokku."""
8
+
9
+ @staticmethod
10
+ def create(name: str) -> Dict[str, str]:
11
+ try:
12
+ output = run_command(["dokku", "apps:create", name])
13
+ return {"name": name, "message": output}
14
+ except DokkuCommandError as e:
15
+ if "already exists" in e.message:
16
+ raise AppAlreadyExists(name)
17
+ raise
18
+
19
+ @staticmethod
20
+ def destroy(name: str, force: bool = True) -> str:
21
+ cmd = ["dokku", "apps:destroy", name]
22
+ if force:
23
+ cmd.append("--force")
24
+ try:
25
+ return run_command(cmd)
26
+ except DokkuCommandError as e:
27
+ if "is not deployed" in e.message or "does not exist" in e.message:
28
+ raise AppNotFound(name)
29
+ raise
30
+
31
+ @staticmethod
32
+ def list() -> List[str]:
33
+ """Retorna uma lista de apps Dokku existentes."""
34
+ output = run_command(["dokku", "apps:list"])
35
+ return [line.strip() for line in output.splitlines() if line.strip()]
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.4
2
+ Name: dokku-wrapper
3
+ Version: 0.1.2
4
+ Summary: Um wrapper em Python para gerenciar aplicações Dokku
5
+ Author-email: Jonatan Rodrigues da Silva <jonatanjrss@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Jonatanjrss/dokku-wrapper
8
+ Project-URL: Issues, https://github.com/Jonatanjrss/dokku-wrapper/issues
9
+ Keywords: dokku,deploy,automation,wrapper
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: POSIX :: Linux
13
+ Requires-Python: >=3.12
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: pytest
17
+ Requires-Dist: pytest-mock
18
+ Dynamic: license-file
19
+
20
+ # dokku-wrapper
21
+
22
+ Wrapper em Python para gerenciar aplicações Dokku.
23
+
24
+ ## Instalação
25
+
26
+ ```bash
27
+
28
+ pip install dokku-wrapper
29
+ ```
30
+
31
+ ## Uso
32
+
33
+ ```python
34
+ from dokku_wrapper.dokku import Dokku
35
+
36
+ dokku = Dokku()
37
+ dokku.apps.create("meu-app") # cria uma nova aplicação
38
+ dokku.apps.list() # lista as aplicações existentes
39
+ ```
@@ -0,0 +1,16 @@
1
+ dokku_wrapper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ dokku_wrapper/dokku.py,sha256=P1odUlFD3ces2asglqiRXFJ34IavTtff1vVzyaefGJo,159
3
+ dokku_wrapper/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ dokku_wrapper/core/exceptions.py,sha256=kpNHbye4TmwQBm7jRNthCA8I46wgy37Jd-33cbPrmcg,552
5
+ dokku_wrapper/core/executor.py,sha256=0eWlxr0iduVvOP-ScRQqRjbUg6aFVI7Y87kt9ID1Tbs,447
6
+ dokku_wrapper/core/parser.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ dokku_wrapper/core/types.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ dokku_wrapper/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ dokku_wrapper/models/app.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ dokku_wrapper/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ dokku_wrapper/services/apps.py,sha256=5WNupDiGxRsxCfvuEY2NdY0Fe0N51TWw4eSOWi5vbqY,1180
12
+ dokku_wrapper-0.1.2.dist-info/licenses/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
13
+ dokku_wrapper-0.1.2.dist-info/METADATA,sha256=4sa-kr3qZNkb854kVgTOPb8hnL3v-COiLlQIgNFrwQE,1004
14
+ dokku_wrapper-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
+ dokku_wrapper-0.1.2.dist-info/top_level.txt,sha256=CvZ9bKqG-DpaVUXMKpSA9cLuFwA7gtiGpt_thCqFoYQ,14
16
+ dokku_wrapper-0.1.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2018 The Python Packaging Authority
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ dokku_wrapper