public function __construct(Symfony_Process_Process $process)
 {
     if ($process->isSuccessful()) {
         throw new Symfony_Process_Exception_InvalidArgumentException('Expected a failed process, but the given process was successful.');
     }
     $error = sprintf('The command "%s" failed.' . "\nExit Code: %s(%s)", $process->getCommandLine(), $process->getExitCode(), $process->getExitCodeText());
     if (!$process->isOutputDisabled()) {
         $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", $process->getOutput(), $process->getErrorOutput());
     }
     parent::__construct($error);
     $this->process = $process;
 }
 public function __construct(Symfony_Process_Process $process, $timeoutType)
 {
     $this->process = $process;
     $this->timeoutType = $timeoutType;
     parent::__construct(sprintf('The process "%s" exceeded the timeout of %s seconds.', $process->getCommandLine(), $this->getExceededTimeout()));
 }
예제 #3
0
파일: Backup.php 프로젝트: jimrucinski/Vine
 public function restore_db($fileName)
 {
     if (!$fileName) {
         throw new Exception('Cannot access database file.');
     }
     $port = 0;
     $host = DB_HOST;
     if (strpos(DB_HOST, ':') !== false) {
         list($host, $port) = explode(':', DB_HOST);
     }
     $socket = false;
     if (strpos(DB_HOST, '/') !== false || strpos(DB_HOST, '\\') !== false) {
         $socket = true;
         $host = end(explode(':', DB_HOST));
     }
     if ($socket) {
         $connection = array('--socket=' . $host);
     } else {
         $connection = array('--host=' . $host);
         if (!empty($port)) {
             $connection[] = '--port=' . $port;
         }
     }
     $mysql = mwp_container()->getExecutableFinder()->find('mysql', 'mysql');
     $arguments = array_merge(array($mysql, '--user='******'--password='******'--default-character-set=utf8', DB_NAME), $connection);
     $command = implode(' ', array_map(array('Symfony_Process_ProcessUtils', 'escapeArgument'), $arguments)) . ' < ' . Symfony_Process_ProcessUtils::escapeArgument($fileName);
     try {
         if (!mwp_is_shell_available()) {
             throw new MMB_Exception("Shell is not available");
         }
         $process = new Symfony_Process_Process($command, untrailingslashit(ABSPATH), $this->getEnv(), null, 3600);
         mwp_logger()->info('Database import process started', array('executable_location' => $mysql, 'command_line' => $process->getCommandLine()));
         $process->run();
         if (!$process->isSuccessful()) {
             throw new Symfony_Process_Exception_ProcessFailedException($process);
         }
     } catch (Symfony_Process_Exception_ProcessFailedException $e) {
         //unlink($fileName);
         mwp_logger()->error('Database import process failed', array('process' => $e->getProcess()));
         throw $e;
     } catch (Exception $e) {
         //unlink($fileName);
         mwp_logger()->error('Error while trying to execute database import process', array('exception' => $e));
         throw $e;
     }
     mwp_logger()->info('Database import process finished');
     //        unlink($fileName);
 }