fix: use panel Python common catalog and track install jobs
This commit is contained in:
1 parent
248badd33e
commit
d7c007adc4
12 files changed
+202
-22
No files matched your search
@@ -430,11 +430,9 @@ func (c *Client) pythonInstallations(ctx context.Context) ([]pythonInstallation,
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *Client) pythonLatestAvailableVersions(ctx context.Context) ([]string, error) {
|
||||
// The legacy Python manager list contains the first patch releases of many
|
||||
// branches (for example 3.12.0) and is not updated consistently. aaPanel's
|
||||
// project SDK catalog tracks the current stable patch of each branch even
|
||||
// when its bundled installer cannot fetch that release.
|
||||
func (c *Client) pythonCommonAvailableVersions(ctx context.Context) ([]string, error) {
|
||||
// Match Websites -> Python Project -> Common Versions exactly. The full
|
||||
// archive is not a fallback: it may advertise a different patch or branch.
|
||||
body, err := c.request(ctx, http.MethodPost, "/project/python/list_py_version/stype", nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read latest Python versions: %w", err)
|
||||
@@ -444,7 +442,6 @@ func (c *Client) pythonLatestAvailableVersions(ctx context.Context) ([]string, e
|
||||
Msg string `json:"msg"`
|
||||
SDK struct {
|
||||
Streamline []runtimeSDK `json:"streamline"`
|
||||
All []runtimeSDK `json:"all"`
|
||||
} `json:"sdk"`
|
||||
}
|
||||
if err = json.Unmarshal(body, &response); err != nil {
|
||||
@@ -453,13 +450,13 @@ func (c *Client) pythonLatestAvailableVersions(ctx context.Context) ([]string, e
|
||||
if failed(response.Status) {
|
||||
return nil, fmt.Errorf("read latest Python versions: %s", safeMessage(response.Msg))
|
||||
}
|
||||
versions := make([]string, 0, len(response.SDK.Streamline)+len(response.SDK.All))
|
||||
for _, item := range append(response.SDK.Streamline, response.SDK.All...) {
|
||||
versions := make([]string, 0, len(response.SDK.Streamline))
|
||||
for _, item := range response.SDK.Streamline {
|
||||
versions = append(versions, item.Version)
|
||||
}
|
||||
versions = latestPythonBranchVersions(versions)
|
||||
if len(versions) == 0 {
|
||||
return nil, errors.New("latest Python branch catalog is empty")
|
||||
return nil, errors.New("宝塔 Python 项目的常用版本列表为空,请在面板刷新版本后重试")
|
||||
}
|
||||
return versions, nil
|
||||
}
|
||||
@@ -813,7 +810,7 @@ func (c *Client) RuntimeEnvironments(ctx context.Context) ([]RuntimeEnvironment,
|
||||
items[2].ComponentInstallable = items[2].ComponentUpdateAvailable
|
||||
}
|
||||
installations, installedErr := c.pythonInstallations(ctx)
|
||||
available, availableErr := c.pythonLatestAvailableVersions(ctx)
|
||||
available, availableErr := c.pythonCommonAvailableVersions(ctx)
|
||||
if installedErr != nil || availableErr != nil {
|
||||
items[2].ComponentStatus, items[2].Detail = RuntimeComponentFailed, "Python 版本清单暂不可用"
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user