/** * Download a release and unzip it * * @param string $release * @param string $installDir */ public function downloadRelease($release, $installDir) { $zipLocation = $this->downloadFromUpdateApi($release); if (!is_dir($installDir)) { mkdir($installDir); } $this->processExecutor->execute("unzip {$zipLocation} -d {$installDir}"); }
/** * Download a release and unzip it * * @param string $release * @param string $installDir */ public function downloadRelease($release, $installDir) { $this->ioService->writeln("<info>Downloading release</info>"); $zipLocation = $this->downloadFromUpdateApi($release); if (!is_dir($installDir)) { mkdir($installDir); } $this->ioService->writeln("<info>Unzipping archive</info>"); $this->processExecutor->execute("unzip -qq {$zipLocation} -d {$installDir}"); }
/** * Run user scripts * * @param string $path */ public function runCustomScripts($path) { if (!isset($this->config['CustomScripts'])) { return; } foreach ($this->config['CustomScripts'] as $script) { $this->processExecutor->execute($script, $path, true); } }
public function testAllowFailingCmmand() { $output = new BufferedOutput(); $executor = new ProcessExecutor($output); $expectedOutput = "ls: cannot access /no-such-file: No such file or directory\n"; $exitCode = $executor->execute('LC_ALL=C ls /no-such-file', null, true); $this->assertEquals(2, $exitCode); $this->assertEquals($expectedOutput, $output->fetch()); }
/** * @param $installDir */ private function runCliCommands($installDir) { $this->ioService->writeln("<info>Running license import</info>"); $this->processExecutor->execute("{$installDir}/bin/console sw:generate:attributes"); $this->processExecutor->execute("{$installDir}/bin/console sw:plugin:refresh"); $this->processExecutor->execute("{$installDir}/bin/console sw:plugin:install SwagLicense --activate"); $licenseFile = @getenv('HOME') . '/licenses.txt'; if (file_exists($licenseFile)) { $this->processExecutor->execute("{$installDir}/bin/console swaglicense:import {$licenseFile}"); } }
/** * @param $installDir */ public function runBuildScripts($installDir) { $buildXml = $installDir . '/build/build.xml'; if (!file_exists($buildXml)) { $this->ioService->writeln("<error>Could not find {$buildXml}</error>"); $this->ioService->writeln("<error>If you checked out an SW version < 4.1.0, you can just import {$installDir}/_sql/demo/VERSION.sql</error>"); return; } $this->ioService->writeln("<info>Running build-unit</info>"); $command = sprintf('ant -f %s build-unit', $buildXml); $this->processExecutor->execute($command); }
private function runInstaller(InstallationRequest $request) { $delegateOptions = ['dbHost', 'dbPort', 'dbSocket', 'dbUser', 'dbPassword', 'dbName', 'shopLocale', 'shopHost', 'shopPath', 'shopName', 'shopEmail', 'shopCurrency', 'adminUsername', 'adminPassword', 'adminEmail', 'adminLocale', 'adminName']; $arguments = []; foreach ($request->all() as $key => $value) { if (!in_array($key, $delegateOptions) || strlen($value) === 0) { continue; } $key = strtolower(preg_replace("/[A-Z]/", "-\$0", $key)); $arguments[] = sprintf('--%s="%s"', $key, $value); } if ($request->getNoSkipImport()) { $arguments[] = '--no-skip-import'; } if ($request->getSkipAdminCreation()) { $arguments[] = '--skip-admin-creation'; } $arguments = join(" ", $arguments); $this->processExecutor->execute("php {$request->getAbsoluteInstallDir()}/recovery/install/index.php {$arguments}"); }
/** * @param string $directory */ public function zipDir($directory, $outputFile) { $this->processExecutor->execute("zip -r {$outputFile} {$directory} -x *.git*"); }
/** * @group slow * @expectedException \Symfony\Component\Process\Exception\ProcessTimedOutException * @expectedExceptionMessage The process "sleep 2" exceeded the timeout of 1 seconds. */ public function testTimeout() { $output = new BufferedOutput(); $executor = new ProcessExecutor($output, 1); $executor->execute('sleep 2', null, true); }