You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
949 B
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package monkey
import (
"goqs/models"
"os/exec"
"time"
log "github.com/sirupsen/logrus"
"github.com/spf13/cast"
)
func runAndroidMonkeyCmd(task models.MonkeyTask) {
pkg_path := "/home/tmp/pkg/" + cast.ToString(time.Now().Unix()) + ".apk"
log.Debug("正在下载apk", task.PackageURL)
err := exec.Command("wget", task.PackageURL, "-O", pkg_path).Run()
if err != nil {
log.Error(err)
}
log.Debug("下载完毕开始调用monkey服务安装包路径", pkg_path)
cmd_content := "cd /home/app/aimonkey && python3 main_run.py" +
" -task_id " + cast.ToString(task.Id) +
" -pkg_path " + pkg_path +
" -package " + task.PackageName +
" -activity " + task.LaunchActivity +
" -count " + cast.ToString(task.DeviceAmount) +
" -time " + cast.ToString(task.RunTime)
log.Debug(cmd_content)
cmd := exec.Command("bash", "-c", cmd_content)
err = cmd.Run()
if err != nil {
log.Error(err)
}
}