Update project config

This commit is contained in:
2025-07-10 17:11:27 +08:00
parent 56531ed91d
commit 401c022723
5 changed files with 49 additions and 10 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.venv/

View File

@ -1,7 +1,9 @@
[project]
name = "managescripts"
name = "WebServicesManager"
version = "0.1.0"
description = "Add your description here"
description = "A template for web services management."
readme = "README.md"
requires-python = ">=3.12"
dependencies = []
dependencies = [
"colorlog==6.9.0",
]

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
colorlog==6.9.0

View File

@ -4,7 +4,7 @@ import os
import logging
import colorlog
# init color log
# Initialize color logging
handler = colorlog.StreamHandler()
handler.setFormatter(colorlog.ColoredFormatter(
'%(log_color)s%(asctime)s - %(levelname)s - %(message)s',
@ -37,12 +37,12 @@ def get_operation():
class Service:
"""A template of web services
"""A template management for web services
Attributes:
tag (str): The tag that marks the service instance to use which way to deploy.
name (str): The name of the service instance.
dir (str): The configuration & data directory of the service instance.
dir (str): The configuration and data directory of the service instance.
"""
def __init__(self, tag: str, name: str, dir=None):
@ -51,7 +51,7 @@ class Service:
self.dir = dir
def command_gen(self):
"""Generate service management commands according to the service's tag.
"""Generate service management commands based on the service's tag.
"""
@ -65,7 +65,7 @@ class Service:
raise ValueError(f"The service tag {self.tag} was not included.")
def manage_service(self):
"""Manage the service based on user input in English.
"""Manage the service based on user input.
"""
@ -86,7 +86,7 @@ class Service:
full_command = f"{command} restart {self.name}"
logger.info(f"Restarting service: {self.name}")
else:
logger.warning("Invalid operation, no service management executed.")
logger.warning("Invalid operation; no service management executed.")
return # Exit if the operation is invalid
if full_command: # Ensure full_command is defined
@ -96,7 +96,7 @@ class Service:
except subprocess.CalledProcessError as e:
logger.error(f"Failed to manage service {self.name}: {e}")
# 示例调用
# Example call
if __name__ == "__main__":
service = Service(tag="sys", name="nginx")
service.manage_service()

35
uv.lock generated Normal file
View File

@ -0,0 +1,35 @@
version = 1
revision = 2
requires-python = ">=3.12"
[[package]]
name = "colorama"
version = "0.4.6"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },
]
[[package]]
name = "colorlog"
version = "6.9.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "colorama", marker = "sys_platform == 'win32'" },
]
sdist = { url = "https://files.pythonhosted.org/packages/d3/7a/359f4d5df2353f26172b3cc39ea32daa39af8de522205f512f458923e677/colorlog-6.9.0.tar.gz", hash = "sha256:bfba54a1b93b94f54e1f4fe48395725a3d92fd2a4af702f6bd70946bdc0c6ac2", size = 16624, upload-time = "2024-10-29T18:34:51.011Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/e3/51/9b208e85196941db2f0654ad0357ca6388ab3ed67efdbfc799f35d1f83aa/colorlog-6.9.0-py3-none-any.whl", hash = "sha256:5906e71acd67cb07a71e779c47c4bcb45fb8c2993eebe9e5adcd6a6f1b283eff", size = 11424, upload-time = "2024-10-29T18:34:49.815Z" },
]
[[package]]
name = "webservicesmanager"
version = "0.1.0"
source = { virtual = "." }
dependencies = [
{ name = "colorlog" },
]
[package.metadata]
requires-dist = [{ name = "colorlog", specifier = "==6.9.0" }]