/**
  * Format messages output
  * 
  * @param Varien_Object $command
  * @return string Message
  */
 protected function formatMessages(Varien_Object $command, $payload = null)
 {
     $messages = '';
     $messages .= PHP_EOL . ' - ' . $command->getMessage() . PHP_EOL;
     $messages .= 'INPUT: ' . $command->getCommand() . PHP_EOL;
     $messages .= 'OUTPUT: ' . print_r($command->getOutput()) . PHP_EOL . PHP_EOL;
     return $messages;
 }
Example #2
0
    /**
     * Run PEAR command with html output console style
     *
     * @param array|Varien_Object $runParams command, options, params,
     *        comment, success_callback, failure_callback
     */
    public function runHtmlConsole($runParams)
    {
        ob_implicit_flush();
        $fe = $this->getFrontend();
        $oldLogStream = $fe->getLogStream();
        $fe->setLogStream('stdout');
        if ($runParams instanceof Varien_Object) {
            $run = $runParams;
        } elseif (is_array($runParams)) {
            $run = new Varien_Object($runParams);
        } elseif (is_string($runParams)) {
            $run = new Varien_Object(array('title' => $runParams));
        } else {
            throw Varien_Exception("Invalid run parameters");
        }
        ?>
<html><head><style type="text/css">
body { margin:0px; padding:3px; background:black; color:white; }
pre { font:normal 11px Courier New, serif; color:#2EC029; }
</style></head><body>
<?php 
        echo "<pre>" . $run->getComment();
        if ($command = $run->getCommand()) {
            $result = $this->run($command, $run->getOptions(), $run->getParams());
            if ($result instanceof PEAR_Error) {
                echo "\r\n\r\nPEAR ERROR: " . $result->getMessage();
            }
            echo '</pre><script type="text/javascript">';
            if ($result instanceof PEAR_Error) {
                if ($callback = $run->getFailureCallback()) {
                    call_user_func_array($callback, array($result));
                }
            } else {
                if ($callback = $run->getSuccessCallback()) {
                    call_user_func_array($callback, array($result));
                }
            }
            echo '</script>';
        } else {
            $result = false;
            echo '</pre>';
        }
        ?>
<script type="text/javascript">
if (!auto_scroll) {
    var auto_scroll = window.setInterval("document.body.scrollTop+=2", 10);
}
</script>
</body></html>
<?php 
        $fe->setLogStream($oldLogStream);
        return $result;
    }