<commit_before>#include "stdafx.h"
#include "sceneGraph.h"

#include "CommonLog.h"

#include <maya/MItDag.h>
#include <maya/MFnDagNode.h>

static MString __PythonBool[] = { MString("False"), MString("True") };
static inline const MString &PythonBool(bool b)
{
	return __PythonBool[b?1:0];
}

static void __file_and_time_control_kill(const MString &var)
{
	MGlobal::executePythonCommand(var + " = None\n");	// deallocate this variable in Python!
}

AlembicFileAndTimeControl::~AlembicFileAndTimeControl(void)
{
	__file_and_time_control_kill(var);
}

AlembicFileAndTimeControlPtr AlembicFileAndTimeControl::createControl(const IJobStringParser& jobParams)
{
	static unsigned int numberOfControlCreated = 0;
	static const MString format("^1s = ExoAlembic._import.IJobInfo(r\"^2s\", ^3s, ^4s, ^5s, ^6s)\n");

	ESS_PROFILE_SCOPE("AlembicFileAndTimeControl::createControl");
	MString var("__alembic_file_and_time_control_tuple_");
	var += (++numberOfControlCreated);

	MString cmd;
	cmd.format(format, var, jobParams.filename.c_str(), PythonBool(jobParams.importNormals), PythonBool(jobParams.importUVs), PythonBool(jobParams.importFacesets), PythonBool(jobParams.useMultiFile));
	MStatus status = MGlobal::executePythonCommand(cmd);
	if (status != MS::kSuccess)
	{
		__file_and_time_control_kill(var);
		return AlembicFileAndTimeControlPtr();
	}
	return AlembicFileAndTimeControlPtr(new AlembicFileAndTimeControl(var));
}

bool SceneNodeMaya::replaceSimilarData(const char *functionName, SceneNodeAlembicPtr fileNode)
{
	static const MString format("ExoAlembic._attach.attach^1s(r\"^2s\", r\"^3s\", ^4s, ^5s)");

	ESS_PROFILE_SCOPE("SceneNodeMaya::replaceSimilarData");
	MString cmd;
	cmd.format(format, functionName, this->dccIdentifier.c_str(), fileNode->dccIdentifier.c_str(), fileAndTime->variable(), PythonBool(fileNode->pObjCache->isConstant));
	MGlobal::executePythonCommand(cmd);<commit_msg>better error message for when python commands fail.<commit_after>#include "stdafx.h"
#include "sceneGraph.h"

#include "CommonLog.h"

#include <maya/MItDag.h>
#include <maya/MFnDagNode.h>

static MString __PythonBool[] = { MString("False"), MString("True") };
static inline const MString &PythonBool(bool b)
{
	return __PythonBool[b?1:0];
}

static void __file_and_time_control_kill(const MString &var)
{
	MGlobal::executePythonCommand(var + " = None\n");	// deallocate this variable in Python!
}

AlembicFileAndTimeControl::~AlembicFileAndTimeControl(void)
{
	__file_and_time_control_kill(var);
}

AlembicFileAndTimeControlPtr AlembicFileAndTimeControl::createControl(const IJobStringParser& jobParams)
{
	static unsigned int numberOfControlCreated = 0;
	static const MString format("^1s = ExoAlembic._import.IJobInfo(r\"^2s\", ^3s, ^4s, ^5s, ^6s)\n");

	ESS_PROFILE_SCOPE("AlembicFileAndTimeControl::createControl");
	MString var("__alembic_file_and_time_control_tuple_");
	var += (++numberOfControlCreated);

	MString cmd;
	cmd.format(format, var, jobParams.filename.c_str(), PythonBool(jobParams.importNormals), PythonBool(jobParams.importUVs), PythonBool(jobParams.importFacesets), PythonBool(jobParams.useMultiFile));
	MStatus status = MGlobal::executePythonCommand(cmd);
	if (status != MS::kSuccess)
	{
		__file_and_time_control_kill(var);
		return AlembicFileAndTimeControlPtr();
	}
	return AlembicFileAndTimeControlPtr(new AlembicFileAndTimeControl(var));
}

bool SceneNodeMaya::replaceSimilarData(const char *functionName, SceneNodeAlembicPtr fileNode)
{
	static const MString format("ExoAlembic._attach.attach^1s(r\"^2s\", r\"^3s\", ^4s, ^5s)");

	ESS_PROFILE_SCOPE("SceneNodeMaya::replaceSimilarData");

	MString cmd;
	cmd.format(format, functionName, this->dccIdentifier.c_str(), fileNode->dccIdentifier.c_str(), fileAndTime->variable(), PythonBool(fileNode->pObjCache->isConstant));
	MStatus result = MGlobal::executePythonCommand(cmd);
	if( result.error() ) {
		ESS_LOG_WARNING( "Attached failed for " << functionName << ", reason: " << result.errorString().asChar() );
		return false;
	}

{'fraction_non_alphanumeric': 0.13631815907953976, 'fraction_numerical': 0.007003501750875438, 'mean_word_length': 8.172018348623853, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4967745', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1388, 'n_words': 227}