cmdbox 0.5.1.1__py3-none-any.whl → 0.5.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.
Potentially problematic release.
This version of cmdbox might be problematic. Click here for more details.
- cmdbox/app/app.py +4 -2
- cmdbox/app/auth/signin.py +633 -631
- cmdbox/app/client.py +10 -10
- cmdbox/app/common.py +50 -6
- cmdbox/app/commons/convert.py +9 -0
- cmdbox/app/commons/module.py +113 -113
- cmdbox/app/commons/redis_client.py +40 -29
- cmdbox/app/edge.py +4 -4
- cmdbox/app/features/cli/audit_base.py +135 -0
- cmdbox/app/features/cli/cmdbox_audit_createdb.py +224 -0
- cmdbox/app/features/cli/cmdbox_audit_delete.py +299 -0
- cmdbox/app/features/cli/cmdbox_audit_search.py +350 -0
- cmdbox/app/features/cli/cmdbox_audit_write.py +240 -0
- cmdbox/app/features/cli/cmdbox_client_file_copy.py +207 -207
- cmdbox/app/features/cli/cmdbox_client_file_download.py +207 -207
- cmdbox/app/features/cli/cmdbox_client_file_list.py +193 -193
- cmdbox/app/features/cli/cmdbox_client_file_mkdir.py +191 -191
- cmdbox/app/features/cli/cmdbox_client_file_move.py +199 -199
- cmdbox/app/features/cli/cmdbox_client_file_remove.py +190 -190
- cmdbox/app/features/cli/cmdbox_client_file_rmdir.py +190 -190
- cmdbox/app/features/cli/cmdbox_client_file_upload.py +212 -212
- cmdbox/app/features/cli/cmdbox_client_server_info.py +166 -166
- cmdbox/app/features/cli/cmdbox_server_list.py +88 -88
- cmdbox/app/features/cli/cmdbox_server_stop.py +138 -138
- cmdbox/app/features/web/cmdbox_web_del_cmd.py +2 -0
- cmdbox/app/features/web/cmdbox_web_del_pipe.py +1 -0
- cmdbox/app/features/web/cmdbox_web_do_signin.py +12 -2
- cmdbox/app/features/web/cmdbox_web_do_signout.py +1 -0
- cmdbox/app/features/web/cmdbox_web_exec_cmd.py +25 -1
- cmdbox/app/features/web/cmdbox_web_exec_pipe.py +1 -0
- cmdbox/app/features/web/cmdbox_web_filer download.py +43 -42
- cmdbox/app/features/web/cmdbox_web_filer.py +1 -0
- cmdbox/app/features/web/cmdbox_web_filer_upload.py +65 -64
- cmdbox/app/features/web/cmdbox_web_gui.py +166 -165
- cmdbox/app/features/web/cmdbox_web_load_pin.py +43 -43
- cmdbox/app/features/web/cmdbox_web_raw_pipe.py +87 -87
- cmdbox/app/features/web/cmdbox_web_save_cmd.py +1 -0
- cmdbox/app/features/web/cmdbox_web_save_pin.py +42 -42
- cmdbox/app/features/web/cmdbox_web_save_pipe.py +1 -0
- cmdbox/app/features/web/cmdbox_web_users.py +12 -0
- cmdbox/app/options.py +767 -601
- cmdbox/extensions/features.yml +20 -0
- cmdbox/extensions/sample_project/sample/app/features/cli/sample_client_time.py +82 -82
- cmdbox/extensions/sample_project/sample/app/features/cli/sample_server_time.py +145 -145
- cmdbox/licenses/{LICENSE.Sphinx.8.1.3(BSD License).txt → LICENSE.Sphinx.8.2.3(UNKNOWN).txt} +1 -1
- cmdbox/licenses/{LICENSE.babel.2.16.0(BSD License).txt → LICENSE.babel.2.17.0(BSD License).txt } +1 -1
- cmdbox/licenses/{LICENSE.pkginfo.1.10.0(MIT License).txt → LICENSE.charset-normalizer.3.4.1(MIT License).txt } +1 -1
- cmdbox/licenses/LICENSE.gunicorn.23.0.0(MIT License).txt +23 -0
- cmdbox/licenses/LICENSE.importlib_metadata.8.6.1(Apache Software License).txt +202 -0
- cmdbox/licenses/LICENSE.nh3.0.2.21(MIT).txt +21 -0
- cmdbox/licenses/{LICENSE.pillow.11.0.0(CMU License (MIT-CMU)).txt → LICENSE.pillow.11.1.0(CMU License (MIT-CMU)).txt } +27 -40
- cmdbox/licenses/LICENSE.plyer.2.1.0(MIT License).txt +19 -0
- cmdbox/licenses/LICENSE.prompt_toolkit.3.0.50(BSD License).txt +27 -0
- cmdbox/licenses/LICENSE.psycopg-binary.3.2.6(GNU Lesser General Public License v3 (LGPLv3)).txt +165 -0
- cmdbox/licenses/LICENSE.psycopg-pool.3.2.6(GNU Lesser General Public License v3 (LGPLv3)).txt +165 -0
- cmdbox/licenses/LICENSE.psycopg.3.2.6(GNU Lesser General Public License v3 (LGPLv3)).txt +165 -0
- cmdbox/licenses/LICENSE.pycryptodome.3.22.0(BSD License; Public Domain).txt +61 -0
- cmdbox/licenses/LICENSE.pystray.0.19.5(GNU Lesser General Public License v3 (LGPLv3)).txt +674 -0
- cmdbox/licenses/LICENSE.questionary.2.1.0(MIT License).txt +19 -0
- cmdbox/licenses/LICENSE.roman-numerals-py.3.1.0(CC0 1.0 Universal (CC0 1.0) Public Domain Dedication; Zero-Clause BSD (0BSD)).txt +146 -0
- cmdbox/licenses/{LICENSE.six.1.16.0(MIT License).txt → LICENSE.six.1.17.0(MIT License).txt } +1 -1
- cmdbox/licenses/{LICENSE.charset-normalizer.3.4.0(MIT License).txt → LICENSE.typing-inspection.0.4.0(MIT License).txt } +2 -2
- cmdbox/licenses/LICENSE.tzdata.2025.2(Apache Software License).txt +15 -0
- cmdbox/licenses/files.txt +48 -36
- cmdbox/logconf_audit.yml +30 -0
- cmdbox/logconf_cmdbox.yml +30 -0
- cmdbox/version.py +2 -2
- cmdbox/web/assets/cmdbox/color_mode.css +516 -0
- cmdbox/web/assets/cmdbox/common.js +19 -0
- cmdbox/web/assets/cmdbox/list_cmd.js +89 -43
- cmdbox/web/assets/cmdbox/list_pipe.js +2 -1
- cmdbox/web/assets/cmdbox/main.js +2 -2
- cmdbox/web/assets/cmdbox/result.js +2 -2
- cmdbox/web/assets/cmdbox/signin.js +2 -2
- cmdbox/web/assets/cmdbox/users.js +2 -3
- cmdbox/web/assets/cmdbox/view_result.js +1 -1
- cmdbox/web/assets/filer/main.js +2 -2
- cmdbox/web/filer.html +16 -2
- cmdbox/web/gui.html +21 -2
- cmdbox/web/result.html +15 -1
- cmdbox/web/signin.html +35 -14
- cmdbox/web/users.html +15 -1
- {cmdbox-0.5.1.1.dist-info → cmdbox-0.5.2.dist-info}/METADATA +25 -5
- {cmdbox-0.5.1.1.dist-info → cmdbox-0.5.2.dist-info}/RECORD +117 -97
- {cmdbox-0.5.1.1.dist-info → cmdbox-0.5.2.dist-info}/entry_points.txt +0 -1
- cmdbox/licenses/LICENSE.nh3.0.2.18(MIT).txt +0 -1
- /cmdbox/licenses/{LICENSE.Jinja2.3.1.4(BSD License).txt → LICENSE.Jinja2.3.1.6(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.Pygments.2.18.0(BSD License).txt → LICENSE.Pygments.2.19.1(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.anyio.4.6.2.post1(MIT License).txt → LICENSE.anyio.4.9.0(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.argcomplete.3.5.1(Apache Software License).txt → LICENSE.argcomplete.3.6.1(Apache Software License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.certifi.2024.8.30(Mozilla Public License 2.0 (MPL 2.0)).txt → LICENSE.certifi.2025.1.31(Mozilla Public License 2.0 (MPL 2.0)).txt} +0 -0
- /cmdbox/licenses/{LICENSE.click.8.1.7(BSD License).txt → LICENSE.click.8.1.8(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.cryptography.43.0.3(Apache Software License; BSD License).txt → LICENSE.cryptography.44.0.2(Apache Software License; BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.fastapi.0.115.5(MIT License).txt → LICENSE.fastapi.0.115.12(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.importlib_metadata.8.5.0(Apache Software License).txt → LICENSE.id.1.5.0(Apache Software License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.keyring.25.5.0(MIT License).txt → LICENSE.keyring.25.6.0(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.more-itertools.10.5.0(MIT License).txt → LICENSE.more-itertools.10.6.0(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.numpy.2.1.3(BSD License).txt → LICENSE.numpy.2.2.4(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.prettytable.3.12.0(BSD License).txt → LICENSE.prettytable.3.16.0(UNKNOWN).txt} +0 -0
- /cmdbox/licenses/{LICENSE.pydantic.2.10.2(MIT License).txt → LICENSE.pydantic.2.11.1(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.pydantic_core.2.27.1(MIT License).txt → LICENSE.pydantic_core.2.33.0(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.python-dotenv.1.0.1(BSD License).txt → LICENSE.python-dotenv.1.1.0(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.python-multipart.0.0.17(Apache Software License).txt → LICENSE.python-multipart.0.0.20(Apache Software License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.redis.5.2.0(MIT License).txt → LICENSE.redis.5.2.1(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.rich.13.9.4(MIT License).txt → LICENSE.rich.14.0.0(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.sphinx-intl.2.3.0(BSD License).txt → LICENSE.sphinx-intl.2.3.1(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.starlette.0.41.3(BSD License).txt → LICENSE.starlette.0.46.1(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.tomli.2.1.0(MIT License).txt → LICENSE.tomli.2.2.1(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.twine.5.1.1(Apache Software License).txt → LICENSE.twine.6.1.0(Apache Software License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.typing_extensions.4.12.2(Python Software Foundation License).txt → LICENSE.typing_extensions.4.13.0(UNKNOWN).txt} +0 -0
- /cmdbox/licenses/{LICENSE.urllib3.2.2.3(MIT License).txt → LICENSE.urllib3.2.3.0(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.uvicorn.0.32.1(BSD License).txt → LICENSE.uvicorn.0.34.0(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.watchfiles.1.0.0(MIT License).txt → LICENSE.watchfiles.1.0.4(MIT License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.websockets.14.1(BSD License).txt → LICENSE.websockets.15.0.1(BSD License).txt} +0 -0
- /cmdbox/licenses/{LICENSE.zope.interface.7.1.1(Zope Public License).txt → LICENSE.zope.interface.7.2(Zope Public License).txt} +0 -0
- {cmdbox-0.5.1.1.dist-info → cmdbox-0.5.2.dist-info}/LICENSE +0 -0
- {cmdbox-0.5.1.1.dist-info → cmdbox-0.5.2.dist-info}/WHEEL +0 -0
- {cmdbox-0.5.1.1.dist-info → cmdbox-0.5.2.dist-info}/top_level.txt +0 -0
cmdbox/extensions/features.yml
CHANGED
|
@@ -37,3 +37,23 @@ aliases: # Specify the alias for the specified co
|
|
|
37
37
|
# e.g. /{1}_exec
|
|
38
38
|
move: # Specify whether to move the regular expression group of the source to the target.
|
|
39
39
|
# e.g. true
|
|
40
|
+
audit:
|
|
41
|
+
enabled: true # Specify whether to enable the audit function.
|
|
42
|
+
feature:
|
|
43
|
+
mode: audit # Specify the mode of the feature to be audited.
|
|
44
|
+
cmd: write # Specify the command to be audited.
|
|
45
|
+
options: # Specify the options for the audit function.
|
|
46
|
+
host: localhost # Specify the service host of the audit Redis server.
|
|
47
|
+
port: 6379 # Specify the service port of the audit Redis server.
|
|
48
|
+
password: password # Specify the access password of the audit Redis server.
|
|
49
|
+
svname: server # Specify the audit service name of the inference server.
|
|
50
|
+
retry_count: 3 # Specifies the number of reconnections to the audit Redis server.If less than 0 is specified, reconnection is forever.
|
|
51
|
+
retry_interval: 1 # Specifies the number of seconds before reconnecting to the audit Redis server.
|
|
52
|
+
timeout: 1 # Specify the maximum waiting time until the server responds.
|
|
53
|
+
pg_enabled: False # Specify True if using the postgresql database server.
|
|
54
|
+
pg_host: localhost # Specify the postgresql host.
|
|
55
|
+
pg_port: 5432 # Specify the postgresql port.
|
|
56
|
+
pg_user: postgres # Specify the postgresql user name.
|
|
57
|
+
pg_password: password # Specify the postgresql password.
|
|
58
|
+
pg_dbname: audit # Specify the postgresql database name.
|
|
59
|
+
retention_period_days: 365 # Specify the number of days to retain audit logs.
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
from cmdbox.app import common, feature
|
|
2
|
-
from cmdbox.app.options import Options
|
|
3
|
-
from typing import Dict, Any, Tuple, Union, List
|
|
4
|
-
import argparse
|
|
5
|
-
import datetime
|
|
6
|
-
import logging
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class ClientTime(feature.Feature):
|
|
10
|
-
def get_mode(self) -> Union[str, List[str]]:
|
|
11
|
-
"""
|
|
12
|
-
この機能のモードを返します
|
|
13
|
-
|
|
14
|
-
Returns:
|
|
15
|
-
Union[str, List[str]]: モード
|
|
16
|
-
"""
|
|
17
|
-
return "client"
|
|
18
|
-
|
|
19
|
-
def get_cmd(self):
|
|
20
|
-
"""
|
|
21
|
-
この機能のコマンドを返します
|
|
22
|
-
|
|
23
|
-
Returns:
|
|
24
|
-
str: コマンド
|
|
25
|
-
"""
|
|
26
|
-
return 'time'
|
|
27
|
-
|
|
28
|
-
def get_option(self):
|
|
29
|
-
"""
|
|
30
|
-
この機能のオプションを返します
|
|
31
|
-
|
|
32
|
-
Returns:
|
|
33
|
-
Dict[str, Any]: オプション
|
|
34
|
-
"""
|
|
35
|
-
return dict(
|
|
36
|
-
type=Options.T_STR, default=None, required=False, multi=False, hide=False, use_redis=self.USE_REDIS_FALSE,
|
|
37
|
-
discription_ja="クライアント側の現在時刻を表示します。",
|
|
38
|
-
discription_en="Displays the current time at the client side.",
|
|
39
|
-
choice=[
|
|
40
|
-
dict(opt="timedelta", type=Options.T_INT, default=9, required=False, multi=False, hide=False, choice=None,
|
|
41
|
-
discription_ja="時差の時間数を指定します。",
|
|
42
|
-
discription_en="Specify the number of hours of time difference."),
|
|
43
|
-
])
|
|
44
|
-
|
|
45
|
-
def apprun(self, logger:logging.Logger, args:argparse.Namespace, tm:float, pf:List[Dict[str, float]]=[]) -> Tuple[int, Dict[str, Any], Any]:
|
|
46
|
-
"""
|
|
47
|
-
この機能の実行を行います
|
|
48
|
-
|
|
49
|
-
Args:
|
|
50
|
-
logger (logging.Logger): ロガー
|
|
51
|
-
args (argparse.Namespace): 引数
|
|
52
|
-
tm (float): 実行開始時間
|
|
53
|
-
pf (List[Dict[str, float]]): 呼出元のパフォーマンス情報
|
|
54
|
-
|
|
55
|
-
Returns:
|
|
56
|
-
Tuple[int, Dict[str, Any], Any]: 終了コード, 結果, オブジェクト
|
|
57
|
-
"""
|
|
58
|
-
tz = datetime.timezone(datetime.timedelta(hours=args.timedelta))
|
|
59
|
-
dt = datetime.datetime.now(tz)
|
|
60
|
-
ret = dict(success=dict(data=dt.strftime('%Y-%m-%d %H:%M:%S')))
|
|
61
|
-
common.print_format(ret, args.format, tm, args.output_json, args.output_json_append, pf=pf)
|
|
62
|
-
if 'success' not in ret:
|
|
63
|
-
return 1, ret, None
|
|
64
|
-
return 0, ret, None
|
|
65
|
-
|
|
66
|
-
def edgerun(self, opt, tool, logger, timeout, prevres = None):
|
|
67
|
-
"""
|
|
68
|
-
この機能のエッジ側の実行を行います
|
|
69
|
-
|
|
70
|
-
Args:
|
|
71
|
-
opt (Dict[str, Any]): オプション
|
|
72
|
-
tool (edge.Tool): 通知関数などedge側のUI操作を行うためのクラス
|
|
73
|
-
logger (logging.Logger): ロガー
|
|
74
|
-
timeout (int): タイムアウト時間
|
|
75
|
-
prevres (Any): 前コマンドの結果。pipeline実行の実行結果を参照する時に使用します。
|
|
76
|
-
|
|
77
|
-
Yields:
|
|
78
|
-
Tuple[int, Dict[str, Any]]: 終了コード, 結果
|
|
79
|
-
"""
|
|
80
|
-
status, res = tool.exec_cmd(opt, logger, timeout, prevres)
|
|
81
|
-
tool.notify(res)
|
|
82
|
-
yield 1, res
|
|
1
|
+
from cmdbox.app import common, feature
|
|
2
|
+
from cmdbox.app.options import Options
|
|
3
|
+
from typing import Dict, Any, Tuple, Union, List
|
|
4
|
+
import argparse
|
|
5
|
+
import datetime
|
|
6
|
+
import logging
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ClientTime(feature.Feature):
|
|
10
|
+
def get_mode(self) -> Union[str, List[str]]:
|
|
11
|
+
"""
|
|
12
|
+
この機能のモードを返します
|
|
13
|
+
|
|
14
|
+
Returns:
|
|
15
|
+
Union[str, List[str]]: モード
|
|
16
|
+
"""
|
|
17
|
+
return "client"
|
|
18
|
+
|
|
19
|
+
def get_cmd(self):
|
|
20
|
+
"""
|
|
21
|
+
この機能のコマンドを返します
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
str: コマンド
|
|
25
|
+
"""
|
|
26
|
+
return 'time'
|
|
27
|
+
|
|
28
|
+
def get_option(self):
|
|
29
|
+
"""
|
|
30
|
+
この機能のオプションを返します
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
Dict[str, Any]: オプション
|
|
34
|
+
"""
|
|
35
|
+
return dict(
|
|
36
|
+
type=Options.T_STR, default=None, required=False, multi=False, hide=False, use_redis=self.USE_REDIS_FALSE,
|
|
37
|
+
discription_ja="クライアント側の現在時刻を表示します。",
|
|
38
|
+
discription_en="Displays the current time at the client side.",
|
|
39
|
+
choice=[
|
|
40
|
+
dict(opt="timedelta", type=Options.T_INT, default=9, required=False, multi=False, hide=False, choice=None,
|
|
41
|
+
discription_ja="時差の時間数を指定します。",
|
|
42
|
+
discription_en="Specify the number of hours of time difference."),
|
|
43
|
+
])
|
|
44
|
+
|
|
45
|
+
def apprun(self, logger:logging.Logger, args:argparse.Namespace, tm:float, pf:List[Dict[str, float]]=[]) -> Tuple[int, Dict[str, Any], Any]:
|
|
46
|
+
"""
|
|
47
|
+
この機能の実行を行います
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
logger (logging.Logger): ロガー
|
|
51
|
+
args (argparse.Namespace): 引数
|
|
52
|
+
tm (float): 実行開始時間
|
|
53
|
+
pf (List[Dict[str, float]]): 呼出元のパフォーマンス情報
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
Tuple[int, Dict[str, Any], Any]: 終了コード, 結果, オブジェクト
|
|
57
|
+
"""
|
|
58
|
+
tz = datetime.timezone(datetime.timedelta(hours=args.timedelta))
|
|
59
|
+
dt = datetime.datetime.now(tz)
|
|
60
|
+
ret = dict(success=dict(data=dt.strftime('%Y-%m-%d %H:%M:%S')))
|
|
61
|
+
common.print_format(ret, args.format, tm, args.output_json, args.output_json_append, pf=pf)
|
|
62
|
+
if 'success' not in ret:
|
|
63
|
+
return 1, ret, None
|
|
64
|
+
return 0, ret, None
|
|
65
|
+
|
|
66
|
+
def edgerun(self, opt, tool, logger, timeout, prevres = None):
|
|
67
|
+
"""
|
|
68
|
+
この機能のエッジ側の実行を行います
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
opt (Dict[str, Any]): オプション
|
|
72
|
+
tool (edge.Tool): 通知関数などedge側のUI操作を行うためのクラス
|
|
73
|
+
logger (logging.Logger): ロガー
|
|
74
|
+
timeout (int): タイムアウト時間
|
|
75
|
+
prevres (Any): 前コマンドの結果。pipeline実行の実行結果を参照する時に使用します。
|
|
76
|
+
|
|
77
|
+
Yields:
|
|
78
|
+
Tuple[int, Dict[str, Any]]: 終了コード, 結果
|
|
79
|
+
"""
|
|
80
|
+
status, res = tool.exec_cmd(opt, logger, timeout, prevres)
|
|
81
|
+
tool.notify(res)
|
|
82
|
+
yield 1, res
|
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
from cmdbox.app import common, client, feature
|
|
2
|
-
from cmdbox.app.commons import redis_client
|
|
3
|
-
from cmdbox.app.options import Options
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
from typing import Dict, Any, Tuple, Union, List
|
|
6
|
-
import argparse
|
|
7
|
-
import datetime
|
|
8
|
-
import logging
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class ServerTime(feature.Feature):
|
|
12
|
-
def get_mode(self) -> Union[str, List[str]]:
|
|
13
|
-
"""
|
|
14
|
-
この機能のモードを返します
|
|
15
|
-
|
|
16
|
-
Returns:
|
|
17
|
-
Union[str, List[str]]: モード
|
|
18
|
-
"""
|
|
19
|
-
return "server"
|
|
20
|
-
|
|
21
|
-
def get_cmd(self):
|
|
22
|
-
"""
|
|
23
|
-
この機能のコマンドを返します
|
|
24
|
-
|
|
25
|
-
Returns:
|
|
26
|
-
str: コマンド
|
|
27
|
-
"""
|
|
28
|
-
return 'time'
|
|
29
|
-
|
|
30
|
-
def get_option(self):
|
|
31
|
-
"""
|
|
32
|
-
この機能のオプションを返します
|
|
33
|
-
|
|
34
|
-
Returns:
|
|
35
|
-
Dict[str, Any]: オプション
|
|
36
|
-
"""
|
|
37
|
-
return dict(
|
|
38
|
-
type=Options.T_STR, default=None, required=False, multi=False, hide=False, use_redis=self.USE_REDIS_FALSE,
|
|
39
|
-
discription_ja="サーバー側の現在時刻を表示します。",
|
|
40
|
-
discription_en="Displays the current time at the server side.",
|
|
41
|
-
choice=[
|
|
42
|
-
dict(opt="host", type=Options.T_STR, default=self.default_host, required=True, multi=False, hide=True, choice=None,
|
|
43
|
-
discription_ja="Redisサーバーのサービスホストを指定します。",
|
|
44
|
-
discription_en="Specify the service host of the Redis server."),
|
|
45
|
-
dict(opt="port", type=Options.T_INT, default=self.default_port, required=True, multi=False, hide=True, choice=None,
|
|
46
|
-
discription_ja="Redisサーバーのサービスポートを指定します。",
|
|
47
|
-
discription_en="Specify the service port of the Redis server."),
|
|
48
|
-
dict(opt="password", type=Options.T_STR, default=self.default_pass, required=True, multi=False, hide=True, choice=None,
|
|
49
|
-
discription_ja="Redisサーバーのアクセスパスワード(任意)を指定します。省略時は `password` を使用します。",
|
|
50
|
-
discription_en="Specify the access password of the Redis server (optional). If omitted, `password` is used."),
|
|
51
|
-
dict(opt="svname", type=Options.T_STR, default="server", required=True, multi=False, hide=True, choice=None,
|
|
52
|
-
discription_ja="サーバーのサービス名を指定します。省略時は `server` を使用します。",
|
|
53
|
-
discription_en="Specify the service name of the inference server. If omitted, `server` is used."),
|
|
54
|
-
dict(opt="timedelta", type=Options.T_INT, default=9, required=False, multi=False, hide=False, choice=None,
|
|
55
|
-
discription_ja="時差の時間数を指定します。",
|
|
56
|
-
discription_en="Specify the number of hours of time difference."),
|
|
57
|
-
dict(opt="retry_count", type=Options.T_INT, default=3, required=False, multi=False, hide=True, choice=None,
|
|
58
|
-
discription_ja="Redisサーバーへの再接続回数を指定します。0以下を指定すると永遠に再接続を行います。",
|
|
59
|
-
discription_en="Specifies the number of reconnections to the Redis server.If less than 0 is specified, reconnection is forever."),
|
|
60
|
-
dict(opt="retry_interval", type=Options.T_INT, default=5, required=False, multi=False, hide=True, choice=None,
|
|
61
|
-
discription_ja="Redisサーバーに再接続までの秒数を指定します。",
|
|
62
|
-
discription_en="Specifies the number of seconds before reconnecting to the Redis server."),
|
|
63
|
-
dict(opt="timeout", type=Options.T_INT, default="15", required=False, multi=False, hide=True, choice=None,
|
|
64
|
-
discription_ja="サーバーの応答が返ってくるまでの最大待ち時間を指定。",
|
|
65
|
-
discription_en="Specify the maximum waiting time until the server responds."),
|
|
66
|
-
])
|
|
67
|
-
|
|
68
|
-
def get_svcmd(self):
|
|
69
|
-
"""
|
|
70
|
-
この機能のサーバー側のコマンドを返します
|
|
71
|
-
|
|
72
|
-
Returns:
|
|
73
|
-
str: サーバー側のコマンド
|
|
74
|
-
"""
|
|
75
|
-
return 'server_time'
|
|
76
|
-
|
|
77
|
-
def apprun(self, logger:logging.Logger, args:argparse.Namespace, tm:float, pf:List[Dict[str, float]]=[]) -> Tuple[int, Dict[str, Any], Any]:
|
|
78
|
-
"""
|
|
79
|
-
この機能の実行を行います
|
|
80
|
-
|
|
81
|
-
Args:
|
|
82
|
-
logger (logging.Logger): ロガー
|
|
83
|
-
args (argparse.Namespace): 引数
|
|
84
|
-
tm (float): 実行開始時間
|
|
85
|
-
pf (List[Dict[str, float]]): 呼出元のパフォーマンス情報
|
|
86
|
-
|
|
87
|
-
Returns:
|
|
88
|
-
Tuple[int, Dict[str, Any], Any]: 終了コード, 結果, オブジェクト
|
|
89
|
-
"""
|
|
90
|
-
cl = client.Client(logger, redis_host=args.host, redis_port=args.port, redis_password=args.password, svname=args.svname)
|
|
91
|
-
ret = cl.redis_cli.send_cmd(self.get_svcmd(), [str(args.timedelta)],
|
|
92
|
-
retry_count=args.retry_count, retry_interval=args.retry_interval, timeout=args.timeout)
|
|
93
|
-
common.print_format(ret, args.format, tm, args.output_json, args.output_json_append, pf=pf)
|
|
94
|
-
if 'success' not in ret:
|
|
95
|
-
return 1, ret, None
|
|
96
|
-
return 0, ret, None
|
|
97
|
-
|
|
98
|
-
def is_cluster_redirect(self):
|
|
99
|
-
"""
|
|
100
|
-
クラスター宛のメッセージの場合、メッセージを転送するかどうかを返します
|
|
101
|
-
|
|
102
|
-
Returns:
|
|
103
|
-
bool: メッセージを転送する場合はTrue
|
|
104
|
-
"""
|
|
105
|
-
return False
|
|
106
|
-
|
|
107
|
-
def svrun(self, data_dir:Path, logger:logging.Logger, redis_cli:redis_client.RedisClient, msg:List[str],
|
|
108
|
-
sessions:Dict[str, Dict[str, Any]]) -> int:
|
|
109
|
-
"""
|
|
110
|
-
この機能のサーバー側の実行を行います
|
|
111
|
-
|
|
112
|
-
Args:
|
|
113
|
-
data_dir (Path): データディレクトリ
|
|
114
|
-
logger (logging.Logger): ロガー
|
|
115
|
-
redis_cli (redis_client.RedisClient): Redisクライアント
|
|
116
|
-
msg (List[str]): 受信メッセージ
|
|
117
|
-
sessions (Dict[str, Dict[str, Any]]): セッション情報
|
|
118
|
-
|
|
119
|
-
Returns:
|
|
120
|
-
int: 終了コード
|
|
121
|
-
"""
|
|
122
|
-
td = 9 if msg[2] == None else int(msg[2])
|
|
123
|
-
tz = datetime.timezone(datetime.timedelta(hours=td))
|
|
124
|
-
dt = datetime.datetime.now(tz)
|
|
125
|
-
ret = dict(success=dict(data=dt.strftime('%Y-%m-%d %H:%M:%S')))
|
|
126
|
-
redis_cli.rpush(msg[1], ret)
|
|
127
|
-
return self.RESP_SCCESS
|
|
128
|
-
|
|
129
|
-
def edgerun(self, opt, tool, logger, timeout, prevres = None):
|
|
130
|
-
"""
|
|
131
|
-
この機能のエッジ側の実行を行います
|
|
132
|
-
|
|
133
|
-
Args:
|
|
134
|
-
opt (Dict[str, Any]): オプション
|
|
135
|
-
tool (edge.Tool): 通知関数などedge側のUI操作を行うためのクラス
|
|
136
|
-
logger (logging.Logger): ロガー
|
|
137
|
-
timeout (int): タイムアウト時間
|
|
138
|
-
prevres (Any): 前コマンドの結果。pipeline実行の実行結果を参照する時に使用します。
|
|
139
|
-
|
|
140
|
-
Yields:
|
|
141
|
-
Tuple[int, Dict[str, Any]]: 終了コード, 結果
|
|
142
|
-
"""
|
|
143
|
-
status, res = tool.exec_cmd(opt, logger, timeout, prevres)
|
|
144
|
-
tool.notify(res)
|
|
145
|
-
yield 1, res
|
|
1
|
+
from cmdbox.app import common, client, feature
|
|
2
|
+
from cmdbox.app.commons import redis_client
|
|
3
|
+
from cmdbox.app.options import Options
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Dict, Any, Tuple, Union, List
|
|
6
|
+
import argparse
|
|
7
|
+
import datetime
|
|
8
|
+
import logging
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ServerTime(feature.Feature):
|
|
12
|
+
def get_mode(self) -> Union[str, List[str]]:
|
|
13
|
+
"""
|
|
14
|
+
この機能のモードを返します
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
Union[str, List[str]]: モード
|
|
18
|
+
"""
|
|
19
|
+
return "server"
|
|
20
|
+
|
|
21
|
+
def get_cmd(self):
|
|
22
|
+
"""
|
|
23
|
+
この機能のコマンドを返します
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
str: コマンド
|
|
27
|
+
"""
|
|
28
|
+
return 'time'
|
|
29
|
+
|
|
30
|
+
def get_option(self):
|
|
31
|
+
"""
|
|
32
|
+
この機能のオプションを返します
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
Dict[str, Any]: オプション
|
|
36
|
+
"""
|
|
37
|
+
return dict(
|
|
38
|
+
type=Options.T_STR, default=None, required=False, multi=False, hide=False, use_redis=self.USE_REDIS_FALSE,
|
|
39
|
+
discription_ja="サーバー側の現在時刻を表示します。",
|
|
40
|
+
discription_en="Displays the current time at the server side.",
|
|
41
|
+
choice=[
|
|
42
|
+
dict(opt="host", type=Options.T_STR, default=self.default_host, required=True, multi=False, hide=True, choice=None,
|
|
43
|
+
discription_ja="Redisサーバーのサービスホストを指定します。",
|
|
44
|
+
discription_en="Specify the service host of the Redis server."),
|
|
45
|
+
dict(opt="port", type=Options.T_INT, default=self.default_port, required=True, multi=False, hide=True, choice=None,
|
|
46
|
+
discription_ja="Redisサーバーのサービスポートを指定します。",
|
|
47
|
+
discription_en="Specify the service port of the Redis server."),
|
|
48
|
+
dict(opt="password", type=Options.T_STR, default=self.default_pass, required=True, multi=False, hide=True, choice=None,
|
|
49
|
+
discription_ja="Redisサーバーのアクセスパスワード(任意)を指定します。省略時は `password` を使用します。",
|
|
50
|
+
discription_en="Specify the access password of the Redis server (optional). If omitted, `password` is used."),
|
|
51
|
+
dict(opt="svname", type=Options.T_STR, default="server", required=True, multi=False, hide=True, choice=None,
|
|
52
|
+
discription_ja="サーバーのサービス名を指定します。省略時は `server` を使用します。",
|
|
53
|
+
discription_en="Specify the service name of the inference server. If omitted, `server` is used."),
|
|
54
|
+
dict(opt="timedelta", type=Options.T_INT, default=9, required=False, multi=False, hide=False, choice=None,
|
|
55
|
+
discription_ja="時差の時間数を指定します。",
|
|
56
|
+
discription_en="Specify the number of hours of time difference."),
|
|
57
|
+
dict(opt="retry_count", type=Options.T_INT, default=3, required=False, multi=False, hide=True, choice=None,
|
|
58
|
+
discription_ja="Redisサーバーへの再接続回数を指定します。0以下を指定すると永遠に再接続を行います。",
|
|
59
|
+
discription_en="Specifies the number of reconnections to the Redis server.If less than 0 is specified, reconnection is forever."),
|
|
60
|
+
dict(opt="retry_interval", type=Options.T_INT, default=5, required=False, multi=False, hide=True, choice=None,
|
|
61
|
+
discription_ja="Redisサーバーに再接続までの秒数を指定します。",
|
|
62
|
+
discription_en="Specifies the number of seconds before reconnecting to the Redis server."),
|
|
63
|
+
dict(opt="timeout", type=Options.T_INT, default="15", required=False, multi=False, hide=True, choice=None,
|
|
64
|
+
discription_ja="サーバーの応答が返ってくるまでの最大待ち時間を指定。",
|
|
65
|
+
discription_en="Specify the maximum waiting time until the server responds."),
|
|
66
|
+
])
|
|
67
|
+
|
|
68
|
+
def get_svcmd(self):
|
|
69
|
+
"""
|
|
70
|
+
この機能のサーバー側のコマンドを返します
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
str: サーバー側のコマンド
|
|
74
|
+
"""
|
|
75
|
+
return 'server_time'
|
|
76
|
+
|
|
77
|
+
def apprun(self, logger:logging.Logger, args:argparse.Namespace, tm:float, pf:List[Dict[str, float]]=[]) -> Tuple[int, Dict[str, Any], Any]:
|
|
78
|
+
"""
|
|
79
|
+
この機能の実行を行います
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
logger (logging.Logger): ロガー
|
|
83
|
+
args (argparse.Namespace): 引数
|
|
84
|
+
tm (float): 実行開始時間
|
|
85
|
+
pf (List[Dict[str, float]]): 呼出元のパフォーマンス情報
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
Tuple[int, Dict[str, Any], Any]: 終了コード, 結果, オブジェクト
|
|
89
|
+
"""
|
|
90
|
+
cl = client.Client(logger, redis_host=args.host, redis_port=args.port, redis_password=args.password, svname=args.svname)
|
|
91
|
+
ret = cl.redis_cli.send_cmd(self.get_svcmd(), [str(args.timedelta)],
|
|
92
|
+
retry_count=args.retry_count, retry_interval=args.retry_interval, timeout=args.timeout)
|
|
93
|
+
common.print_format(ret, args.format, tm, args.output_json, args.output_json_append, pf=pf)
|
|
94
|
+
if 'success' not in ret:
|
|
95
|
+
return 1, ret, None
|
|
96
|
+
return 0, ret, None
|
|
97
|
+
|
|
98
|
+
def is_cluster_redirect(self):
|
|
99
|
+
"""
|
|
100
|
+
クラスター宛のメッセージの場合、メッセージを転送するかどうかを返します
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
bool: メッセージを転送する場合はTrue
|
|
104
|
+
"""
|
|
105
|
+
return False
|
|
106
|
+
|
|
107
|
+
def svrun(self, data_dir:Path, logger:logging.Logger, redis_cli:redis_client.RedisClient, msg:List[str],
|
|
108
|
+
sessions:Dict[str, Dict[str, Any]]) -> int:
|
|
109
|
+
"""
|
|
110
|
+
この機能のサーバー側の実行を行います
|
|
111
|
+
|
|
112
|
+
Args:
|
|
113
|
+
data_dir (Path): データディレクトリ
|
|
114
|
+
logger (logging.Logger): ロガー
|
|
115
|
+
redis_cli (redis_client.RedisClient): Redisクライアント
|
|
116
|
+
msg (List[str]): 受信メッセージ
|
|
117
|
+
sessions (Dict[str, Dict[str, Any]]): セッション情報
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
int: 終了コード
|
|
121
|
+
"""
|
|
122
|
+
td = 9 if msg[2] == None else int(msg[2])
|
|
123
|
+
tz = datetime.timezone(datetime.timedelta(hours=td))
|
|
124
|
+
dt = datetime.datetime.now(tz)
|
|
125
|
+
ret = dict(success=dict(data=dt.strftime('%Y-%m-%d %H:%M:%S')))
|
|
126
|
+
redis_cli.rpush(msg[1], ret)
|
|
127
|
+
return self.RESP_SCCESS
|
|
128
|
+
|
|
129
|
+
def edgerun(self, opt, tool, logger, timeout, prevres = None):
|
|
130
|
+
"""
|
|
131
|
+
この機能のエッジ側の実行を行います
|
|
132
|
+
|
|
133
|
+
Args:
|
|
134
|
+
opt (Dict[str, Any]): オプション
|
|
135
|
+
tool (edge.Tool): 通知関数などedge側のUI操作を行うためのクラス
|
|
136
|
+
logger (logging.Logger): ロガー
|
|
137
|
+
timeout (int): タイムアウト時間
|
|
138
|
+
prevres (Any): 前コマンドの結果。pipeline実行の実行結果を参照する時に使用します。
|
|
139
|
+
|
|
140
|
+
Yields:
|
|
141
|
+
Tuple[int, Dict[str, Any]]: 終了コード, 結果
|
|
142
|
+
"""
|
|
143
|
+
status, res = tool.exec_cmd(opt, logger, timeout, prevres)
|
|
144
|
+
tool.notify(res)
|
|
145
|
+
yield 1, res
|
|
@@ -4,7 +4,7 @@ License for Sphinx
|
|
|
4
4
|
Unless otherwise indicated, all code in the Sphinx project is licenced under the
|
|
5
5
|
two clause BSD licence below.
|
|
6
6
|
|
|
7
|
-
Copyright (c) 2007-
|
|
7
|
+
Copyright (c) 2007-2025 by the Sphinx team (see AUTHORS file).
|
|
8
8
|
All rights reserved.
|
|
9
9
|
|
|
10
10
|
Redistribution and use in source and binary forms, with or without
|
cmdbox/licenses/{LICENSE.babel.2.16.0(BSD License).txt → LICENSE.babel.2.17.0(BSD License).txt }
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c) 2013-
|
|
1
|
+
Copyright (c) 2013-2025 by the Babel Team, see AUTHORS for more information.
|
|
2
2
|
|
|
3
3
|
Redistribution and use in source and binary forms, with or without
|
|
4
4
|
modification, are permitted provided that the following conditions
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
2009-2024 (c) Benoît Chesneau <benoitc@gunicorn.org>
|
|
2
|
+
2009-2015 (c) Paul J. Davis <paul.joseph.davis@gmail.com>
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person
|
|
5
|
+
obtaining a copy of this software and associated documentation
|
|
6
|
+
files (the "Software"), to deal in the Software without
|
|
7
|
+
restriction, including without limitation the rights to use,
|
|
8
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the
|
|
10
|
+
Software is furnished to do so, subject to the following
|
|
11
|
+
conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
18
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
20
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
21
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
22
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
23
|
+
OTHER DEALINGS IN THE SOFTWARE.
|