|
|
|
@@ -167,7 +167,7 @@ func CreateSafetyTask(req TaskReq, jsonstr string) (string, error) { |
|
|
|
return "", nil |
|
|
|
} |
|
|
|
|
|
|
|
func GetAlgorithmList() error { |
|
|
|
func GetAlgorithmList() (map[string]interface{}, error) { |
|
|
|
checkSetting() |
|
|
|
client := getRestyClient() |
|
|
|
params := make(map[string]interface{}) |
|
|
|
@@ -192,13 +192,20 @@ func GetAlgorithmList() error { |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
log.Info("error =" + err.Error()) |
|
|
|
return fmt.Errorf("resty GetJob: %v", err) |
|
|
|
return nil, fmt.Errorf("resty GetJob: %v", err) |
|
|
|
} else { |
|
|
|
reMap := make(map[string]interface{}) |
|
|
|
err = json.Unmarshal(res.Body(), &reMap) |
|
|
|
if err == nil && reMap["code"] == "0" { |
|
|
|
return reMap, nil |
|
|
|
} else { |
|
|
|
return nil, fmt.Errorf("get error,code not 0") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func GetTaskStatus(jobID string) error { |
|
|
|
func GetTaskStatus(jobID string) (map[string]interface{}, error) { |
|
|
|
checkSetting() |
|
|
|
client := getRestyClient() |
|
|
|
var taskResult string |
|
|
|
@@ -219,8 +226,14 @@ func GetTaskStatus(jobID string) error { |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
log.Info("error =" + err.Error()) |
|
|
|
return fmt.Errorf("resty GetJob: %v", err) |
|
|
|
return nil, fmt.Errorf("resty GetJob: %v", err) |
|
|
|
} else { |
|
|
|
reMap := make(map[string]interface{}) |
|
|
|
err = json.Unmarshal(res.Body(), &reMap) |
|
|
|
if err == nil && reMap["code"] == "0" { |
|
|
|
return reMap, nil |
|
|
|
} else { |
|
|
|
return nil, fmt.Errorf("get error,code not 0") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return nil |
|
|
|
} |