Commit 4c26f401 authored by vlad_burin's avatar vlad_burin
Browse files

Слияние с DeploymentQt

--HG--
branch : MockCompsTest
......@@ -501,6 +501,19 @@ int Rpc_GetChannelName(int server_index, int channel_index, const char* &result,
return 0;
}
int Rpc_GetLastError(int server_index, const char* &result, int timeout)
{
RDK::USerStorageXML request,response;
int res=ProcessSimpleCommand("GetLastError", server_index, -1, timeout, request, response);
if(res)
return res;
static std::string res_string;
res_string=response.ReadString("Data", "").c_str();
result=res_string.c_str();
return 0;
}
int Rpc_GetDeploymentState(int server_index, int &dp_state, int& dp_progress, int& dp_cap, int timeout)
{
RDK::USerStorageXML request,response;
......@@ -580,6 +593,18 @@ int Rpc_DeployProject(int server_index, int task_index, int &resp, int timeout)
if(res)
return res;
}
int Rpc_PrepareProject(int server_index, const char* &verbose_response, int timeout)
{
RDK::USerStorageXML request,response;
return ProcessSimpleCommand("PrepareProject", server_index, -1, timeout, request, response);
}
int Rpc_OpenPreparedProject(int server_index, const char* &verbose_response, int timeout)
{
RDK::USerStorageXML request,response;
return ProcessSimpleCommand("OpenPreparedProject", server_index, -1, timeout, request, response);
}
......@@ -97,10 +97,16 @@ int Rpc_GetDeploymentState(int server_index, int &dp_state, int& dp_progress, i
int Rpc_SetChannelName(int server_index, int channel_index, const char* channel_name, int timeout);
int Rpc_GetLastError(int server_index, const char* &result, int timeout);
int Rpc_SaveProject(int server_index, int timeout);
int Rpc_LoadProject(int server_index, const char* project_path, int timeout);
int Rpc_DeployProject(int server_index, int task_index, int &resp, int timeout=-1);
int Rpc_PrepareProject(int server_index, const char* &verbose_response, int timeout);
int Rpc_OpenPreparedProject(int server_index, const char* &verbose_response, int timeout);
#endif // RDKQTCPCLIENTLIB_H
This diff is collapsed.
......@@ -52,7 +52,12 @@ enum DeploymentState
DS_UnpackScripts=7,
DS_DownloadData=8,
DS_UnpackData=9,
DS_Finished=10,
DS_DeployFinished=10,
DS_CopyProject=11,
DS_PrepareProject=12,
DS_ProjectPrepared=13,
DS_OpenProject=14,
DS_ProjectOpened=15,
DS_Error=100
};
......@@ -68,7 +73,6 @@ public:
void SetDatabasePath(const QString& path);
void SetDownloadTempPath(const QString& path);
void SetDeploymentTempPath(const QString& path);
void SetFtpRemoteBasePath(const QString& path);
void SetDeploymentState(const DeploymentState& state);
void SetDeploymentProgress(const int &progress);
......@@ -84,7 +88,6 @@ public:
///Get
QString GetDatabasePath();
QString GetFtpRemoteBasePath();
QString GetDeploymentTempPath();
QString GetDownloadTempPath(); //
DeploymentState GetDeploymentState();
......@@ -110,12 +113,6 @@ private:
void DeployData();
bool VerifyData();
// , , ?
//bool ErrorOccured();
// , ,
//std::string GetLastError();
private:
QMutex deploymentStateMutex;
QMutex deploymentProgressMutex;
......@@ -123,7 +120,6 @@ private:
QString databasePath;
QString ftpRemoteBasePath;
QString deploymentTempPath;
QString downloadTempPath;
bool template_dr, weights_dr, script_dr, videosource_dr;
......@@ -199,16 +195,20 @@ bool task_script_download_required;
//
// ( )
QString task_src_path;
QString task_src_fullpath;
//
bool task_src_download_required;
// ( )
QString task_src_zip_url;
QString deployment_temp_path;
QString download_temp_path;
UProjectDeployProcessingThread *deployProcessingThread;
std::string lastError;
DeploymentState deploymentState;
/*
//?
// (- 1)
......@@ -232,6 +232,15 @@ public: //
/// , ( )
virtual int StartProjectDeployment(int task_id);
/// :
/// 1.
/// 2. ?
/// 3.
virtual int PrepareProject(std::string &response);
///
virtual int OpenPreparedProject(std::string &response);
///
//virtual void SetDatabaseAccess(const std::string &db_address, const std::string &db_name, const std::string &db_login, const std::string &db_password);
//virtual void SetProjectIndices(int gt_id, int sln_id, int weights_id, int script_id);
......@@ -242,6 +251,7 @@ virtual int GetDeploymentState();
virtual int GetStageCap();
virtual int GetStageProgress();
virtual std::string GetLastError();
virtual std::string GetProjectFileName();
public: //
......@@ -254,9 +264,22 @@ UProjectDeployerQt(void);
virtual ~UProjectDeployerQt(void);
// --------------------------
protected:
// --------------------------
//
// --------------------------
/// ,
int CopyProjectToTempFolder();
///
int OpenProjectMockMode();
///
int SetupProjectMockParameters();
///
int CloseMockProject();
///
/// ( )
//int OpenPreparedProject();
/// ,
///
......
......@@ -135,12 +135,20 @@ int UAppCore<ApplicationT, EngineControlT, ProjectT, ServerControlT, TestManager
programName=projectIniFile("General","ProgramName","Server");
configsMainPath=projectIniFile("General", "ConfigsMainPath", "../../../Configs/");
neverSleepOnMMThreadContention=atoi(projectIniFile("General","NeverSleepOnMMThreadContention","0"));
logDir=projectIniFile("Log","Dir","");
logDir=projectIniFile("Log","Dir",""); // TODO: Log/FixedLogPath
if(logDir.empty())
logDir=projectIniFile("Log","FixedLogPath",""); // TODO: Log/Dir
int logCreationMode=atoi(projectIniFile("Log","LogCreationMode","0"));
// bool SetFixedLogPath(const std::string& value);
startupDelay=atoi(projectIniFile("General","StartupDelay","0"));
useNewXmlFormatProjectFile=atoi(projectIniFile("General","UseNewXmlFormatProjectFile","0"));
useNewProjectFilesStructure=atoi(projectIniFile("General","UseNewProjectFilesStructure","0"));
std::string librariesPath=projectIniFile("General", "LibrariesPath", "../../../");
databaseMainPath=projectIniFile("General","DatabaseMainPath","");
remoteFtpDatabasePath=projectIniFile("General","RemoteFtpDatabasePath","");
......@@ -152,6 +160,7 @@ int UAppCore<ApplicationT, EngineControlT, ProjectT, ServerControlT, TestManager
logDebugMode=atoi(projectIniFile("Log","DebugMode","1"));
disableAdminForm=atoi(projectIniFile("General","DisableAdminForm","0"));
std::string temp_proj_path = projectIniFile("General", "TemporaryProjectPath", "");
serverPort = atoi(projectIniFile("Server","BindPort","45545"));
serverAddress = projectIniFile("Server","BindAddress","127.0.0.2");
......@@ -164,18 +173,26 @@ int UAppCore<ApplicationT, EngineControlT, ProjectT, ServerControlT, TestManager
application.SetApplicationFileName(application_file_name);
application.SetLogCreationMode(logCreationMode);
if(logDir.empty())
{
application.SetFixedLogPath(log_dir);
application.SetLogDir(log_dir);
}
else
{
application.SetFixedLogPath(logDir);
application.SetLogDir(logDir);
}
application.SetDebugMode(logDebugMode);
application.SetLibrariesPath(librariesPath);
application.SetConfigsMainPath(configsMainPath);
application.ChangeUseNewXmlFormatProjectFile(useNewXmlFormatProjectFile);
application.ChangeUseNewProjectFilesStructure(useNewProjectFilesStructure);
try
{
if(argc > 1)
......@@ -201,6 +218,12 @@ int UAppCore<ApplicationT, EngineControlT, ProjectT, ServerControlT, TestManager
{
application.SetDatabaseMainPath(databaseMainPath);
}
if(temp_proj_path!="")
{
application.GetProjectDeployer()->SetTempProjectDeploymentPath(temp_proj_path);
}
application.GetServerControl()->GetServerTransport()->SetServerBinding(serverAddress, serverPort);
cout<<"ServerAutoStartFlag: "<<serverAutostartFlag<<"\n";
std::cout<<"Test cout "<<serverAddress.c_str()<<" "<<serverPort<<std::endl;
......
......@@ -47,6 +47,7 @@ UApplication::UApplication(void)
ChangeUseNewXmlFormatProjectFile(false);
ChangeUseNewProjectFilesStructure(false);
StorageBuildMode = 1;
LogCreationMode=0;
//SetStandartXMLInCatalog();
......@@ -87,7 +88,8 @@ bool UApplication::SetWorkDirectory(const std::string& value)
if(WorkDirectory == value)
return true;
WorkDirectory=value;
UpdateLoggers();
if(FixedLogPath.empty())
UpdateLoggers();
return true;
}
......@@ -105,6 +107,20 @@ bool UApplication::SetConfigsMainPath(const std::string &value)
return true;
}
/// ( - MockLibs, RTlibs)
const std::string& UApplication::GetLibrariesPath(void) const
{
return LibrariesPath;
}
bool UApplication::SetLibrariesPath(const std::string &value)
{
if(LibrariesPath == value)
return true;
LibrariesPath=value;
return true;
}
/// ( /Bin/Configs)
const std::string& UApplication::GetDatabaseMainPath(void) const
{
......@@ -157,7 +173,8 @@ bool UApplication::SetProjectPath(const std::string& value)
if(ProjectPath == value)
return true;
ProjectPath=value;
UpdateLoggers();
if(LogCreationMode == 0 || LogCreationMode == 1)
UpdateLoggers();
// EngineControl->GetEngineStateThread()->CloseEventsLogFile();
CalcAppCaption();
return true;
......@@ -265,18 +282,53 @@ bool UApplication::SetDebugMode(bool value)
std::string UApplication::CalcCurrentLogDir(void) const
{
std::string log_dir;
if(Project && Project->GetConfig().OverrideLogParameters && !ProjectPath.empty())
switch(LogCreationMode)
{
case 0:
case 1:
{
log_dir=ProjectPath+"EventsLog/";
if(Project && Project->GetConfig().OverrideLogParameters && !ProjectPath.empty())
{
log_dir=ProjectPath+"EventsLog/";
}
else
{
if(FixedLogPath.empty())
{
log_dir=Core_GetLogDir();
if(log_dir.empty())
log_dir=WorkDirectory+"EventsLog/";
}
else
{
log_dir=FixedLogPath;
}
if(!log_dir.empty() && log_dir.find_last_of("\\/") != log_dir.size()-1)
log_dir+="/";
}
}
else
break;
case 2:
case 3:
{
log_dir=Core_GetLogDir();
if(log_dir.empty())
log_dir=WorkDirectory+"EventsLog/";
if(FixedLogPath.empty())
{
log_dir=Core_GetLogDir();
if(log_dir.empty())
log_dir=WorkDirectory+"EventsLog/";
}
else
{
log_dir=FixedLogPath;
}
if(!log_dir.empty() && log_dir.find_last_of("\\/") != log_dir.size()-1)
log_dir+="/";
}
break;
}
return log_dir;
}
......@@ -311,6 +363,43 @@ bool UApplication::IsInit(void) const
return AppIsInit;
}
///
const std::string& UApplication::GetFixedLogPath(void) const
{
return FixedLogPath;
}
bool UApplication::SetFixedLogPath(const std::string& value)
{
if(FixedLogPath == value)
return true;
FixedLogPath=value;
return true;
}
///
/// 0 - ( Reset )
/// 1 - .
/// 2 - .
/// 3 -
int UApplication::GetLogCreationMode(void) const
{
return LogCreationMode;
}
bool UApplication::SetLogCreationMode(int mode)
{
if(LogCreationMode == mode)
return true;
if(mode<0 || mode>3)
return false;
LogCreationMode=mode;
return true;
}
///
void UApplication::SetStorageBuildMode(int mode)
{
......@@ -540,6 +629,7 @@ bool UApplication::Init(void)
Core_LoadFonts();
EngineControl->Init();
RDK::GetCoreLock()->SetLibrariesPath(LibrariesPath);
UApplication::SetNumChannels(1);
// MCore_ChannelInit(0,0,(void*)ExceptionHandler);
......@@ -556,8 +646,6 @@ bool UApplication::Init(void)
}*/
SetStandartXMLInCatalog();
AppIsInit = true;
return true;
}
......@@ -1271,11 +1359,13 @@ bool UApplication::OpenProject(const std::string &filename)
ProjectFileName=extract_file_name(filename);
Project->SetProjectPath(ProjectPath);
Project->ReadFromXml(ProjectXml);
UpdateLoggers();
if(LogCreationMode != 3)
UpdateLoggers();
TProjectConfig config=Project->GetConfig();
GetCore()->GetLogger(RDK_GLOB_MESSAGE)->SetEventsLogMode(config.EventsLogFlag);
GetCore()->GetLogger(RDK_GLOB_MESSAGE)->Clear();
if(LogCreationMode != 3)
GetCore()->GetLogger(RDK_GLOB_MESSAGE)->Clear();
// EngineControl->GetEngineStateThread()->SetLogFlag(config.EventsLogFlag);
// EngineControl->GetEngineStateThread()->CloseEventsLogFile();
// EngineControl->GetEngineStateThread()->SetLogDir(ProjectPath);
......
......@@ -50,6 +50,9 @@ std::string WorkDirectory;
/// ( /Bin/Configs)
std::string ConfigsMainPath;
/// ( - MockLibs, RTlibs)
std::string LibrariesPath;
/// ( /Database)
std::string DatabaseMainPath;
......@@ -101,6 +104,17 @@ std::list<StandartXMLInCatalog> xmlInCatalog;
// 3 - . -, . ( )
int StorageBuildMode;
///
///
std::string FixedLogPath;
///
/// 0 - ( ResetChannel StartChannel )
/// 1 - .
/// 2 - .
/// 3 -
int LogCreationMode;
protected: //
///
UEPtr<URpcDispatcher> RpcDispatcher;
......@@ -159,6 +173,10 @@ bool SetConfigsMainPath(const std::string &value);
const std::string& GetDatabaseMainPath(void) const;
bool SetDatabaseMainPath(const std::string &value);
/// ( - MockLibs, RTLibs)
const std::string& GetLibrariesPath(void) const;
bool SetLibrariesPath(const std::string &value);
/// ( /Bin/Models)
const std::string& GetModelsMainPath(void) const;
bool SetModelsMainPath(const std::string &value);
......@@ -196,6 +214,18 @@ bool ChangeUseNewProjectFilesStructure(bool value);
const std::list<StandartXMLInCatalog>& GetStandartXMLInCatalog(void) const;
bool SetStandartXMLInCatalog(void);
///
const std::string& GetFixedLogPath(void) const;
bool SetFixedLogPath(const std::string& value);
///
/// 0 - ( ResetChannel StartChannel )
/// 1 - .
/// 2 - .
/// 3 -
int GetLogCreationMode(void) const;
bool SetLogCreationMode(int mode);
///
const std::string& GetAppCaption(void) const;
......
......@@ -263,7 +263,8 @@ void UEngineControl::StartChannel(int channel_index)
if(channel_index>=GetNumChannels())
return;
GetCore()->GetLogger(RDK_GLOB_MESSAGE)->RecreateEventsLogFile();
if(Application && Application->GetLogCreationMode() == 0)
GetCore()->GetLogger(RDK_GLOB_MESSAGE)->RecreateEventsLogFile();
// EngineStateThread->RecreateEventsLogFile();
switch(ThreadMode)
{
......@@ -367,7 +368,8 @@ void UEngineControl::PauseChannel(int channel_index)
break;
}
GetCore()->GetLogger(RDK_GLOB_MESSAGE)->Clear();
if(Application && Application->GetLogCreationMode() == 0)
GetCore()->GetLogger(RDK_GLOB_MESSAGE)->Clear();
// EngineStateThread->CloseEventsLogFile();
}
......@@ -377,7 +379,8 @@ void UEngineControl::ResetChannel(int channel_index)
if(channel_index>=GetNumChannels())
return;
GetCore()->GetLogger(RDK_GLOB_MESSAGE)->RecreateEventsLogFile();
if(Application && Application->GetLogCreationMode() == 0)
GetCore()->GetLogger(RDK_GLOB_MESSAGE)->RecreateEventsLogFile();
// EngineStateThread->RecreateEventsLogFile();
if(channel_index == -1)
{
......
......@@ -74,11 +74,43 @@ void UProjectDeployer::SetFtpRemotePath(const std::string &path)
ftp_remote_path = path;
}
void UProjectDeployer::SetTempProjectDeploymentPath(const std::string &path)
{
temp_project_deployment_path = path;
}
std::string UProjectDeployer::GetTempProjectDeploymentPath()
{
return temp_project_deployment_path;
}
/// :
/// 1.
/// 2. ?
/// 3.
int UProjectDeployer::PrepareProject(std::string &response)
{
response="base class called";
return -1;
}
///
int UProjectDeployer::OpenPreparedProject(std::string &response)
{
response="base class called";
return -1;
}
std::string UProjectDeployer::GetLastError()
{
return std::string();
}
std::string UProjectDeployer::GetProjectFileName()
{
return std::string();
}
/*
void UProjectDeployer::SetProjectIndices(int gt_id, int sln_id, int weights_id, int script_id)
{
......
......@@ -28,6 +28,8 @@ std::string database_password;
std::string ftp_remote_path;
std::string temp_project_deployment_path;
/*
// ( !)
// (- 1)
......@@ -50,9 +52,18 @@ UEPtr<UApplication> GetApplication(void);
bool SetApplication(UEPtr<UApplication> value);
// --------------------------
/// , ( )
/// ,
/// ( )
virtual int StartProjectDeployment(int task_id);
/// :
/// 1.
/// 2. ?
/// 3.
virtual int PrepareProject(std::string &response);
///
virtual int OpenPreparedProject(std::string &response);
/// -
virtual void SetDatabaseAccess(const std::string &db_address, const std::string &db_name, const std::string &db_login, const std::string &db_password);
///
......@@ -65,8 +76,12 @@ virtual int GetStageCap();
virtual int GetStageProgress();
virtual std::string GetLastError();
virtual std::string GetProjectFileName();
virtual void SetFtpRemotePath(const std::string &path);
virtual void SetTempProjectDeploymentPath(const std::string &path);
virtual std::string GetTempProjectDeploymentPath();
// --------------------------
//
......
......@@ -160,6 +160,16 @@ bool URpcDecoderCommon::IsCmdSupported(const UEPtr<URpcCommand> &command) const
{
return true;
}
else
if(cmd == "PrepareProject")
{
return true;
}
else
if(cmd == "OpenPreparedProject")
{
return true;
}
/*else
if(cmd == "GetDeploymentStageMax")
{
......@@ -387,16 +397,25 @@ const char* URpcDecoderCommon::RemoteCall(const char *request, int &return_value
if(cmd == "GetLastError")