diff --git a/afanasy/python/check_parser.py b/afanasy/python/check_parser.py index 105f1afd4..aa9e44f86 100755 --- a/afanasy/python/check_parser.py +++ b/afanasy/python/check_parser.py @@ -39,6 +39,8 @@ def UsageExit(message=''): taskInfo = dict() taskInfo['frames_num'] = framesNum taskInfo['wdir'] = os.getcwd() +taskInfo['environment'] = dict() +taskInfo['environment']['PDG_DIR'] = os.getcwd() parser.setTaskInfo(taskInfo) arguments = [] diff --git a/afanasy/python/parsers/mantra.py b/afanasy/python/parsers/mantra.py index 2eae65875..56b846880 100644 --- a/afanasy/python/parsers/mantra.py +++ b/afanasy/python/parsers/mantra.py @@ -11,6 +11,8 @@ IMAGE_RE = re.compile(r'.*Generating Image: (.+) \(\d+x\d+\)') +PDG_IMG_RE = re.compile(r'PDG_RESULT:.*;\s*(.*)\s*;.*;.*') + ErrorsRE = [re.compile(r'Error loading geometry .* from stdin')] PeakMem_RE = re.compile('.*Peak Memory Usage: *(.*)') @@ -51,6 +53,12 @@ def do(self, i_args): m = IMAGE_RE.match(line) if m: self.appendFile(m.group(1)) + m = PDG_IMG_RE.search(line) + if m: + img = m.group(1) + if cgruutils.isImageExt(img): + self.appendFile(self.expandEnvVars(img)) + percent_pos = data.find(PERCENT) if percent_pos > -1: @@ -89,3 +97,14 @@ def do(self, i_args): res = res.strip() if len(res): self.resources = res + + + def expandEnvVars(self, i_str): + + if not 'environment' in self.taskInfo: + return i_str + + for name in self.taskInfo['environment']: + i_str = i_str.replace('__%s__' % name, cgruutils.toStr(self.taskInfo['environment'][name])) + + return i_str diff --git a/afanasy/src/libafanasy/service.cpp b/afanasy/src/libafanasy/service.cpp index 0f340dade..ce84cf317 100644 --- a/afanasy/src/libafanasy/service.cpp +++ b/afanasy/src/libafanasy/service.cpp @@ -172,6 +172,10 @@ void Service::initialize( const TaskExec * i_task_exec, const std::string & i_st PyList_Append( pHostsList, PyBytes_FromString((*it).c_str())); + PyObject * pEenvDict = PyDict_New(); + for (auto const& it : i_task_exec->getEnv()) + PyDict_SetItemString(pEenvDict, it.first.c_str(), PyBytes_FromString(it.second.c_str())); + PyObject *pArgs; pArgs = PyTuple_New( 2); @@ -189,6 +193,7 @@ void Service::initialize( const TaskExec * i_task_exec, const std::string & i_st PyDict_SetItemString( task_info, "file_size_max", PyLong_FromLong( i_task_exec->getFileSizeMax())); PyDict_SetItemString( task_info, "hosts", pHostsList); PyDict_SetItemString( task_info, "parsed_files", pParsedFilesList); + PyDict_SetItemString(task_info, "environment", pEenvDict); PyDict_SetItemString( task_info, "frame_start", PyLong_FromLong(i_task_exec->getFrameStart())); PyDict_SetItemString( task_info, "frame_finish", PyLong_FromLong(i_task_exec->getFrameFinish()));