fix: hide cmhub curl download window
This commit is contained in:
@@ -1452,6 +1452,21 @@ def _find_system_curl():
|
||||
return ""
|
||||
|
||||
|
||||
def _subprocess_hidden_window_kwargs():
|
||||
if os.name != "nt":
|
||||
return {}
|
||||
creationflags = getattr(subprocess, "CREATE_NO_WINDOW", 0)
|
||||
if creationflags:
|
||||
return {"creationflags": creationflags}
|
||||
startupinfo_cls = getattr(subprocess, "STARTUPINFO", None)
|
||||
if startupinfo_cls is None:
|
||||
return {}
|
||||
startupinfo = startupinfo_cls()
|
||||
startupinfo.dwFlags |= getattr(subprocess, "STARTF_USESHOWWINDOW", 1)
|
||||
startupinfo.wShowWindow = getattr(subprocess, "SW_HIDE", 0)
|
||||
return {"startupinfo": startupinfo}
|
||||
|
||||
|
||||
def _download_cmhub_image_with_curl(
|
||||
url,
|
||||
connect_timeout,
|
||||
@@ -1501,6 +1516,7 @@ def _download_cmhub_image_with_curl(
|
||||
timeout=max(2, int(connect_timeout) + int(read_timeout) + 10),
|
||||
check=False,
|
||||
shell=False,
|
||||
**_subprocess_hidden_window_kwargs(),
|
||||
)
|
||||
except (OSError, subprocess.TimeoutExpired) as exc:
|
||||
raise AIError("下载 cmhub 图片失败: curl 执行失败") from exc
|
||||
|
||||
Reference in New Issue
Block a user