openbench-cli 0.0.5__py3-none-win_amd64.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.
- ds_cli_bin/__init__.py +326 -0
- ds_cli_bin/bin/_internal/VCRUNTIME140.dll +0 -0
- ds_cli_bin/bin/_internal/_asyncio.pyd +0 -0
- ds_cli_bin/bin/_internal/_bz2.pyd +0 -0
- ds_cli_bin/bin/_internal/_ctypes.pyd +0 -0
- ds_cli_bin/bin/_internal/_decimal.pyd +0 -0
- ds_cli_bin/bin/_internal/_hashlib.pyd +0 -0
- ds_cli_bin/bin/_internal/_lzma.pyd +0 -0
- ds_cli_bin/bin/_internal/_multiprocessing.pyd +0 -0
- ds_cli_bin/bin/_internal/_overlapped.pyd +0 -0
- ds_cli_bin/bin/_internal/_queue.pyd +0 -0
- ds_cli_bin/bin/_internal/_socket.pyd +0 -0
- ds_cli_bin/bin/_internal/_ssl.pyd +0 -0
- ds_cli_bin/bin/_internal/_uuid.pyd +0 -0
- ds_cli_bin/bin/_internal/_zoneinfo.pyd +0 -0
- ds_cli_bin/bin/_internal/ada92cb5d92a588d1b93__mypyc.cp310-win_amd64.pyd +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-console-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-datetime-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-debug-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-errorhandling-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-fibers-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-fibers-l1-1-1.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-file-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-file-l1-2-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-file-l2-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-handle-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-heap-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-interlocked-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-kernel32-legacy-l1-1-1.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-libraryloader-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-localization-l1-2-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-memory-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-namedpipe-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-processenvironment-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-processthreads-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-processthreads-l1-1-1.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-profile-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-rtlsupport-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-string-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-synch-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-synch-l1-2-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-sysinfo-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-sysinfo-l1-2-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-timezone-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-core-util-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-crt-conio-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-crt-convert-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-crt-environment-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-crt-filesystem-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-crt-heap-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-crt-locale-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-crt-math-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-crt-process-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-crt-runtime-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-crt-stdio-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-crt-string-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-crt-time-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/api-ms-win-crt-utility-l1-1-0.dll +0 -0
- ds_cli_bin/bin/_internal/attrs-26.1.0.dist-info/INSTALLER +1 -0
- ds_cli_bin/bin/_internal/attrs-26.1.0.dist-info/METADATA +199 -0
- ds_cli_bin/bin/_internal/attrs-26.1.0.dist-info/RECORD +55 -0
- ds_cli_bin/bin/_internal/attrs-26.1.0.dist-info/WHEEL +4 -0
- ds_cli_bin/bin/_internal/attrs-26.1.0.dist-info/licenses/LICENSE +21 -0
- ds_cli_bin/bin/_internal/base_library.zip +0 -0
- ds_cli_bin/bin/_internal/certifi/cacert.pem +3959 -0
- ds_cli_bin/bin/_internal/certifi/py.typed +0 -0
- ds_cli_bin/bin/_internal/charset_normalizer/cd.cp310-win_amd64.pyd +0 -0
- ds_cli_bin/bin/_internal/charset_normalizer/md.cp310-win_amd64.pyd +0 -0
- ds_cli_bin/bin/_internal/ffi-8.dll +0 -0
- ds_cli_bin/bin/_internal/jsonschema/benchmarks/issue232/issue.json +2653 -0
- ds_cli_bin/bin/_internal/jsonschema-4.26.0.dist-info/INSTALLER +1 -0
- ds_cli_bin/bin/_internal/jsonschema-4.26.0.dist-info/METADATA +170 -0
- ds_cli_bin/bin/_internal/jsonschema-4.26.0.dist-info/RECORD +83 -0
- ds_cli_bin/bin/_internal/jsonschema-4.26.0.dist-info/REQUESTED +0 -0
- ds_cli_bin/bin/_internal/jsonschema-4.26.0.dist-info/WHEEL +4 -0
- ds_cli_bin/bin/_internal/jsonschema-4.26.0.dist-info/entry_points.txt +2 -0
- ds_cli_bin/bin/_internal/jsonschema-4.26.0.dist-info/licenses/COPYING +19 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft201909/metaschema.json +42 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft201909/vocabularies/applicator +56 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft201909/vocabularies/content +17 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft201909/vocabularies/core +57 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft201909/vocabularies/format +14 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft201909/vocabularies/meta-data +37 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft201909/vocabularies/validation +98 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/metaschema.json +58 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/vocabularies/applicator +48 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/vocabularies/content +17 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/vocabularies/core +51 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/vocabularies/format-annotation +14 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/vocabularies/format-assertion +14 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/vocabularies/meta-data +37 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/vocabularies/unevaluated +15 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/vocabularies/validation +98 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft3/metaschema.json +172 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft4/metaschema.json +149 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft6/metaschema.json +153 -0
- ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft7/metaschema.json +166 -0
- ds_cli_bin/bin/_internal/libbz2.dll +0 -0
- ds_cli_bin/bin/_internal/libcrypto-3-x64.dll +0 -0
- ds_cli_bin/bin/_internal/libexpat.dll +0 -0
- ds_cli_bin/bin/_internal/liblzma.dll +0 -0
- ds_cli_bin/bin/_internal/libssl-3-x64.dll +0 -0
- ds_cli_bin/bin/_internal/orjson/orjson.cp310-win_amd64.pyd +0 -0
- ds_cli_bin/bin/_internal/psutil/_psutil_windows.pyd +0 -0
- ds_cli_bin/bin/_internal/pyexpat.pyd +0 -0
- ds_cli_bin/bin/_internal/python3.dll +0 -0
- ds_cli_bin/bin/_internal/python310.dll +0 -0
- ds_cli_bin/bin/_internal/rpds/rpds.cp310-win_amd64.pyd +0 -0
- ds_cli_bin/bin/_internal/select.pyd +0 -0
- ds_cli_bin/bin/_internal/ucrtbase.dll +0 -0
- ds_cli_bin/bin/_internal/unicodedata.pyd +0 -0
- ds_cli_bin/bin/_internal/yaml/_yaml.cp310-win_amd64.pyd +0 -0
- ds_cli_bin/bin/_internal/zlib.dll +0 -0
- ds_cli_bin/bin/ob.exe +0 -0
- ds_cli_bin/release_config.py +5 -0
- openbench_cli-0.0.5.dist-info/METADATA +45 -0
- openbench_cli-0.0.5.dist-info/RECORD +120 -0
- openbench_cli-0.0.5.dist-info/WHEEL +5 -0
- openbench_cli-0.0.5.dist-info/entry_points.txt +2 -0
- openbench_cli-0.0.5.dist-info/top_level.txt +1 -0
ds_cli_bin/__init__.py
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import shlex
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
import time
|
|
7
|
+
from importlib.metadata import version
|
|
8
|
+
from importlib.resources import files
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from urllib.request import urlopen
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
PACKAGE_NAME = "openbench-cli"
|
|
14
|
+
DEFAULT_CHECK_INTERVAL_SECONDS = 0
|
|
15
|
+
try:
|
|
16
|
+
from .release_config import DEFAULT_PIP_INDEX_ARGS, DEFAULT_PYPI_JSON_URL
|
|
17
|
+
except Exception:
|
|
18
|
+
DEFAULT_PYPI_JSON_URL = f"https://pypi.org/pypi/{PACKAGE_NAME}/json"
|
|
19
|
+
DEFAULT_PIP_INDEX_ARGS = [
|
|
20
|
+
"-i",
|
|
21
|
+
"https://pypi.org/simple",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _cache_path():
|
|
26
|
+
cache_name = os.getenv("DS_CLI_UPDATE_CACHE", "update-check.json")
|
|
27
|
+
return Path.home() / ".ob" / cache_name
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _pypi_json_url():
|
|
31
|
+
return os.getenv("DS_CLI_UPDATE_JSON_URL", DEFAULT_PYPI_JSON_URL)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _pip_index_args():
|
|
35
|
+
override = os.getenv("DS_CLI_PIP_INDEX_ARGS")
|
|
36
|
+
if override:
|
|
37
|
+
return override.split()
|
|
38
|
+
return list(DEFAULT_PIP_INDEX_ARGS)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _check_interval_seconds():
|
|
42
|
+
try:
|
|
43
|
+
return max(0, int(os.getenv("DS_CLI_UPDATE_CACHE_SECONDS", DEFAULT_CHECK_INTERVAL_SECONDS)))
|
|
44
|
+
except ValueError:
|
|
45
|
+
return DEFAULT_CHECK_INTERVAL_SECONDS
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _load_cached_latest():
|
|
49
|
+
path = _cache_path()
|
|
50
|
+
if not path.exists():
|
|
51
|
+
return None
|
|
52
|
+
|
|
53
|
+
try:
|
|
54
|
+
data = json.loads(path.read_text(encoding="utf-8"))
|
|
55
|
+
checked_at = data.get("checked_at", 0)
|
|
56
|
+
if time.time() - checked_at > _check_interval_seconds():
|
|
57
|
+
return None
|
|
58
|
+
return data.get("latest")
|
|
59
|
+
except Exception:
|
|
60
|
+
return None
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _save_cached_latest(latest):
|
|
64
|
+
path = _cache_path()
|
|
65
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
66
|
+
path.write_text(
|
|
67
|
+
json.dumps({"checked_at": time.time(), "latest": latest}),
|
|
68
|
+
encoding="utf-8",
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _fetch_latest_version(version_cls):
|
|
73
|
+
with urlopen(_pypi_json_url(), timeout=2) as response:
|
|
74
|
+
data = json.loads(response.read().decode("utf-8"))
|
|
75
|
+
|
|
76
|
+
versions = []
|
|
77
|
+
for raw_version, files_info in data.get("releases", {}).items():
|
|
78
|
+
parsed = version_cls(raw_version)
|
|
79
|
+
if parsed.is_prerelease:
|
|
80
|
+
continue
|
|
81
|
+
if files_info and all(item.get("yanked", False) for item in files_info):
|
|
82
|
+
continue
|
|
83
|
+
versions.append(parsed)
|
|
84
|
+
|
|
85
|
+
if not versions:
|
|
86
|
+
return None
|
|
87
|
+
|
|
88
|
+
return str(max(versions))
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _upgrade_command():
|
|
92
|
+
base = [_python_executable(), "-m", "pip", "install", "-U"]
|
|
93
|
+
base.extend(_pip_index_args())
|
|
94
|
+
base.append(PACKAGE_NAME)
|
|
95
|
+
return base
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _python_executable():
|
|
99
|
+
executable = Path(sys.executable)
|
|
100
|
+
if os.name == "nt" and executable.name.lower() == "ob.exe":
|
|
101
|
+
candidate = Path(sys.prefix) / "Scripts" / "python.exe"
|
|
102
|
+
if candidate.exists():
|
|
103
|
+
return str(candidate)
|
|
104
|
+
return sys.executable
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _format_command(args):
|
|
108
|
+
if os.name == "nt":
|
|
109
|
+
return subprocess.list2cmdline(args)
|
|
110
|
+
return " ".join(shlex.quote(arg) for arg in args)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _run_upgrade_after_exit(command):
|
|
114
|
+
updater_path = Path.home() / ".ob" / f"self-update-{os.getpid()}.py"
|
|
115
|
+
updater_path.parent.mkdir(parents=True, exist_ok=True)
|
|
116
|
+
updater_path.write_text(
|
|
117
|
+
"""
|
|
118
|
+
import ctypes
|
|
119
|
+
import json
|
|
120
|
+
import os
|
|
121
|
+
import subprocess
|
|
122
|
+
import sys
|
|
123
|
+
import time
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def wait_for_parent(pid, timeout_seconds=60):
|
|
127
|
+
if os.name == "nt":
|
|
128
|
+
handle = ctypes.windll.kernel32.OpenProcess(0x00100000, False, pid)
|
|
129
|
+
if handle:
|
|
130
|
+
try:
|
|
131
|
+
ctypes.windll.kernel32.WaitForSingleObject(handle, int(timeout_seconds * 1000))
|
|
132
|
+
finally:
|
|
133
|
+
ctypes.windll.kernel32.CloseHandle(handle)
|
|
134
|
+
return
|
|
135
|
+
|
|
136
|
+
deadline = time.time() + timeout_seconds
|
|
137
|
+
while time.time() < deadline:
|
|
138
|
+
try:
|
|
139
|
+
os.kill(pid, 0)
|
|
140
|
+
except OSError:
|
|
141
|
+
return
|
|
142
|
+
time.sleep(0.2)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def format_command(command):
|
|
146
|
+
if os.name == "nt":
|
|
147
|
+
return subprocess.list2cmdline(command)
|
|
148
|
+
return " ".join(command)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def restore_prompt():
|
|
152
|
+
if os.name != "nt" or os.getenv("DS_CLI_RESTORE_PROMPT", "1") == "0":
|
|
153
|
+
return
|
|
154
|
+
|
|
155
|
+
try:
|
|
156
|
+
from ctypes import wintypes
|
|
157
|
+
|
|
158
|
+
STD_INPUT_HANDLE = -10
|
|
159
|
+
KEY_EVENT = 0x0001
|
|
160
|
+
VK_RETURN = 0x0D
|
|
161
|
+
|
|
162
|
+
class KEY_EVENT_RECORD(ctypes.Structure):
|
|
163
|
+
_fields_ = [
|
|
164
|
+
("bKeyDown", wintypes.BOOL),
|
|
165
|
+
("wRepeatCount", wintypes.WORD),
|
|
166
|
+
("wVirtualKeyCode", wintypes.WORD),
|
|
167
|
+
("wVirtualScanCode", wintypes.WORD),
|
|
168
|
+
("uChar", wintypes.WCHAR),
|
|
169
|
+
("dwControlKeyState", wintypes.DWORD),
|
|
170
|
+
]
|
|
171
|
+
|
|
172
|
+
class INPUT_RECORD(ctypes.Structure):
|
|
173
|
+
_fields_ = [
|
|
174
|
+
("EventType", wintypes.WORD),
|
|
175
|
+
("KeyEvent", KEY_EVENT_RECORD),
|
|
176
|
+
]
|
|
177
|
+
|
|
178
|
+
records = (INPUT_RECORD * 2)()
|
|
179
|
+
records[0].EventType = KEY_EVENT
|
|
180
|
+
records[0].KeyEvent = KEY_EVENT_RECORD(True, 1, VK_RETURN, 0, "\\r", 0)
|
|
181
|
+
records[1].EventType = KEY_EVENT
|
|
182
|
+
records[1].KeyEvent = KEY_EVENT_RECORD(False, 1, VK_RETURN, 0, "\\r", 0)
|
|
183
|
+
|
|
184
|
+
written = wintypes.DWORD()
|
|
185
|
+
handle = ctypes.windll.kernel32.GetStdHandle(STD_INPUT_HANDLE)
|
|
186
|
+
ctypes.windll.kernel32.WriteConsoleInputW(handle, records, 2, ctypes.byref(written))
|
|
187
|
+
except Exception:
|
|
188
|
+
pass
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def main():
|
|
192
|
+
parent_pid = int(sys.argv[1])
|
|
193
|
+
command = json.loads(sys.argv[2])
|
|
194
|
+
wait_for_parent(parent_pid)
|
|
195
|
+
time.sleep(0.5)
|
|
196
|
+
print("[ob] Running update command:")
|
|
197
|
+
print(" " + format_command(command))
|
|
198
|
+
rc = subprocess.call(command)
|
|
199
|
+
if rc == 0:
|
|
200
|
+
print("[ob] Update completed. Please run your command again.")
|
|
201
|
+
else:
|
|
202
|
+
print("[ob] Update failed. Please run the update command manually.", file=sys.stderr)
|
|
203
|
+
sys.stdout.flush()
|
|
204
|
+
sys.stderr.flush()
|
|
205
|
+
restore_prompt()
|
|
206
|
+
try:
|
|
207
|
+
os.remove(__file__)
|
|
208
|
+
except OSError:
|
|
209
|
+
pass
|
|
210
|
+
return rc
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
if __name__ == "__main__":
|
|
214
|
+
raise SystemExit(main())
|
|
215
|
+
""".lstrip(),
|
|
216
|
+
encoding="utf-8",
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
subprocess.Popen(
|
|
220
|
+
[_python_executable(), str(updater_path), str(os.getpid()), json.dumps(command)],
|
|
221
|
+
close_fds=False,
|
|
222
|
+
)
|
|
223
|
+
print("[ob] 已启动自动升级进程,当前命令将退出。")
|
|
224
|
+
print("[ob] Auto-update has started. The current command will exit.")
|
|
225
|
+
return 2
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def _can_update_in_current_process():
|
|
229
|
+
return os.name != "nt"
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def _run_upgrade():
|
|
233
|
+
command = _upgrade_command()
|
|
234
|
+
print("[ob] 正在升级,请稍候...")
|
|
235
|
+
print("[ob] Updating, please wait...")
|
|
236
|
+
if not _can_update_in_current_process():
|
|
237
|
+
return _run_upgrade_after_exit(command)
|
|
238
|
+
|
|
239
|
+
result = subprocess.run(command)
|
|
240
|
+
if result.returncode == 0:
|
|
241
|
+
print("[ob] 升级完成,请重新执行命令。")
|
|
242
|
+
print("[ob] Update completed. Please run your command again.")
|
|
243
|
+
else:
|
|
244
|
+
print(
|
|
245
|
+
f"[ob] 升级失败,请手动执行:\n"
|
|
246
|
+
f" {_format_command(command)}\n"
|
|
247
|
+
f"[ob] Update failed. Please run manually:\n"
|
|
248
|
+
f" {_format_command(command)}",
|
|
249
|
+
file=sys.stderr,
|
|
250
|
+
)
|
|
251
|
+
return result.returncode or 2
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def _confirm_upgrade():
|
|
255
|
+
if not sys.stdin.isatty():
|
|
256
|
+
return False
|
|
257
|
+
try:
|
|
258
|
+
answer = input("[ob] 是否现在自动升级?输入 y 继续,其他输入退出 / Update now? Enter y to continue: ")
|
|
259
|
+
except (EOFError, KeyboardInterrupt):
|
|
260
|
+
return False
|
|
261
|
+
return answer.strip().lower() == "y"
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def _ensure_latest_version():
|
|
265
|
+
try:
|
|
266
|
+
from packaging.version import Version
|
|
267
|
+
|
|
268
|
+
current = Version(version(PACKAGE_NAME))
|
|
269
|
+
|
|
270
|
+
latest = _load_cached_latest()
|
|
271
|
+
if latest is None:
|
|
272
|
+
latest = _fetch_latest_version(Version)
|
|
273
|
+
if latest:
|
|
274
|
+
_save_cached_latest(latest)
|
|
275
|
+
|
|
276
|
+
if latest and Version(latest) > current:
|
|
277
|
+
command = _upgrade_command()
|
|
278
|
+
print(
|
|
279
|
+
f"[ob] 当前工具版本过低,请升级。\n"
|
|
280
|
+
f"[ob] 当前版本:{current},最新版本:{latest}。\n"
|
|
281
|
+
f"[ob] The current tool version is too old. Please upgrade. "
|
|
282
|
+
f"Current version: {current}; latest version: {latest}.\n"
|
|
283
|
+
f"[ob] 升级命令 / Upgrade command:\n"
|
|
284
|
+
f" {_format_command(command)}",
|
|
285
|
+
file=sys.stderr,
|
|
286
|
+
flush=True,
|
|
287
|
+
)
|
|
288
|
+
if os.getenv("DS_CLI_AUTO_UPDATE") == "1" or _confirm_upgrade():
|
|
289
|
+
return _run_upgrade()
|
|
290
|
+
return 2
|
|
291
|
+
except Exception as exc:
|
|
292
|
+
# 版本校验失败(网络不可达/超时/镜像异常等):不阻断命令,WARN 后继续执行("失败放行")。
|
|
293
|
+
# "版本过旧"(latest > current)分支不受影响,仍走原流程(提示升级 / 拦截)。
|
|
294
|
+
command = _upgrade_command()
|
|
295
|
+
print(
|
|
296
|
+
f"[ob] 未校验到最新版本,已跳过并继续执行(版本校验失败不影响命令运行)。\n"
|
|
297
|
+
f"[ob] Skipping the version check and continuing. Reason: {exc}\n"
|
|
298
|
+
f"[ob] 如需手动升级 / To upgrade manually:\n"
|
|
299
|
+
f" {_format_command(command)}",
|
|
300
|
+
file=sys.stderr,
|
|
301
|
+
flush=True,
|
|
302
|
+
)
|
|
303
|
+
return 0
|
|
304
|
+
|
|
305
|
+
return 0
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
def main():
|
|
309
|
+
# ob -V / ob --version:直接打印已安装包的版本(= PyPI 上的 openbench-cli 版本),
|
|
310
|
+
# 在升级检查之前处理,避免触发"请升级"流程。
|
|
311
|
+
if len(sys.argv) >= 2 and sys.argv[1] in ("-V", "--version"):
|
|
312
|
+
try:
|
|
313
|
+
print(version(PACKAGE_NAME))
|
|
314
|
+
except Exception as exc:
|
|
315
|
+
print(f"[ob] 无法读取版本信息: {exc}", file=sys.stderr)
|
|
316
|
+
return 3
|
|
317
|
+
return 0
|
|
318
|
+
|
|
319
|
+
update_status = _ensure_latest_version()
|
|
320
|
+
if update_status != 0:
|
|
321
|
+
return update_status
|
|
322
|
+
|
|
323
|
+
exe_name = "ob.exe" if sys.platform.startswith("win") else "ob"
|
|
324
|
+
exe = files(__package__).joinpath("bin", exe_name)
|
|
325
|
+
result = subprocess.run([str(exe), *sys.argv[1:]])
|
|
326
|
+
return result.returncode
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pip
|