Running an external command

• Sep 25, 2014 - 11:49

Hi,

I read the post on running an external command, but it does not seem to be working.

The command optimuse is located in a subdirectory called optimuse in the plugin folder. It does not seem to be executing. The files are opened correctly (cantus.xml), but the command is not run since no new files are being generated.

Am I overlooking something?

Thanks!

//=============================================================================
// MuseScore
// OptiMuse plugin
//=============================================================================

//
// This is ECMAScript code (ECMA-262 aka "Java Script")
//

//---------------------------------------------------------
// init
// this function will be called on startup of mscore
//---------------------------------------------------------

function init()
{

}

//-------------------------------------------------------------------
// run
// this function will be called when activating the
// plugin menu entry
//
// global Variables:
// pluginPath - contains the plugin path; file separator is "/"
//-------------------------------------------------------------------

var outFile;
var reqId;

function run()
{

var process= new QProcess();

var args = new Array();
args[0]= pluginPath;
args[1]= "cf";

process.start(pluginPath + "/optimuse/optimuse", args);
process.waitForStarted();
process.waitForFinished();

outFile = new QTemporaryFile(pluginPath + "/optimuse/cantus.xml");

var score = new Score();
score.load(outFile.fileName());
}

//---------------------------------------------------------
// display a message box with error message
//---------------------------------------------------------
function errorMessage(){
mb = new QMessageBox();
mb.setWindowTitle("Error: optimuse");
mb.text = "An error occured during cantus firmus generation";
mb.exec();
}

//---------------------------------------------------------
// get finished handler
//---------------------------------------------------------
function finished(id ,error){
//print("finished");
/*print(id);
if (error){
errorMessage();
return;
}
if (id == reqId){
outFile.flush();
outFile.close();
if(outFile.size() > 200){
var score = new Score();
//score.load(outFile.fileName());
}else{
errorMessage();
}
}*/
}

//---------------------------------------------------------
// menu: defines were the function will be placed
// in the MuseScore menu structure
//---------------------------------------------------------

var mscorePlugin = {
majorVersion: 1,
minorVersion: 1,
menu: 'Optimuse.Generate Cantus Firmus',
init: init,
run: run
};

mscorePlugin;


Comments

Ok actually, I see it's the command itself and the first argument (url) that is not entirely correct. Scripts seems fine :)

Do you still have an unanswered question? Please log in first to post your question.