improve error messages
This commit is contained in:
parent
21c3009945
commit
d99488f22f
@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -51,6 +52,10 @@ func (a *App) InstallPyDep(python string, cnMirror bool) (string, error) {
|
|||||||
if python == "" {
|
if python == "" {
|
||||||
python, err = GetPython()
|
python, err = GetPython()
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
|
python, err = filepath.Abs(python)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
python = `"` + python + `"`
|
python = `"` + python + `"`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,19 +115,11 @@ func GetPython() (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.New("failed to unzip python")
|
return "", errors.New("failed to unzip python")
|
||||||
} else {
|
} else {
|
||||||
python, err := filepath.Abs("py310/python.exe")
|
return "py310/python.exe", nil
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return python, nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
python, err := filepath.Abs("py310/python.exe")
|
return "py310/python.exe", nil
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return python, nil
|
|
||||||
}
|
}
|
||||||
case "darwin":
|
case "darwin":
|
||||||
return "python3", nil
|
return "python3", nil
|
||||||
|
@ -136,7 +136,7 @@
|
|||||||
"Custom Python Path": "自定义Python路径",
|
"Custom Python Path": "自定义Python路径",
|
||||||
"Custom Models Path": "自定义模型路径",
|
"Custom Models Path": "自定义模型路径",
|
||||||
"Microsoft Visual C++ Redistributable is not installed, would you like to download it?": "微软VC++组件未安装, 是否下载?",
|
"Microsoft Visual C++ Redistributable is not installed, would you like to download it?": "微软VC++组件未安装, 是否下载?",
|
||||||
"Path Cannot Contain Space": "路径不能包含空格",
|
"File Path Cannot Contain Space": "文件路径不能包含空格",
|
||||||
"Failed to switch model, please try starting the program with administrator privileges or increasing your virtual memory.": "切换模型失败, 请尝试以管理员权限启动程序, 或增加你的虚拟内存",
|
"Failed to switch model, please try starting the program with administrator privileges or increasing your virtual memory.": "切换模型失败, 请尝试以管理员权限启动程序, 或增加你的虚拟内存",
|
||||||
"Current Strategy": "当前Strategy",
|
"Current Strategy": "当前Strategy",
|
||||||
"MacOS is not yet supported for performing this operation, please do it manually.": "MacOS尚未支持此操作, 请手动执行",
|
"MacOS is not yet supported for performing this operation, please do it manually.": "MacOS尚未支持此操作, 请手动执行",
|
||||||
@ -144,5 +144,6 @@
|
|||||||
"On Linux system, you must manually install python dependencies.": "在Linux系统下, 你必须手动安装python依赖",
|
"On Linux system, you must manually install python dependencies.": "在Linux系统下, 你必须手动安装python依赖",
|
||||||
"Update completed, please restart the program.": "更新完成, 请重启程序",
|
"Update completed, please restart the program.": "更新完成, 请重启程序",
|
||||||
"Are you sure you want to reset this page? It cannot be undone.": "你确定要重置本页吗?这无法撤销",
|
"Are you sure you want to reset this page? It cannot be undone.": "你确定要重置本页吗?这无法撤销",
|
||||||
"Model file download is not complete": "模型文件下载未完成"
|
"Model file download is not complete": "模型文件下载未完成",
|
||||||
|
"Error": "错误"
|
||||||
}
|
}
|
@ -78,8 +78,13 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
toast(depErrorMsg, { type: 'info', position: 'bottom-left' });
|
toast(depErrorMsg, { type: 'info', position: 'bottom-left' });
|
||||||
if (commonStore.platform != 'linux')
|
if (commonStore.platform != 'linux')
|
||||||
toastWithButton(t('Python dependencies are incomplete, would you like to install them?'), t('Install'), () => {
|
toastWithButton(t('Python dependencies are incomplete, would you like to install them?'), t('Install'), () => {
|
||||||
InstallPyDep(commonStore.settings.customPythonPath, commonStore.settings.cnMirror);
|
InstallPyDep(commonStore.settings.customPythonPath, commonStore.settings.cnMirror).catch((e) => {
|
||||||
|
const errMsg = e.message || e;
|
||||||
|
toast(t('Error') + ' - ' + errMsg, { type: 'error' });
|
||||||
|
});
|
||||||
setTimeout(WindowShow, 1000);
|
setTimeout(WindowShow, 1000);
|
||||||
|
}, {
|
||||||
|
autoClose: 8000
|
||||||
});
|
});
|
||||||
else
|
else
|
||||||
toastWithButton(t('On Linux system, you must manually install python dependencies.'), t('Check'), () => {
|
toastWithButton(t('On Linux system, you must manually install python dependencies.'), t('Check'), () => {
|
||||||
@ -131,7 +136,13 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
|||||||
|
|
||||||
await exit(1000).catch(() => {
|
await exit(1000).catch(() => {
|
||||||
});
|
});
|
||||||
StartServer(commonStore.settings.customPythonPath, port, commonStore.settings.host !== '127.0.0.1' ? '0.0.0.0' : '127.0.0.1');
|
StartServer(commonStore.settings.customPythonPath, port, commonStore.settings.host !== '127.0.0.1' ? '0.0.0.0' : '127.0.0.1').catch((e) => {
|
||||||
|
const errMsg = e.message || e;
|
||||||
|
if (errMsg.includes('path contains space'))
|
||||||
|
toast(`${t('Error')} - ${t('File Path Cannot Contain Space')}`, { type: 'error' });
|
||||||
|
else
|
||||||
|
toast(t('Error') + ' - ' + errMsg, { type: 'error' });
|
||||||
|
});
|
||||||
setTimeout(WindowShow, 1000);
|
setTimeout(WindowShow, 1000);
|
||||||
|
|
||||||
let timeoutCount = 6;
|
let timeoutCount = 6;
|
||||||
|
@ -259,7 +259,7 @@ export const Configs: FC = observer(() => {
|
|||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
const errMsg = e.message || e;
|
const errMsg = e.message || e;
|
||||||
if (errMsg.includes('path contains space'))
|
if (errMsg.includes('path contains space'))
|
||||||
toast(`${t('Convert Failed')} - ${t('Path Cannot Contain Space')}`, { type: 'error' });
|
toast(`${t('Convert Failed')} - ${t('File Path Cannot Contain Space')}`, { type: 'error' });
|
||||||
else
|
else
|
||||||
toast(`${t('Convert Failed')} - ${e.message || e}`, { type: 'error' });
|
toast(`${t('Convert Failed')} - ${e.message || e}`, { type: 'error' });
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user