cmdbox 0.6.3.2__py3-none-any.whl → 0.6.4.1__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.

Files changed (168) hide show
  1. cmdbox/app/app.py +22 -7
  2. cmdbox/app/common.py +9 -6
  3. cmdbox/app/commons/loghandler.py +101 -20
  4. cmdbox/app/commons/redis_client.py +1 -1
  5. cmdbox/app/edge.py +2 -4
  6. cmdbox/app/feature.py +1 -1
  7. cmdbox/app/features/cli/cmdbox_agent_mcp_client.py +175 -0
  8. cmdbox/app/features/cli/cmdbox_agent_mcp_proxy.py +96 -0
  9. cmdbox/app/features/cli/cmdbox_audit_createdb.py +224 -224
  10. cmdbox/app/features/cli/cmdbox_audit_delete.py +4 -4
  11. cmdbox/app/features/cli/cmdbox_audit_search.py +4 -4
  12. cmdbox/app/features/cli/cmdbox_audit_write.py +6 -8
  13. cmdbox/app/features/cli/cmdbox_client_file_copy.py +3 -3
  14. cmdbox/app/features/cli/cmdbox_client_file_download.py +3 -3
  15. cmdbox/app/features/cli/cmdbox_client_file_list.py +3 -3
  16. cmdbox/app/features/cli/cmdbox_client_file_mkdir.py +3 -3
  17. cmdbox/app/features/cli/cmdbox_client_file_move.py +3 -3
  18. cmdbox/app/features/cli/cmdbox_client_file_remove.py +3 -3
  19. cmdbox/app/features/cli/cmdbox_client_file_rmdir.py +3 -3
  20. cmdbox/app/features/cli/cmdbox_client_file_upload.py +3 -3
  21. cmdbox/app/features/cli/cmdbox_client_http.py +7 -6
  22. cmdbox/app/features/cli/cmdbox_client_server_info.py +4 -4
  23. cmdbox/app/features/cli/cmdbox_cmd_list.py +4 -4
  24. cmdbox/app/features/cli/cmdbox_cmd_load.py +5 -5
  25. cmdbox/app/features/cli/cmdbox_edge_config.py +1 -1
  26. cmdbox/app/features/cli/cmdbox_edge_start.py +3 -3
  27. cmdbox/app/features/cli/cmdbox_mcp_client.py +174 -174
  28. cmdbox/app/features/cli/cmdbox_mcp_proxy.py +96 -96
  29. cmdbox/app/features/cli/cmdbox_server_list.py +3 -3
  30. cmdbox/app/features/cli/cmdbox_server_start.py +103 -103
  31. cmdbox/app/features/cli/cmdbox_server_stop.py +6 -6
  32. cmdbox/app/features/cli/cmdbox_tts_install.py +317 -0
  33. cmdbox/app/features/cli/cmdbox_tts_say.py +179 -0
  34. cmdbox/app/features/cli/cmdbox_tts_start.py +329 -0
  35. cmdbox/app/features/cli/cmdbox_tts_stop.py +108 -0
  36. cmdbox/app/features/cli/cmdbox_web_apikey_add.py +91 -91
  37. cmdbox/app/features/cli/cmdbox_web_apikey_del.py +91 -91
  38. cmdbox/app/features/cli/cmdbox_web_gencert.py +7 -7
  39. cmdbox/app/features/cli/cmdbox_web_genpass.py +168 -168
  40. cmdbox/app/features/cli/cmdbox_web_group_add.py +94 -94
  41. cmdbox/app/features/cli/cmdbox_web_group_del.py +87 -87
  42. cmdbox/app/features/cli/cmdbox_web_group_edit.py +94 -94
  43. cmdbox/app/features/cli/cmdbox_web_group_list.py +87 -87
  44. cmdbox/app/features/cli/cmdbox_web_start.py +236 -235
  45. cmdbox/app/features/cli/cmdbox_web_stop.py +72 -72
  46. cmdbox/app/features/cli/cmdbox_web_user_add.py +104 -104
  47. cmdbox/app/features/cli/cmdbox_web_user_del.py +87 -87
  48. cmdbox/app/features/cli/cmdbox_web_user_edit.py +104 -104
  49. cmdbox/app/features/cli/cmdbox_web_user_list.py +87 -87
  50. cmdbox/app/features/web/cmdbox_web_agent.py +16 -4
  51. cmdbox/app/features/web/cmdbox_web_get_cmd_choices.py +10 -2
  52. cmdbox/app/features/web/cmdbox_web_save_cmd.py +1 -0
  53. cmdbox/app/features/web/cmdbox_web_versions_used.py +4 -0
  54. cmdbox/app/filer.py +9 -9
  55. cmdbox/app/mcp.py +19 -8
  56. cmdbox/app/options.py +52 -47
  57. cmdbox/app/server.py +224 -224
  58. cmdbox/app/web.py +39 -17
  59. cmdbox/extensions/features.yml +7 -1
  60. cmdbox/extensions/sample_project/sample/app/features/cli/sample_client_time.py +2 -2
  61. cmdbox/extensions/sample_project/sample/app/features/cli/sample_server_time.py +3 -3
  62. cmdbox/licenses/LICENSE_APScheduler_3_11_0_MIT_License.txt +19 -0
  63. cmdbox/licenses/LICENSE_SQLAlchemy_2_0_43_MIT.txt +19 -0
  64. cmdbox/licenses/LICENSE_Werkzeug_3_1_1_BSD_License.txt +28 -0
  65. cmdbox/licenses/LICENSE_absolufy-imports_0_3_1_MIT_License.txt +21 -0
  66. cmdbox/licenses/LICENSE_anyio_4_10_0_UNKNOWN.txt +20 -0
  67. cmdbox/licenses/{LICENSE_typer_0_16_0_MIT_License.txt → LICENSE_backoff_2_2_1_MIT_License.txt} +1 -1
  68. cmdbox/licenses/LICENSE_certifi_2025_8_3_Mozilla_Public_License_2_0-MPL_2_0.txt +20 -0
  69. cmdbox/licenses/LICENSE_charset-normalizer_3_4_3_MIT.txt +21 -0
  70. cmdbox/licenses/LICENSE_cryptography_45_0_6_Apache-2_0_OR_BSD-3-Clause.txt +3 -0
  71. cmdbox/licenses/LICENSE_cyclopts_3_22_5_Apache_Software_License.txt +201 -0
  72. cmdbox/licenses/LICENSE_fastapi-sso_0_18_0_MIT_License.txt +21 -0
  73. cmdbox/licenses/LICENSE_fastmcp_2_11_3_Apache_Software_License.txt +201 -0
  74. cmdbox/licenses/LICENSE_google-adk_1_9_0_Apache_Software_License.txt +202 -0
  75. cmdbox/licenses/LICENSE_google-genai_1_28_0_Apache_Software_License.txt +202 -0
  76. cmdbox/licenses/LICENSE_google-genai_1_29_0_Apache_Software_License.txt +202 -0
  77. cmdbox/licenses/LICENSE_greenlet_3_2_4_MIT_AND_Python-2_0.txt +30 -0
  78. cmdbox/licenses/LICENSE_isodate_0_7_2_BSD_License.txt +26 -0
  79. cmdbox/licenses/LICENSE_lazy-object-proxy_1_11_0_BSD_License.txt +20 -0
  80. cmdbox/licenses/LICENSE_litellm-enterprise_0_1_19_UNKNOWN.txt +37 -0
  81. cmdbox/licenses/LICENSE_litellm_1_75_5_post1_MIT_License.txt +26 -0
  82. cmdbox/licenses/LICENSE_markdown-it-py_4_0_0_MIT_License.txt +21 -0
  83. cmdbox/licenses/LICENSE_mcp_1_12_4_MIT_License.txt +21 -0
  84. cmdbox/licenses/LICENSE_multidict_6_6_4_Apache_License_2_0.txt +13 -0
  85. cmdbox/licenses/LICENSE_oauthlib_3_3_1_BSD-3-Clause.txt +27 -0
  86. cmdbox/licenses/LICENSE_openai_1_99_9_Apache_Software_License.txt +201 -0
  87. cmdbox/licenses/LICENSE_openapi-core_0_19_5_BSD_License.txt +29 -0
  88. cmdbox/licenses/LICENSE_openapi-schema-validator_0_6_3_BSD_License.txt +29 -0
  89. cmdbox/licenses/LICENSE_openapi-spec-validator_0_7_2_Apache_Software_License.txt +201 -0
  90. cmdbox/licenses/LICENSE_opentelemetry-api_1_36_0_UNKNOWN.txt +201 -0
  91. cmdbox/licenses/LICENSE_opentelemetry-sdk_1_36_0_UNKNOWN.txt +201 -0
  92. cmdbox/licenses/LICENSE_opentelemetry-semantic-conventions_0_57b0_UNKNOWN.txt +201 -0
  93. cmdbox/licenses/LICENSE_orjson_3_11_1_Apache_Software_License-MIT_License.txt +201 -0
  94. cmdbox/licenses/LICENSE_parse_1_20_2_MIT_License.txt +19 -0
  95. cmdbox/licenses/LICENSE_pathable_0_4_4_Apache_Software_License.txt +201 -0
  96. cmdbox/licenses/{LICENSE_pillow_11_2_1_UNKNOWN.txt → LICENSE_pillow_11_3_0_UNKNOWN.txt} +393 -3
  97. cmdbox/licenses/LICENSE_pyperclip_1_9_0_BSD_License.txt +27 -0
  98. cmdbox/licenses/LICENSE_redis_6_4_0_MIT_License.txt +21 -0
  99. cmdbox/licenses/LICENSE_rfc3339-validator_0_1_4_MIT_License.txt +22 -0
  100. cmdbox/licenses/LICENSE_rich-rst_1_3_1_MIT_License.txt +7 -0
  101. cmdbox/licenses/LICENSE_rpds-py_0_27_0_UNKNOWN.txt +19 -0
  102. cmdbox/licenses/{LICENSE_setuptools_65_5_0_MIT_License.txt → LICENSE_setuptools_80_9_0_UNKNOWN.txt} +0 -2
  103. cmdbox/licenses/LICENSE_sphinx-intl_2_3_2_UNKNOWN.txt +25 -0
  104. cmdbox/licenses/LICENSE_tenacity_9_1_2_Apache_Software_License.txt +202 -0
  105. cmdbox/licenses/LICENSE_tiktoken_0_11_0_MIT_License-Copyright-c-2022_OpenAI-Shantanu_Jain-Permission_is_hereby_granted-free_of_charge-to_any_per.txt +21 -0
  106. cmdbox/licenses/LICENSE_tokenizers_0_21_4_Apache_Software_License.txt +1 -0
  107. cmdbox/licenses/LICENSE_voicevox_core_0_16_0_MIT.txt +20 -0
  108. cmdbox/licenses/LICENSE_watchdog_6_0_0_Apache_Software_License.txt +16 -0
  109. cmdbox/licenses/{LICENSE_httptools_0_6_4_MIT_License.txt → LICENSE_wsproto_1_2_0_MIT_License.txt} +3 -3
  110. cmdbox/licenses/files.txt +69 -50
  111. cmdbox/logconf_cmdbox.yml +136 -0
  112. cmdbox/version.py +2 -2
  113. cmdbox/web/agent.html +16 -2
  114. cmdbox/web/assets/cmdbox/agent.js +226 -1
  115. cmdbox/web/assets/cmdbox/common.js +20 -25
  116. cmdbox/web/assets/cmdbox/svgicon.js +18 -0
  117. {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info}/METADATA +29 -20
  118. {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info}/RECORD +158 -118
  119. {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info}/WHEEL +1 -1
  120. cmdbox/config.yml +0 -3
  121. cmdbox/licenses/LICENSE_shellingham_1_5_4_ISC_License-ISCL.txt +0 -13
  122. cmdbox/licenses/LICENSE_watchfiles_1_1_0_MIT_License.txt +0 -21
  123. cmdbox/logconf_audit.yml +0 -43
  124. cmdbox/logconf_client.yml +0 -43
  125. cmdbox/logconf_edge.yml +0 -43
  126. cmdbox/logconf_gui.yml +0 -43
  127. cmdbox/logconf_mcp.yml +0 -43
  128. cmdbox/logconf_server.yml +0 -43
  129. cmdbox/logconf_web.yml +0 -43
  130. /cmdbox/licenses/{LICENSE_Authlib_1_6_0_BSD_License.txt → LICENSE_Authlib_1_6_1_BSD_License.txt} +0 -0
  131. /cmdbox/licenses/{LICENSE_SQLAlchemy_2_0_41_MIT.txt → LICENSE_SQLAlchemy_2_0_42_MIT.txt} +0 -0
  132. /cmdbox/licenses/{LICENSE_aiohttp_3_12_13_Apache-2_0.txt → LICENSE_aiohttp_3_12_15_Apache-2_0_AND_MIT.txt} +0 -0
  133. /cmdbox/licenses/{LICENSE_aiosignal_1_3_2_Apache_Software_License.txt → LICENSE_aiosignal_1_4_0_Apache_Software_License.txt} +0 -0
  134. /cmdbox/licenses/{LICENSE_certifi_2025_6_15_Mozilla_Public_License_2_0-MPL_2_0.txt → LICENSE_certifi_2025_7_14_Mozilla_Public_License_2_0-MPL_2_0.txt} +0 -0
  135. /cmdbox/licenses/{LICENSE_cryptography_45_0_4_Apache-2_0_OR_BSD-3-Clause.txt → LICENSE_cryptography_45_0_5_Apache-2_0_OR_BSD-3-Clause.txt} +0 -0
  136. /cmdbox/licenses/{LICENSE_docstring_parser_0_16_MIT_License.txt → LICENSE_docstring_parser_0_17_0_MIT_License.txt} +0 -0
  137. /cmdbox/licenses/{LICENSE_fastapi_0_115_14_MIT_License.txt → LICENSE_fastapi_0_116_1_MIT_License.txt} +0 -0
  138. /cmdbox/licenses/{LICENSE_fastmcp_2_10_1_Apache_Software_License.txt → LICENSE_fastmcp_2_11_0_Apache_Software_License.txt} +0 -0
  139. /cmdbox/licenses/{LICENSE_fsspec_2025_5_1_BSD_License.txt → LICENSE_fsspec_2025_7_0_BSD_License.txt} +0 -0
  140. /cmdbox/licenses/{LICENSE_google-adk_1_5_0_Apache_Software_License.txt → LICENSE_google-adk_1_10_0_Apache_Software_License.txt} +0 -0
  141. /cmdbox/licenses/{LICENSE_google-api-python-client_2_174_0_Apache_Software_License.txt → LICENSE_google-api-python-client_2_177_0_Apache_Software_License.txt} +0 -0
  142. /cmdbox/licenses/{LICENSE_huggingface-hub_0_33_1_Apache_Software_License.txt → LICENSE_google-api-python-client_2_178_0_Apache_Software_License.txt} +0 -0
  143. /cmdbox/licenses/{LICENSE_google-cloud-aiplatform_1_100_0_Apache_2_0.txt → LICENSE_google-cloud-aiplatform_1_106_0_Apache_2_0.txt} +0 -0
  144. /cmdbox/licenses/{LICENSE_google-cloud-bigquery_3_34_0_Apache_Software_License.txt → LICENSE_google-cloud-aiplatform_1_108_0_Apache_2_0.txt} +0 -0
  145. /cmdbox/licenses/{LICENSE_google-genai_1_23_0_Apache_Software_License.txt → LICENSE_google-cloud-bigquery_3_35_1_Apache_Software_License.txt} +0 -0
  146. /cmdbox/licenses/{LICENSE_grpcio-status_1_73_1_Apache_Software_License.txt → LICENSE_grpcio-status_1_74_0_Apache_Software_License.txt} +0 -0
  147. /cmdbox/licenses/{LICENSE_grpcio_1_73_1_Apache_Software_License.txt → LICENSE_grpcio_1_74_0_Apache_Software_License.txt} +0 -0
  148. /cmdbox/licenses/{LICENSE_opentelemetry-api_1_34_1_Apache_Software_License.txt → LICENSE_huggingface-hub_0_34_3_Apache_Software_License.txt} +0 -0
  149. /cmdbox/licenses/{LICENSE_opentelemetry-sdk_1_34_1_Apache_Software_License.txt → LICENSE_huggingface-hub_0_34_4_Apache_Software_License.txt} +0 -0
  150. /cmdbox/licenses/{LICENSE_opentelemetry-semantic-conventions_0_55b1_Apache_Software_License.txt → LICENSE_jsonschema-path_0_3_4_Apache_Software_License.txt} +0 -0
  151. /cmdbox/licenses/{LICENSE_jsonschema_4_24_0_UNKNOWN.txt → LICENSE_jsonschema_4_25_0_UNKNOWN.txt} +0 -0
  152. /cmdbox/licenses/{LICENSE_litellm_1_73_6_MIT_License.txt → LICENSE_litellm_1_74_12_MIT_License.txt} +0 -0
  153. /cmdbox/licenses/{LICENSE_mcp_1_10_1_MIT_License.txt → LICENSE_mcp_1_12_3_MIT_License.txt} +0 -0
  154. /cmdbox/licenses/{LICENSE_multidict_6_6_2_Apache_License_2_0.txt → LICENSE_multidict_6_6_3_Apache_License_2_0.txt} +0 -0
  155. /cmdbox/licenses/{LICENSE_nh3_0_2_21_MIT.txt → LICENSE_nh3_0_3_0_MIT.txt} +0 -0
  156. /cmdbox/licenses/{LICENSE_numpy_2_3_1_BSD_License.txt → LICENSE_numpy_2_3_2_BSD_License.txt} +0 -0
  157. /cmdbox/licenses/{LICENSE_openai_1_93_0_Apache_Software_License.txt → LICENSE_openai_1_98_0_Apache_Software_License.txt} +0 -0
  158. /cmdbox/licenses/{LICENSE_tokenizers_0_21_2_Apache_Software_License.txt → LICENSE_pywin32_311_Python_Software_Foundation_License.txt} +0 -0
  159. /cmdbox/licenses/{LICENSE_regex_2024_11_6_Apache_Software_License.txt → LICENSE_regex_2025_7_34_UNKNOWN.txt} +0 -0
  160. /cmdbox/licenses/{LICENSE_rich_14_0_0_MIT_License.txt → LICENSE_rich_14_1_0_MIT_License.txt} +0 -0
  161. /cmdbox/licenses/{LICENSE_rpds-py_0_25_1_MIT.txt → LICENSE_rpds-py_0_26_0_MIT.txt} +0 -0
  162. /cmdbox/licenses/{LICENSE_sse-starlette_2_3_6_BSD_License.txt → LICENSE_sse-starlette_3_0_2_UNKNOWN.txt} +0 -0
  163. /cmdbox/licenses/{LICENSE_starlette_0_46_2_BSD_License.txt → LICENSE_starlette_0_47_2_BSD_License.txt} +0 -0
  164. /cmdbox/licenses/{LICENSE_typing_extensions_4_14_0_UNKNOWN.txt → LICENSE_typing_extensions_4_14_1_UNKNOWN.txt} +0 -0
  165. /cmdbox/licenses/{LICENSE_zope_event_5_1_Zope_Public_License.txt → LICENSE_zope_event_5_1_1_Zope_Public_License.txt} +0 -0
  166. {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info}/entry_points.txt +0 -0
  167. {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info/licenses}/LICENSE +0 -0
  168. {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info}/top_level.txt +0 -0
