Ejemplo n.º 1
0
//Get job result
func (this *JobController) GetJobResult() {
	jid := this.GetString("jobid")

	resultPath := path.Join(config.GetSharePath(), jid)
	ex, err := comm.FileExists(resultPath)
	if !ex || err != nil {
		log.Println(err)
		return
	}

	zipPath := path.Join(config.GetSharePath(), jid+".zip")
	ex, err = comm.FileExists(zipPath)
	if err != nil {
		log.Println(err)
		return
	}
	if !ex {
		err := comm.Zipit(resultPath, zipPath)
		if err != nil {
			log.Println(err)
			return
		}
	}
	name := jid + ".zip"
	this.Ctx.Output.Download(zipPath, name)
}
Ejemplo n.º 2
0
func (m *DeviceManager) updateDevInfo() {
	adb := path.Join(getAndroidSDKPath(), framework.ADB_PATH)
	comm.ExeCmd(GET_DEVICE_CMD + " " + adb)

	exist, err := comm.FileExists("dinfo.json")
	if !exist {
		log.Println("dinfo.json not exist!", err)
		return
	}

	//read info from this json
	content, err := ioutil.ReadFile("dinfo.json")
	if err != nil {
		log.Println("dinfo.json not exist!", err)
		return
	}

	//struct this json
	var dvinfos comp.DeviceInfoSlice
	err = json.Unmarshal(content, &dvinfos)
	if err != nil {
		log.Println(err)
		return
	}

	log.Println("Devices num: ", len(dvinfos.DeviceInfos))

	//get update devices map
	newMap := make(map[string]comp.Device)
	for _, dvinfo := range dvinfos.DeviceInfos {
		var dev comp.Device
		dev.State = comp.DEVICE_FREE
		dev.Info = dvinfo
		newMap[dvinfo.Id] = dev
		//fmt.Println(dvinfo)
	}

	m.deviceLock.Lock()
	defer m.deviceLock.Unlock()

	for id, ndev := range newMap {
		dev, ok := m.deviceMap[id]
		//old device
		if ok {
			newMap[id] = dev
		} else {
			//new device
			go startMinicap(id, ndev.Info.Resolution)
		}
	}
	for id, _ := range m.deviceMap {
		_, ok := newMap[id]
		if !ok {
			//miss device
			stopMinicap(id)
		}
	}
	m.deviceMap = newMap
}
Ejemplo n.º 3
0
func createLocalFile(ts comp.RunTask) error {
	//create local file
	ex, err := comm.FileExists(ts.TaskInfo.JobId)
	if err != nil {
		return err
	}

	if !ex {
		//create local file
		err = os.Mkdir(ts.TaskInfo.JobId, os.ModePerm)
		if err != nil {
			return err
		}
		//make test locally
		ts.Frame = ts.Frame.MoveTestFile(ts.TaskInfo.JobId)
	}

	return nil
}