Ejemplo n.º 1
0
 public function testExecutingCommandInBackground()
 {
     $script_sleep = realpath(__DIR__) . '/../data/sleep.php';
     $commandSleep = new Command("php {$script_sleep}");
     $exec = new Exec();
     $startTime = microtime(true);
     $exec->run($commandSleep);
     $this->assertGreaterThanOrEqual(1, microtime(true) - $startTime, "Script execution took 1 second");
     $commandSleep->runInBackground(true);
     $startTime = microtime(true);
     $exec->run($commandSleep);
     $this->assertLessThan(1, microtime(true) - $startTime, "Script that takes at least 1 secon is run in background");
 }
Ejemplo n.º 2
0
 /**
  * get current working directory
  */
 public static function getCwd()
 {
     if (!Exec::allowed() || OperatingSystem::isWindows()) {
         return getcwd();
     }
     Exec::run('pwd', $folder);
     return $folder;
 }
Ejemplo n.º 3
0
 /**
  * Store the confluence document in the confluence wiki.
  *
  * @param string $newDoc New document in confluence markup
  *
  * @return void
  */
 public function storePage($newDoc)
 {
     //we cannot pipe because of
     //  https://studio.plugins.atlassian.com/browse/CSOAP-121
     $tmpfile = tempnam(sys_get_temp_dir(), 'deploy-confluence-');
     file_put_contents($tmpfile, $newDoc);
     $cmd = sprintf($this->cmd['cflcli'] . ' --server %s --user %s --password %s' . ' --action storePage --space %s --title %s --file %s --quiet', escapeshellarg($this->cflHost), escapeshellarg($this->cflUser), escapeshellarg($this->cflPass), escapeshellarg($this->cflSpace), escapeshellarg($this->cflPage), escapeshellarg($tmpfile));
     list($lastline, $retval) = Exec::run($cmd);
     unlink($tmpfile);
     if ($retval !== 0) {
         throw new Exception('Error storing new document in confluence' . "\n" . $lastline, 30);
     }
 }