@@ -1,103 +1,103 @@
1
- from cmdbox.app import common, feature, server
2
- from cmdbox.app.options import Options
3
- from pathlib import Path
4
- from typing import Dict, Any, Tuple, List, Union
5
- import argparse
6
- import logging
7
-
8
-
9
- class ServerStart(feature.OneshotNotifyEdgeFeature):
10
- def get_mode(self) -> Union[str, List[str]]:
11
- """
12
- この機能のモードを返します
13
-
14
- Returns:
15
- Union[str, List[str]]: モード
16
- """
17
- return 'server'
18
-
19
- def get_cmd(self):
20
- """
21
- この機能のコマンドを返します
22
-
23
- Returns:
24
- str: コマンド
25
- """
26
- return 'start'
27
-
28
- def get_option(self):
29
- """
30
- この機能のオプションを返します
31
-
32
- Returns:
33
- Dict[str, Any]: オプション
34
- """
35
- return dict(
36
- use_redis=self.USE_REDIS_TRUE, nouse_webmode=True,
37
- description_ja="サーバーを起動します。installモードで `cmdbox -m install -c server` を実行している場合は、 `docker-compose up -d` を使用してください。",
38
- description_en="Start the inference server. If you are running `cmdbox -m install -c server` in install mode, use `docker-compose up -d`.",
39
- choice=[
40
- dict(opt="host", type=Options.T_STR, default=self.default_host, required=True, multi=False, hide=True, choice=None, web="mask",
41
- description_ja="Redisサーバーのサービスホストを指定します。",
42
- description_en="Specify the service host of the Redis server."),
43
- dict(opt="port", type=Options.T_INT, default=self.default_port, required=True, multi=False, hide=True, choice=None, web="mask",
44
- description_ja="Redisサーバーのサービスポートを指定します。",
45
- description_en="Specify the service port of the Redis server."),
46
- dict(opt="password", type=Options.T_STR, default=self.default_pass, required=True, multi=False, hide=True, choice=None, web="mask",
47
- description_ja="Redisサーバーのアクセスパスワード(任意)を指定します。省略時は `password` を使用します。",
48
- description_en="Specify the access password of the Redis server (optional). If omitted, `password` is used."),
49
- dict(opt="svname", type=Options.T_STR, default=self.default_svname, required=True, multi=False, hide=True, choice=None, web="readonly",
50
- description_ja="サーバーのサービス名を指定します。省略時は `server` を使用します。",
51
- description_en="Specify the service name of the inference server. If omitted, `server` is used."),
52
- dict(opt="data", type=Options.T_DIR, default=self.default_data, required=False, multi=False, hide=False, choice=None,
53
- description_ja=f"省略した時は `$HONE/.{self.ver.__appid__}` を使用します。",
54
- description_en=f"When omitted, `$HONE/.{self.ver.__appid__}` is used."),
55
- dict(opt="retry_count", type=Options.T_INT, default=20, required=False, multi=False, hide=True, choice=None,
56
- description_ja="Redisサーバーへの再接続回数を指定します。0以下を指定すると永遠に再接続を行います。",
57
- description_en="Specifies the number of reconnections to the Redis server.If less than 0 is specified, reconnection is forever."),
58
- dict(opt="retry_interval", type=Options.T_INT, default=5, required=False, multi=False, hide=True, choice=None,
59
- description_ja="Redisサーバーに再接続までの秒数を指定します。",
60
- description_en="Specifies the number of seconds before reconnecting to the Redis server."),
61
- dict(opt="output_json", short="o", type=Options.T_FILE, default=None, required=False, multi=False, hide=True, choice=None, fileio="out",
62
- description_ja="処理結果jsonの保存先ファイルを指定。",
63
- description_en="Specify the destination file for saving the processing result json."),
64
- dict(opt="output_json_append", short="a", type=Options.T_BOOL, default=False, required=False, multi=False, hide=True, choice=[True, False],
65
- description_ja="処理結果jsonファイルを追記保存します。",
66
- description_en="Save the processing result json file by appending."),
67
- dict(opt="stdout_log", type=Options.T_BOOL, default=True, required=False, multi=False, hide=True, choice=[True, False],
68
- description_ja="GUIモードでのみ使用可能です。コマンド実行時の標準出力をConsole logに出力します。",
69
- description_en="Available only in GUI mode. Outputs standard output during command execution to Console log."),
70
- dict(opt="capture_stdout", type=Options.T_BOOL, default=True, required=False, multi=False, hide=True, choice=[True, False],
71
- description_ja="GUIモードでのみ使用可能です。コマンド実行時の標準出力をキャプチャーし、実行結果画面に表示します。",
72
- description_en="Available only in GUI mode. Captures standard output during command execution and displays it on the execution result screen."),
73
- dict(opt="capture_maxsize", type=Options.T_INT, default=self.DEFAULT_CAPTURE_MAXSIZE, required=False, multi=False, hide=True, choice=None,
74
- description_ja="GUIモードでのみ使用可能です。コマンド実行時の標準出力の最大キャプチャーサイズを指定します。",
75
- description_en="Available only in GUI mode. Specifies the maximum capture size of standard output when executing commands."),
76
- ]
77
- )
78
-
79
- def apprun(self, logger:logging.Logger, args:argparse.Namespace, tm:float, pf:List[Dict[str, float]]=[]) -> Tuple[int, Dict[str, Any], Any]:
80
- """
81
- この機能の実行を行います
82
-
83
- Args:
84
- logger (logging.Logger): ロガー
85
- args (argparse.Namespace): 引数
86
- tm (float): 実行開始時間
87
- pf (List[Dict[str, float]]): 呼出元のパフォーマンス情報
88
-
89
- Returns:
90
- Tuple[int, Dict[str, Any], Any]: 終了コード, 結果, オブジェクト
91
- """
92
- if args.data is None:
93
- msg = dict(warn=f"Please specify the --data option.")
94
- common.print_format(msg, args.format, tm, args.output_json, args.output_json_append, pf=pf)
95
- return 1, msg
96
- if args.svname is None:
97
- msg = dict(warn=f"Please specify the --svname option.")
98
- common.print_format(msg, args.format, tm, args.output_json, args.output_json_append, pf=pf)
99
- return 1, msg
100
- sv = server.Server(Path(args.data), logger, redis_host=args.host, redis_port=args.port, redis_password=args.password, svname=args.svname)
101
- sv.start_server(args.retry_count, args.retry_interval)
102
-
103
- return 0, dict(warn=f"server stoped. svname={sv.svname}"), sv
1
+ from cmdbox.app import common, feature, server
2
+ from cmdbox.app.options import Options
3
+ from pathlib import Path
4
+ from typing import Dict, Any, Tuple, List, Union
5
+ import argparse
6
+ import logging
7
+
8
+
9
+ class ServerStart(feature.UnsupportEdgeFeature):
10
+ def get_mode(self) -> Union[str, List[str]]:
11
+ """
12
+ この機能のモードを返します
13
+
14
+ Returns:
15
+ Union[str, List[str]]: モード
16
+ """
17
+ return 'server'
18
+
19
+ def get_cmd(self):
20
+ """
21
+ この機能のコマンドを返します
22
+
23
+ Returns:
24
+ str: コマンド
25
+ """
26
+ return 'start'
27
+
28
+ def get_option(self):
29
+ """
30
+ この機能のオプションを返します
31
+
32
+ Returns:
33
+ Dict[str, Any]: オプション
34
+ """
35
+ return dict(
36
+ use_redis=self.USE_REDIS_TRUE, nouse_webmode=True, use_agent=False,
37
+ description_ja="サーバーを起動します。installモードで `cmdbox -m install -c server` を実行している場合は、 `docker-compose up -d` を使用してください。",
38
+ description_en="Start the inference server. If you are running `cmdbox -m install -c server` in install mode, use `docker-compose up -d`.",
39
+ choice=[
40
+ dict(opt="host", type=Options.T_STR, default=self.default_host, required=True, multi=False, hide=True, choice=None, web="mask",
41
+ description_ja="Redisサーバーのサービスホストを指定します。",
42
+ description_en="Specify the service host of the Redis server."),
43
+ dict(opt="port", type=Options.T_INT, default=self.default_port, required=True, multi=False, hide=True, choice=None, web="mask",
44
+ description_ja="Redisサーバーのサービスポートを指定します。",
45
+ description_en="Specify the service port of the Redis server."),
46
+ dict(opt="password", type=Options.T_STR, default=self.default_pass, required=True, multi=False, hide=True, choice=None, web="mask",
47
+ description_ja="Redisサーバーのアクセスパスワード(任意)を指定します。省略時は `password` を使用します。",
48
+ description_en="Specify the access password of the Redis server (optional). If omitted, `password` is used."),
49
+ dict(opt="svname", type=Options.T_STR, default=self.default_svname, required=True, multi=False, hide=True, choice=None, web="readonly",
50
+ description_ja="サーバーのサービス名を指定します。省略時は `server` を使用します。",
51
+ description_en="Specify the service name of the inference server. If omitted, `server` is used."),
52
+ dict(opt="data", type=Options.T_DIR, default=self.default_data, required=False, multi=False, hide=False, choice=None,
53
+ description_ja=f"省略した時は `$HONE/.{self.ver.__appid__}` を使用します。",
54
+ description_en=f"When omitted, `$HONE/.{self.ver.__appid__}` is used."),
55
+ dict(opt="retry_count", type=Options.T_INT, default=20, required=False, multi=False, hide=True, choice=None,
56
+ description_ja="Redisサーバーへの再接続回数を指定します。0以下を指定すると永遠に再接続を行います。",
57
+ description_en="Specifies the number of reconnections to the Redis server.If less than 0 is specified, reconnection is forever."),
58
+ dict(opt="retry_interval", type=Options.T_INT, default=5, required=False, multi=False, hide=True, choice=None,
59
+ description_ja="Redisサーバーに再接続までの秒数を指定します。",
60
+ description_en="Specifies the number of seconds before reconnecting to the Redis server."),
61
+ dict(opt="output_json", short="o", type=Options.T_FILE, default=None, required=False, multi=False, hide=True, choice=None, fileio="out",
62
+ description_ja="処理結果jsonの保存先ファイルを指定。",
63
+ description_en="Specify the destination file for saving the processing result json."),
64
+ dict(opt="output_json_append", short="a", type=Options.T_BOOL, default=False, required=False, multi=False, hide=True, choice=[True, False],
65
+ description_ja="処理結果jsonファイルを追記保存します。",
66
+ description_en="Save the processing result json file by appending."),
67
+ dict(opt="stdout_log", type=Options.T_BOOL, default=True, required=False, multi=False, hide=True, choice=[True, False],
68
+ description_ja="GUIモードでのみ使用可能です。コマンド実行時の標準出力をConsole logに出力します。",
69
+ description_en="Available only in GUI mode. Outputs standard output during command execution to Console log."),
70
+ dict(opt="capture_stdout", type=Options.T_BOOL, default=True, required=False, multi=False, hide=True, choice=[True, False],
71
+ description_ja="GUIモードでのみ使用可能です。コマンド実行時の標準出力をキャプチャーし、実行結果画面に表示します。",
72
+ description_en="Available only in GUI mode. Captures standard output during command execution and displays it on the execution result screen."),
73
+ dict(opt="capture_maxsize", type=Options.T_INT, default=self.DEFAULT_CAPTURE_MAXSIZE, required=False, multi=False, hide=True, choice=None,
74
+ description_ja="GUIモードでのみ使用可能です。コマンド実行時の標準出力の最大キャプチャーサイズを指定します。",
75
+ description_en="Available only in GUI mode. Specifies the maximum capture size of standard output when executing commands."),
76
+ ]
77
+ )
78
+
79
+ def apprun(self, logger:logging.Logger, args:argparse.Namespace, tm:float, pf:List[Dict[str, float]]=[]) -> Tuple[int, Dict[str, Any], Any]:
80
+ """
81
+ この機能の実行を行います
82
+
83
+ Args:
84
+ logger (logging.Logger): ロガー
85
+ args (argparse.Namespace): 引数
86
+ tm (float): 実行開始時間
87
+ pf (List[Dict[str, float]]): 呼出元のパフォーマンス情報
88
+
89
+ Returns:
90
+ Tuple[int, Dict[str, Any], Any]: 終了コード, 結果, オブジェクト
91
+ """
92
+ if args.data is None:
93
+ msg = dict(warn=f"Please specify the --data option.")
94
+ common.print_format(msg, args.format, tm, args.output_json, args.output_json_append, pf=pf)
95
+ return self.RESP_WARN, msg
96
+ if args.svname is None:
97
+ msg = dict(warn=f"Please specify the --svname option.")
98
+ common.print_format(msg, args.format, tm, args.output_json, args.output_json_append, pf=pf)
99
+ return self.RESP_WARN, msg
100
+ sv = server.Server(Path(args.data), logger, redis_host=args.host, redis_port=args.port, redis_password=args.password, svname=args.svname)
101
+ sv.start_server(args.retry_count, args.retry_interval)
102
+
103
+ return self.RESP_SUCCESS, dict(success=f"server stoped. svname={sv.svname}"), sv
@@ -7,7 +7,7 @@ import argparse
7
7
  import logging
