def tryUpdate(): """Execute the CLI module, but don't warn about missing inputs (used for autoUpdate). Returns error messages that can be displayed if explicitly run (cf. update()).""" global execution execution = CLIExecution() execution.start() if ctx.field('runInBackground_WIP').value: _pollProcessStatus() else: while execution.isRunning(): MLAB.processEvents() time.sleep(0.1) ec = execution.wait() if ec: return execution.errorDescription
def processOnce(): commandList = ctx.field("commandList").value isVerbose = ctx.field("isVerbose").value isProcessEvents = ctx.field("isProcessEvents").value isProcessInventorQueue = ctx.field("isProcessInventorQueue").value sleep = ctx.field("sleep").value commands = commandList.split('\n') for i in range(0, len(commands)): command = commands[i] if ((command != '') and (command[0] != '#')): if (isVerbose): MLAB.log("CommandBox ... " + command) ctx.parent().field(command).touch() if (isProcessEvents): MLAB.processEvents() if (isProcessInventorQueue): MLAB.processInventorQueue() MLAB.msleep(sleep)
def processOnce(): commandList = ctx.field("commandList").value; isVerbose = ctx.field("isVerbose").value; isProcessEvents = ctx.field("isProcessEvents").value; isProcessInventorQueue = ctx.field("isProcessInventorQueue").value; sleep = ctx.field("sleep").value; commands = commandList.split('\n') for i in range(0, len(commands)): command = commands[i] if ( (command != '') and (command[0] != '#') ): if (isVerbose): MLAB.log("CommandBox ... " + command); ctx.parent().field(command).touch(); if (isProcessEvents): MLAB.processEvents(); if (isProcessInventorQueue): MLAB.processInventorQueue(); MLAB.msleep(sleep);
def call(): success = False ctx.field("callSucceeded").value = success prog = ctx.field("executable").value args = str(ctx.field("arguments").value).split() workingdir = ctx.field("workingDirectory").value g_Process = MLAB.newProcess() #global g_Process MLAB.processEvents(False) MLAB.log(prog + " is started with the following options:") MLAB.log(args) if g_Process: g_Process.kill() if g_Process: MLAB.deleteProcess(g_Process) g_Process = MLAB.newProcess() g_Process.clearArguments() g_Process.addArgument(prog) g_Process.addArguments(args) g_Process.setWorkDir(workingdir) if ctx.field("outputToLogWindow").value: g_Process.setStdOutHandler(ctx, "processOut") g_Process.setStdErrHandler(ctx, "processOut") g_Process.setExitedHandler(ctx, "processExit") g_Process.setUserInfo(prog) g_Process.run() g_Process.waitForLaunch() if g_Process.isRunning(): MLAB.log(prog + " is running") success = True else: MLAB.log(prog + " failed to start") success = False MLAB.processEvents(True) if g_Process: g_Process.waitForExit() if g_Process: MLAB.deleteProcess(g_Process) ctx.field("callSucceeded").value = success