Bladeren bron

1、将脚本路径写入resource_run.cfg中,使Py脚本能读取。
2、将脚本xml生成文件、图片路径等改到脚本文件所在目录中,服务程序也做相应修改。

scbc.sat2 5 jaren geleden
bovenliggende
commit
93698abdcd
2 gewijzigde bestanden met toevoegingen van 19 en 2 verwijderingen
  1. 5 2
      SATService/SATService/Global.cpp
  2. 14 0
      SATService/SATService/SATExecutor.cpp

+ 5 - 2
SATService/SATService/Global.cpp

@@ -186,7 +186,9 @@ namespace GLOBAL
 			StringCchPrintf(szIniPath, MAX_PATH, _T("%sSATService.ini"), g_szCurModuleDir);
 
 		HANDLE hFile = CreateFile(szIniPath, 0/*GENERIC_READ*/, 0, NULL, OPEN_EXISTING, 0, NULL);
-
+		
+		// resoucre_run.cfg;
+		_stprintf_s(g_szPython27ResourceConfig, _T("%s%s"), g_szPython27Dir, "Lib\\site-packages\\ssat_sdk\\config\\resource_run.cfg");
 		if (ERROR_FILE_NOT_FOUND == GetLastError())
 		{
 			return -1;
@@ -199,6 +201,8 @@ namespace GLOBAL
 			_tcscat_s(g_stSATConfig.szScriptDir, MAX_PATH, "\\");
 			WritePrivateProfileString(_T("SATService"), _T("ScriptDir"), g_stSATConfig.szScriptDir, szIniPath);
 		}
+		// 同时将该目录写入resouce_run.cfg中;
+		WritePrivateProfileString(_T("SATService"), _T("ScriptDir"), g_stSATConfig.szScriptDir, g_szPython27ResourceConfig);
 
 		g_stSATConfig.dwAdbKillTime = GetPrivateProfileInt(_T("SATService"), _T("AdbKillTime"), 9000, szIniPath);
 		g_stSATConfig.dwAdbTimeout = GetPrivateProfileInt(_T("SATService"), _T("AdbTimeout"), 120000, szIniPath);
@@ -226,7 +230,6 @@ namespace GLOBAL
 		GetPrivateProfileString(_T("LinuxDevice"), _T("model"), _T(""), g_stSATConfig.stLinuxDevice.szModel, MAX_PATH, szIniPath);
 
 		// 读取其他目录的配置文件;sat_result_dir
-		_stprintf_s(g_szPython27ResourceConfig, _T("%s%s"), g_szPython27Dir, "Lib\\site-packages\\ssat_sdk\\config\\resource_run.cfg");
 		GetPrivateProfileString(_T("COMM"), _T("serial_communicator_port"), _T(""), g_stSATConfig.szTVPort, MAX_PATH, g_szPython27ResourceConfig);
 		GetPrivateProfileString(_T("Abnormal"), _T("reboot"), NULL, g_stSATConfig.szTVReboot, MAX_PATH, g_szPython27ResourceConfig);
 		GetPrivateProfileString(_T("Abnormal"), _T("shutdown"), NULL, g_stSATConfig.szTVShutdown, MAX_PATH, g_szPython27ResourceConfig);

+ 14 - 0
SATService/SATService/SATExecutor.cpp

@@ -129,7 +129,11 @@ SATHTTP::STCase* CSATExecutor::ExecuteFreeCaseScript(SATHTTP::STTask* pTask)
 	SATHTTP::STCase* pCase = GetFreeCaseScript(pTask->Job.vtCases);
 	if (pCase) {		
 #if 1 // 额外追加代码:清除之前的xml文件;
+#if 0
 		std::string xmlpath = GLOBAL::g_stSATConfig.szCaseResultDir;
+#else
+		std::string xmlpath = pCase->_strFileDir;
+#endif
 		xmlpath.append("detail\\");
 		xmlpath.append(pCase->_strFileName);
 		xmlpath.append("_result.xml");
@@ -520,7 +524,12 @@ bool CSATExecutor::ReportCaseItemFinish(SATHTTP::STTask* pTask, SATHTTP::STCase
 		// 再上传图片;
 		std::string img;
 		for (std::vector<std::string>::iterator it = caseItem.imgs.begin(); it != caseItem.imgs.end(); it++ ) {
+#if 0
 			img = GLOBAL::g_stSATConfig.szCaseResultDir;
+#else
+			// 使用脚本路径;
+			img = pCase->_strFileDir;
+#endif
 			img.append(it->substr(3));
 			img = GLOBAL::Replace(img, "/", "\\");
 			GLOBAL::WriteTextLog(GLOBAL::SAT_EXE, "图片路径=%s", img.c_str());
@@ -633,7 +642,12 @@ bool CSATExecutor::ReportCaseFinish(SATHTTP::STTask* pTask, SATHTTP::STCase *pCa
 bool CSATExecutor::ReportCaseResult(SATHTTP::STTask* pTask, SATHTTP::STCase *pCase)
 {
 	// 获取xml文件内容;
+#if 0
 	std::string xmlpath = GLOBAL::g_stSATConfig.szCaseResultDir;
+#else
+	// 使用脚本自身路径作为根目录;
+	std::string xmlpath = pCase->_strFileDir;
+#endif
 	xmlpath.append("detail\\");
 	xmlpath.append(pCase->_strFileName);
 #if 0