8
8
 
9
9
 
10
- class ServerStop(feature.OneshotNotifyEdgeFeature):
10
+ class ServerStop(feature.UnsupportEdgeFeature):
11
11
  def get_mode(self) -> Union[str, List[str]]:
12
12
  """
13
13
  この機能のモードを返します
@@ -34,7 +34,7 @@ class ServerStop(feature.OneshotNotifyEdgeFeature):
34
34
  Dict[str, Any]: オプション
35
35
  """
36
36
  return dict(
37
- use_redis=self.USE_REDIS_TRUE, nouse_webmode=True,
37
+ use_redis=self.USE_REDIS_TRUE, nouse_webmode=True, use_agent=False,
38
38
  description_ja="サーバーを停止します。installモードで `cmdbox -m install -c server` を実行している場合は、 `docker-compose down` を使用してください。",
39
39
  description_en="Stop the inference server. If you are running `cmdbox -m install -c server` in install mode, use `docker-compose down`.",
40
40
  choice=[
@@ -102,13 +102,13 @@ class ServerStop(feature.OneshotNotifyEdgeFeature):
102
102
  if args.svname is None:
103
103
  msg = dict(warn=f"Please specify the --svname option.")
104
104
  common.print_format(msg, args.format, tm, args.output_json, args.output_json_append, pf=pf)
105
- return 1, msg
105
+ return self.RESP_WARN, msg
106
106
  cl = client.Client(logger, redis_host=args.host, redis_port=args.port, redis_password=args.password, svname=args.svname)
107
107
  ret = cl.stop_server(retry_count=args.retry_count, retry_interval=args.retry_interval, timeout=args.timeout)
108
108
  common.print_format(ret, args.format, tm, args.output_json, args.output_json_append, pf=pf)
109
109
  if 'success' not in ret:
110
- return 1, ret, cl
111
- return 0, ret, cl
110
+ return self.RESP_WARN, ret, cl
111
+ return self.RESP_SUCCESS, ret, cl
112
112
 
113
113
  def is_cluster_redirect(self):
114
114
  """
@@ -135,4 +135,4 @@ class ServerStop(feature.OneshotNotifyEdgeFeature):
135
135
  int: 終了コード
136
136
  """
137
137
  redis_cli.rpush(msg[1], dict(success=f"Successful stop server. svname={redis_cli.svname}"))
138
- return self.RESP_SCCESS
138
+ return self.RESP_SUCCESS
@@ -0,0 +1,317 @@
1
+ from cmdbox import version
2
+ from cmdbox.app import common, client, feature
3
+ from cmdbox.app.commons import convert, redis_client
4
+ from cmdbox.app.options import Options
5
+ from pathlib import Path
6
+ from typing import Dict, Any, Tuple, List, Union
7
+ import argparse
8
+ import glob
9
+ import logging
10
+ import pip
11
+ import requests
12
+ import shutil
13
+ import subprocess
14
+ import sys
15
+
16
+
17
+ class TtsInstall(feature.UnsupportEdgeFeature):
18
+ def get_mode(self) -> Union[str, List[str]]:
19
+ """
20
+ この機能のモードを返します
21
+
22
+ Returns:
23
+ Union[str, List[str]]: モード
24
+ """
25
+ return 'tts'
26
+
27
+ def get_cmd(self):
28
+ """
29
+ この機能のコマンドを返します
30
+
31
+ Returns:
32
+ str: コマンド
33
+ """
34
+ return 'install'
35
+
36
+ def get_option(self):
37
+ """
38
+ この機能のオプションを返します
39
+
40
+ Returns:
41
+ Dict[str, Any]: オプション
42
+ """
43
+ return dict(
44
+ use_redis=self.USE_REDIS_MEIGHT, nouse_webmode=True, use_agent=False,
45
+ description_ja="Text-to-Speech(TTS)エンジンをインストールします。",
46
+ description_en="Installs the Text-to-Speech (TTS) engine.",
47
+ choice=[
48
+ dict(opt="host", type=Options.T_STR, default=self.default_host, required=True, multi=False, hide=True, choice=None, web="mask",
49
+ description_ja="Redisサーバーのサービスホストを指定します。",
50
+ description_en="Specify the service host of the Redis server."),
51
+ dict(opt="port", type=Options.T_INT, default=self.default_port, required=True, multi=False, hide=True, choice=None, web="mask",
52
+ description_ja="Redisサーバーのサービスポートを指定します。",
53
+ description_en="Specify the service port of the Redis server."),
54
+ dict(opt="password", type=Options.T_STR, default=self.default_pass, required=True, multi=False, hide=True, choice=None, web="mask",
55
+ description_ja=f"Redisサーバーのアクセスパスワード(任意)を指定します。省略時は `{self.default_pass}` を使用します。",
56
+ description_en=f"Specify the access password of the Redis server (optional). If omitted, `{self.default_pass}` is used."),
57
+ dict(opt="svname", type=Options.T_STR, default=self.default_svname, required=True, multi=False, hide=True, choice=None, web="readonly",
58
+ description_ja="サーバーのサービス名を指定します。省略時は `server` を使用します。",
59
+ description_en="Specify the service name of the inference server. If omitted, `server` is used."),
60
+ dict(opt="retry_count", type=Options.T_INT, default=3, required=False, multi=False, hide=True, choice=None,
61
+ description_ja="Redisサーバーへの再接続回数を指定します。0以下を指定すると永遠に再接続を行います。",
62
+ description_en="Specifies the number of reconnections to the Redis server.If less than 0 is specified, reconnection is forever."),
63
+ dict(opt="retry_interval", type=Options.T_INT, default=5, required=False, multi=False, hide=True, choice=None,
64
+ description_ja="Redisサーバーに再接続までの秒数を指定します。",
65
+ description_en="Specifies the number of seconds before reconnecting to the Redis server."),
66
+ dict(opt="timeout", type=Options.T_INT, default="300", required=False, multi=False, hide=True, choice=None,
67
+ description_ja="サーバーの応答が返ってくるまでの最大待ち時間を指定。",
68
+ description_en="Specify the maximum waiting time until the server responds."),
69
+ dict(opt="client_only", type=Options.T_BOOL, default=False, required=False, multi=False, hide=True, choice=[True, False],
70
+ description_ja="サーバーへの接続を行わないようにします。",
71
+ description_en="Do not make connections to the server."),
72
+ dict(opt="tts_engine", type=Options.T_STR, default="voicevox", required=True, multi=False, hide=False,
73
+ choice=["voicevox"],
74
+ choice_show=dict(voicevox=["voicevox_ver", "voicevox_os", "voicevox_arc", "voicevox_device", "voicevox_whl"]),
75
+ description_ja="使用するTTSエンジンを指定します。",
76
+ description_en="Specify the TTS engine to use."),
77
+ dict(opt="voicevox_ver", type=Options.T_STR, default='0.16.0', required=False, multi=False, hide=False, choice=['0.16.0'],
78
+ description_ja="使用するTTSエンジンのバージョンを指定します。",
79
+ description_en="Specify the version of the TTS engine to use."),
80
+ dict(opt="voicevox_os", type=Options.T_STR, default='windows', required=False, multi=False, hide=False, choice=['windows', 'osx', 'linux'],
81
+ description_ja="使用するTTSエンジンのOSを指定します。",
82
+ description_en="Specify the OS for the TTS engine."),
83
+ dict(opt="voicevox_arc", type=Options.T_STR, default='x64', required=False, multi=False, hide=False, choice=['x64', 'arm64'],
84
+ description_ja="使用するTTSエンジンのアーキテクチャを指定します。",
85
+ description_en="Specify the architecture for the TTS engine."),
86
+ dict(opt="voicevox_device", type=Options.T_STR, default='cpu', required=False, multi=False, hide=False, choice=['cpu', 'directml', 'cuda'],
87
+ description_ja="使用するTTSエンジンのデバイスを指定します。",
88
+ description_en="Specify the device for the TTS engine."),
89
+ dict(opt="voicevox_whl", type=Options.T_STR, default='voicevox_core-0.16.0-cp310-abi3-win32.whl', required=False, multi=False, hide=False,
90
+ choice=['voicevox_core-0.16.0-cp310-abi3-win32.whl',
91
+ 'voicevox_core-0.16.0-cp310-abi3-win_amd64.whl',
92
+ 'voicevox_core-0.16.0-cp310-abi3-macosx_10_12_x86_64.whl',
93
+ 'voicevox_core-0.16.0-cp310-abi3-macosx_11_0_arm64.whl',
94
+ 'voicevox_core-0.16.0-cp310-abi3-manylinux_2_34_aarch64.whl',
95
+ 'voicevox_core-0.16.0-cp310-abi3-manylinux_2_34_x86_64.whl'],
96
+ choice_edit=True,
97
+ description_ja="使用するTTSエンジンのホイールファイルを指定します。",
98
+ description_en="Specify the wheel file for the TTS engine."),
99
+ ]
100
+ )
101
+
102
+ def get_svcmd(self):
103
+ """
104
+ この機能のサーバー側のコマンドを返します
105
+
106
+ Returns:
107
+ str: サーバー側のコマンド
108
+ """
109
+ return 'tts_install'
110
+
111
+ def apprun(self, logger:logging.Logger, args:argparse.Namespace, tm:float, pf:List[Dict[str, float]]=[]) -> Tuple[int, Dict[str, Any], Any]:
112
+ """
113
+ この機能の実行を行います
114
+
115
+ Args:
116
+ logger (logging.Logger): ロガー
117
+ args (argparse.Namespace): 引数
118
+ tm (float): 実行開始時間
119
+ pf (List[Dict[str, float]]): 呼出元のパフォーマンス情報
120
+
121
+ Returns:
122
+ Tuple[int, Dict[str, Any], Any]: 終了コード, 結果, オブジェクト
123
+ """
124
+ if args.tts_engine is None:
125
+ msg = dict(warn=f"Please specify the --tts_engine option.")
126
+ common.print_format(msg, False, tm, args.output_json, args.output_json_append, pf=pf)
127
+ return self.RESP_WARN, msg, None
128
+ if args.tts_engine == 'voicevox':
129
+ if args.voicevox_ver is None:
130
+ msg = dict(warn=f"Please specify the --voicevox_ver option.")
131
+ common.print_format(msg, False, tm, args.output_json, args.output_json_append, pf=pf)
132
+ return self.RESP_WARN, msg, None
133
+ if args.voicevox_os is None:
134
+ msg = dict(warn=f"Please specify the --voicevox_os option.")
135
+ common.print_format(msg, False, tm, args.output_json, args.output_json_append, pf=pf)
136
+ return self.RESP_WARN, msg, None
137
+ if args.voicevox_arc is None:
138
+ msg = dict(warn=f"Please specify the --voicevox_arc option.")
139
+ common.print_format(msg, False, tm, args.output_json, args.output_json_append, pf=pf)
140
+ return self.RESP_WARN, msg, None
141
+ if args.voicevox_device is None:
142
+ msg = dict(warn=f"Please specify the --voicevox_device option.")
143
+ common.print_format(msg, False, tm, args.output_json, args.output_json_append, pf=pf)
144
+ return self.RESP_WARN, msg, None
145
+ if args.voicevox_whl is None:
146
+ msg = dict(warn=f"Please specify the --voicevox_whl option.")
147
+ common.print_format(msg, False, tm, args.output_json, args.output_json_append, pf=pf)
148
+ return self.RESP_WARN, msg, None
149
+
150
+ tts_engine = args.tts_engine
151
+ voicevox_ver = args.voicevox_ver if args.voicevox_ver is not None else '-'
152
+ voicevox_os = args.voicevox_os if args.voicevox_os is not None else '-'
153
+ voicevox_arc = args.voicevox_arc if args.voicevox_arc is not None else '-'
154
+ voicevox_device = args.voicevox_device if args.voicevox_device is not None else '-'
155
+ voicevox_whl = args.voicevox_whl if args.voicevox_whl is not None else '-'
156
+
157
+ if args.client_only:
158
+ # クライアントのみの場合は、サーバーに接続せずに実行
159
+ ret = self.install(common.random_string(), tts_engine, voicevox_ver, voicevox_os, voicevox_arc,
160
+ voicevox_device, voicevox_whl, logger)
161
+ else:
162
+ tts_engine_b64 = convert.str2b64str(tts_engine)
163
+ voicevox_ver_b64 = convert.str2b64str(voicevox_ver)
164
+ voicevox_os_b64 = convert.str2b64str(voicevox_os)
165
+ voicevox_arc_b64 = convert.str2b64str(voicevox_arc)
166
+ voicevox_device_b64 = convert.str2b64str(voicevox_device)
167
+ voicevox_whl_b64 = convert.str2b64str(voicevox_whl)
168
+ cl = client.Client(logger, redis_host=args.host, redis_port=args.port, redis_password=args.password, svname=args.svname)
169
+ ret = cl.redis_cli.send_cmd(self.get_svcmd(),
170
+ [tts_engine_b64, voicevox_ver_b64, voicevox_os_b64, voicevox_arc_b64, voicevox_device_b64, voicevox_whl_b64],
171
+ retry_count=args.retry_count, retry_interval=args.retry_interval, timeout=args.timeout, nowait=False)
172
+ common.print_format(ret, False, tm, None, False, pf=pf)
173
+ if 'success' not in ret:
174
+ return self.RESP_WARN, ret, None
175
+ return self.RESP_SUCCESS, ret, None
176
+
177
+ def is_cluster_redirect(self):
178
+ """
179
+ クラスター宛のメッセージの場合、メッセージを転送するかどうかを返します
180
+
181
+ Returns:
182
+ bool: メッセージを転送する場合はTrue
183
+ """
184
+ return False
185
+
186
+ def svrun(self, data_dir:Path, logger:logging.Logger, redis_cli:redis_client.RedisClient, msg:List[str],
187
+ sessions:Dict[str, Dict[str, Any]]) -> int:
188
+ """
189
+ この機能のサーバー側の実行を行います
190
+
191
+ Args:
192
+ data_dir (Path): データディレクトリ
193
+ logger (logging.Logger): ロガー
194
+ redis_cli (redis_client.RedisClient): Redisクライアント
195
+ msg (List[str]): 受信メッセージ
196
+ sessions (Dict[str, Dict[str, Any]]): セッション情報
197
+
198
+ Returns:
199
+ int: 終了コード
200
+ """
201
+ if logger.level == logging.DEBUG:
202
+ logger.debug(f"audit write svrun msg: {msg}")
203
+ tts_engine = convert.b64str2str(msg[2])
204
+ voicevox_ver = convert.b64str2str(msg[3])
205
+ voicevox_os = convert.b64str2str(msg[4])
206
+ voicevox_arc = convert.b64str2str(msg[5])
207
+ voicevox_device = convert.b64str2str(msg[6])
208
+ voicevox_whl = convert.b64str2str(msg[7])
209
+ ret = self.install(msg[1], tts_engine, voicevox_ver, voicevox_os, voicevox_arc, voicevox_device, voicevox_whl, logger)
210
+
211
+ if 'success' not in ret:
212
+ redis_cli.rpush(msg[1], ret)
213
+ return self.RESP_WARN
214
+ return self.RESP_SUCCESS
215
+
216
+ def install(self, reskey:str, tts_engine:str, voicevox_ver:str, voicevox_os:str, voicevox_arc:str,
217
+ voicevox_device:str, voicevox_whl:str, logger:logging.Logger) -> Dict[str, Any]:
218
+ """
219
+ TTSエンジンをインストールします
220
+
221
+ Args:
222
+ reskey (str): レスポンスキー
223
+ tts_engine (str): TTSエンジン
224
+ voicevox_ver (str): VoiceVoxバージョン
225
+ voicevox_os (str): VoiceVox OS
226
+ voicevox_arc (str): VoiceVox アーキテクチャ
227
+ voicevox_device (str): VoiceVox デバイス
228
+ voicevox_whl (str): VoiceVox ホイールファイル
229
+ logger (logging.Logger): ロガー
230
+
231
+ Returns:
232
+ Dict[str, Any]: 結果
233
+ """
234
+ try:
235
+ if tts_engine == 'voicevox':
236
+ #===============================================================
237
+ # voicevoxのダウンローダーのダウンロード
238
+ if voicevox_os == 'windows':
239
+ dlfile = f"download-{voicevox_os}-{voicevox_arc}.exe"
240
+ else:
241
+ dlfile = f"download-{voicevox_os}-{voicevox_arc}"
242
+ downloader_url = f"https://github.com/VOICEVOX/voicevox_core/releases/download/{voicevox_ver}/{dlfile}"
243
+ voicevox_dir = Path(version.__file__).parent / '.voicevox' / 'voicevox_core'
244
+ # すでにダウンローダーが存在する場合は削除
245
+ if voicevox_dir.exists():
246
+ shutil.rmtree(voicevox_dir)
247
+ voicevox_dir.mkdir(parents=True, exist_ok=True)
248
+ dlfile = voicevox_dir / dlfile
249
+ # ダウンローダーを保存
250
+ if logger.level == logging.DEBUG:
251
+ logger.debug(f"Downloading.. : {downloader_url}")
252
+ responce = requests.get(downloader_url, allow_redirects=True)
253
+ if responce.status_code != 200:
254
+ _msg = f"Failed to download VoiceVox core: {responce.status_code} {responce.reason}. {downloader_url}"
255
+ logger.error(_msg, exc_info=True)
256
+ return dict(warn=_msg)
257
+ with open(dlfile, mode='wb') as f:
258
+ f.write(responce.content)
259
+ # ダウンローダーの実行権限を付与
260
+ if voicevox_os != 'windows':
261
+ dlfile.chmod(dlfile.stat().st_mode | 0o111)
262
+ #===============================================================
263
+ # ダウンローダーを実行してVoiceVox coreをダウンロード
264
+ cmd_line = [str(dlfile), '-o', '.', '--exclude', 'c-api']
265
+ if voicevox_device == 'directml':
266
+ cmd_line.extend(['--devices', 'directml'])
267
+ elif voicevox_device == 'cuda':
268
+ cmd_line.extend(['--devices', 'cuda'])
269
+ if logger.level == logging.DEBUG:
270
+ logger.debug(f"EXEC - {cmd_line}")
271
+ proc = subprocess.Popen(cmd_line, cwd=str(voicevox_dir), stdout=subprocess.PIPE, stdin=subprocess.PIPE, shell=True)
272
+ outs, errs = proc.communicate(input=b'y\ny\n') # 'y' to confirm installation
273
+ if proc.returncode != 0:
274
+ _msg = outs.decode('utf-8') if outs else ''
275
+ _msg += errs.decode('utf-8') if errs else _msg
276
+ _msg += f"Failed to install VoiceVox core: {_msg}"
277
+ logger.error(_msg, exc_info=True)
278
+ return dict(warn=_msg)
279
+ if logger.level == logging.DEBUG:
280
+ logger.debug(f"Completed - {cmd_line}")
281
+ if (voicevox_dir / 'voicevox_core').exists():
282
+ for file in glob.glob(str(voicevox_dir / 'voicevox_core' / '*')):
283
+ shutil.move(file, voicevox_dir)
284
+ shutil.rmtree(voicevox_dir / 'voicevox_core')
285
+ logger.info(outs.decode('utf-8'))
286
+ logger.info(f"VoiceVox core download successfully. {dlfile}")
287
+ #===============================================================
288
+ # voicevoxのpythonライブラリのインストール
289
+ whl_url = f'https://github.com/VOICEVOX/voicevox_core/releases/download/{voicevox_ver}/{voicevox_whl}'
290
+ voicevox_whl = voicevox_dir / voicevox_whl
291
+ # whlファイルをダウンロード
292
+ if logger.level == logging.DEBUG:
293
+ logger.debug(f"Downloading.. : {whl_url}")
294
+ responce = requests.get(whl_url, allow_redirects=True)
295
+ if responce.status_code != 200:
296
+ _msg = f"Failed to download VoiceVox whl: {responce.status_code} {responce.reason}. {whl_url}"
297
+ logger.error(_msg, exc_info=True)
298
+ return dict(warn=_msg)
299
+ with open(voicevox_whl, mode='wb') as f:
300
+ f.write(responce.content)
301
+ # whlファイルをpipでインストール
302
+ if logger.level == logging.DEBUG:
303
+ logger.debug(f"pip install {voicevox_whl}")
304
+ rescode = pip.main(['install', str(voicevox_whl)]) # pipのインストール
305
+ logger.info(f"Install wheel: {voicevox_whl}")
306
+ if rescode != 0:
307
+ _msg = f"Failed to install VoiceVox python library: Possible whl not in the environment. {voicevox_whl}. {whl_url}"
308
+ logger.error(_msg, exc_info=True)
309
+ return dict(warn=_msg)
310
+ #===============================================================
311
+ # 成功時の処理
312
+ rescode, _msg = (self.RESP_SUCCESS, dict(success=f'Success to install VoiceVox python library. {whl_url}'))
313
+ return dict(success=_msg)
314
+ except Exception as e:
315
+ _msg = f"Failed to install VoiceVox: {e}"
316
+ logger.warning(_msg, exc_info=True)
317
+ return dict(warn=_msg)