Skip to content

Commit e02bfcb

Browse files
committed
Update dependencies in pyproject.toml and requirements-full.txt; enhance error handling in load_cli_module function and clean up logging configuration.
1 parent 39d0411 commit e02bfcb

5 files changed

Lines changed: 26 additions & 38 deletions

File tree

‎pawnlib/cli/main_cli.py‎

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,22 @@ def get_sys_argv():
109109

110110
def load_cli_module(commands=None, module_name=""):
111111
pawn.console.debug(f"Add parser => '{module_name}'")
112-
module = importlib.import_module(f"pawnlib.cli.{module_name}")
113-
description = getattr(module, "__description__", f"{module_name} module")
114-
epilog = getattr(module, "__epilog__", "")
115-
if isinstance(epilog, tuple):
116-
epilog = "\n".join(epilog)
117-
_parser = commands.add_parser(
118-
module_name,
119-
help=f'{description}',
120-
epilog=epilog,
121-
formatter_class=ColoredHelpFormatter,
122-
description=description.upper(),
123-
)
124-
module.get_arguments(_parser)
112+
try:
113+
module = importlib.import_module(f"pawnlib.cli.{module_name}")
114+
description = getattr(module, "__description__", f"{module_name} module")
115+
epilog = getattr(module, "__epilog__", "")
116+
if isinstance(epilog, tuple):
117+
epilog = "\n".join(epilog)
118+
_parser = commands.add_parser(
119+
module_name,
120+
help=f'{description}',
121+
epilog=epilog,
122+
formatter_class=ColoredHelpFormatter,
123+
description=description.upper(),
124+
)
125+
module.get_arguments(_parser)
126+
except ImportError as e:
127+
pawn.console.log(f"[red]Failed to load module {module_name}: {e}[/red]")
125128

126129

127130
def get_args():
@@ -131,10 +134,15 @@ def get_args():
131134
formatter_class=ColoredHelpFormatter,
132135
)
133136
commands = parser.add_subparsers(title='sub-module')
134-
pawn.console.debug(f"sys_argv={get_sys_argv()}, modules={get_submodule_names()}")
135-
if get_sys_argv() and get_sys_argv() in get_submodule_names():
136-
load_cli_module(commands, get_sys_argv())
137+
138+
# 사용자가 입력한 명령어를 가져옵니다.
139+
command = get_sys_argv()
140+
141+
# 명령어가 하위 모듈 이름과 일치하는지 확인합니다.
142+
if command and command in get_submodule_names():
143+
load_cli_module(commands, command)
137144
else:
145+
# 하위 모듈을 로드하지 않고, 사용자가 입력한 명령어가 유효한지 확인합니다.
138146
for module_name in get_submodule_names():
139147
try:
140148
load_cli_module(commands, module_name)

‎pawnlib/cli/s3.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from pawnlib.utils.http import append_s3
2121

2222
logger = setup_app_logger(simple_format="detailed", propagate_scope="pawnlib")
23-
logger.info("Start")
2423

2524
__description__ = 'Upload or download directories to/from AWS S3.'
2625

‎pawnlib/config/logging_config.py‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,6 @@ def trace(self, message, *args, **kwargs):
2626

2727
logging.Logger.trace = trace
2828

29-
# def verbose_to_log_level(verbose: int, log_levels: dict = None) -> int:
30-
# """
31-
# Convert a verbose value to a corresponding log level.
32-
#
33-
# :param verbose: Verbosity level (e.g., 0, 1, 2, 3). Negative values default to 0.
34-
# :type verbose: int
35-
# :param log_levels: Mapping of verbose levels to logging levels. If None, use default.
36-
# :type log_levels: dict or None
37-
# :return: Corresponding log level (e.g., logging.DEBUG).
38-
# :rtype: int
39-
# :raises ValueError: If log_levels is empty or invalid.
40-
# """
41-
# if log_levels is None:
42-
# log_levels = {0: logging.WARNING, 1: logging.INFO, 2: logging.DEBUG, 3: TRACE}
43-
#
44-
# if not log_levels or not isinstance(log_levels, dict):
45-
# raise ValueError("log_levels must be a non-empty dictionary")
46-
#
47-
# max_verbose = max(log_levels.keys())
48-
# effective_verbose = max(0, min(verbose, max_verbose))
49-
# return log_levels.get(effective_verbose)
5029

5130
def verbose_to_log_level(
5231
verbose: int,

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ full = [
8787
"boto3>=1.28.3",
8888
"redis~=4.5.1",
8989
"aioboto3~=11.3.1",
90+
"xxhash~=3.5.0",
9091
]
9192

9293
[project.scripts]

‎requirements-full.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ bcc-python~=0.0.2
3939
redis~=4.5.1
4040
# aioboto3~=11.3.1
4141
aioboto3~=14.1.0
42+
xxhash~=3.5.0

0 commit comments

Comments
 (0)