本文整理汇总了PHP中Shell类的典型用法代码示例。如果您正苦于以下问题:PHP Shell类的具体用法?PHP Shell怎么用?PHP Shell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Shell类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Executo command on shell
* @param Shell $shell
* @return bool
* @throws \Exception
*/
public function run(Shell $shell)
{
$match = NULL;
while (true) {
fwrite($shell->getStream(), $this->__cmd);
switch ($key = expect_expectl($shell->getStream(), $cases = $this->formatCases(), $match)) {
case in_array($key, $cases):
// Run next
if ($this->__next instanceof TCommand) {
$this->__next->run($shell);
}
if ('break' == ($result = $this->__cases_list[$key]->proceed($shell->getStream(), $match))) {
break;
}
$shell->addCmd($this->__cmd);
$shell->addResult($this->formatResult($result));
return true;
break 2;
case EXP_EOF:
case EXP_FULLBUFFER:
break 2;
case EXP_TIMEOUT:
throw new \Exception("Connection time out");
break 2;
default:
throw new \Exception("Error has occurred!");
break 2;
}
}
return false;
}
开发者ID:nejtr0n,项目名称:expect,代码行数:37,代码来源:Command.php
示例2: testCount
public function testCount()
{
$gerador = new Gerador();
$vector = $gerador->gerar(500);
$shell = new Shell();
$array = Asort($vector);
$this->assertEquals($array, $shell->run($vector));
}
开发者ID:secretrepository,项目名称:algbuild,代码行数:8,代码来源:CommandTest.php
示例3: testProjectDir
public function testProjectDir()
{
$projectDir = __DIR__ . '/../../../../';
$shell = new Shell($projectDir);
$testCommand = 'vendor/bin/phpunit';
$result = $shell->exec($testCommand, ['--version']);
$this->assertContains('PHPUnit', $result);
}
开发者ID:cakmoel,项目名称:QualityAnalyzer,代码行数:8,代码来源:ShellTest.php
示例4: truncateModels
/**
* Truncate the given models
*
* @param array $modelsToTruncate An array of models (names) to truncate
* @return void
* @todo Improve testability by extracting the model object retrieval part.
*/
public function truncateModels($modelsToTruncate)
{
foreach ($modelsToTruncate as $modelName) {
$this->_shell->out(__('Truncate model %s...', $modelName), 1, Shell::VERBOSE);
$model = ClassRegistry::init($modelName);
$datasource = $model->getDataSource();
$datasource->truncate($model->table);
}
}
开发者ID:ravage84,项目名称:cakephp-fake-seeder,代码行数:16,代码来源:ShellModelTruncator.php
示例5: parseFile
/**
* Parse file
* @param string $Filename relative path (from FRONTEND_PATH) to file
*/
public function parseFile($Filename)
{
$File = FRONTEND_PATH . $Filename;
$this->Filename = FRONTEND_PATH . $Filename . '.temp';
$Command = new PerlCommand();
$Command->setScript('fittorunalyze.pl', '"' . $File . '" 1>"' . $this->Filename . '"');
$Shell = new Shell();
$Shell->runCommand($Command);
$this->readFile();
}
开发者ID:n0rthface,项目名称:Runalyze,代码行数:14,代码来源:class.ImporterFiletypeFIT.php
示例6: isPerlAvailable
/**
* Is Perl available?
*
* Tries to run a testscript and returns true if succeeded.
* @return boolean
*/
public static function isPerlAvailable()
{
try {
$Command = new PerlCommand();
$Command->setScript('test.pl', '');
$Shell = new Shell();
$Shell->runCommand($Command);
return $Shell->getOutput() == 'success';
} catch (Exception $Exception) {
return false;
}
}
开发者ID:n0rthface,项目名称:Runalyze,代码行数:18,代码来源:class.Shell.php
示例7: doShell
/**
* Handle the run shell action
* @return ShellResult
*/
public function doShell()
{
// $shell is derived from RunResult
$shell = new Shell();
while (!$shell->isEOF()) {
if ($shell->isFail()) {
break;
}
$input = $shell->readInput();
if ($input === FALSE) {
break;
}
// Available shell commands (for help sreen)
$shell_commands = array('dump', 'exit', 'help');
// Interpret shell keywords
switch ($input) {
case 'exit':
break 2;
case 'dump':
$this->stdout(print_r($this->getMemory()->getData(), true));
break;
case 'help':
$extension_manager = $this->getExtensionManager();
$exports = $extension_manager->exports();
$this->stdout(PHP_EOL);
$this->stdout(str_pad(' Commands:', 13) . join(', ', $shell_commands) . PHP_EOL);
$this->stdout(str_pad(' Keywords:', 13) . join(', ', $this->getLanguageKeywords()) . PHP_EOL);
$this->stdout(str_pad(' Functions:', 13) . join(', ', $exports) . PHP_EOL);
$this->stdout(PHP_EOL);
break;
default:
// Assume is code
$this->setCode($input);
$result = $this->doRun();
// TODO: Finished this
// dd($result);
// $this->stdout()
// Handle printing errors
if ($result->isFail()) {
foreach ($result->getErrors() as $error) {
$this->stderr($this->outputFormatErrorMessage($error));
}
}
break;
}
// TODO: Provide interface for setting position :/
$this->line++;
$this->column = 0;
}
$shell->setData($this->getMemory()->getData());
return $shell;
}
开发者ID:g4z,项目名称:poop,代码行数:56,代码来源:Interpreter.php
示例8: instance
public static function instance()
{
if (!self::$_instance instanceof Shell) {
self::$_instance = new self();
}
return self::$_instance;
}
开发者ID:bauhouse,项目名称:sym-extensions,代码行数:7,代码来源:class.shell.php
示例9: execute
/**
* Executa comando
*
* @param Object $oInput
* @param Object $oOutput
* @access public
* @return void
*/
public function execute($oInput, $oOutput)
{
$oOutput->write("baixando atualizações...\r");
$oComando = $this->getApplication()->execute('cvs update -dRP');
$aRetornoComandoUpdate = $oComando->output;
$iStatusComandoUpdate = $oComando->code;
/**
* Caso CVS encontre conflito, retorna erro 1
*/
if ($iStatusComandoUpdate > 1) {
$oOutput->writeln('<error>Erro nº ' . $iStatusComandoUpdate . ' ao execurar cvs update -dR:' . "\n" . $this->getApplication()->getLastError() . '</error>');
return $iStatusComandoUpdate;
}
$oOutput->writeln(str_repeat(' ', \Shell::columns()) . "\r" . "Atualizações baixados");
$sComandoRoot = '';
/**
* Senha do root
*/
$sSenhaRoot = $this->getApplication()->getConfig('senhaRoot');
/**
* Executa comando como root
* - caso for existir senha no arquivo de configuracoes
*/
if (!empty($sSenhaRoot)) {
$sComandoRoot = "echo '{$sSenhaRoot}' | sudo -S ";
}
$oComando = $this->getApplication()->execute($sComandoRoot . 'chmod 777 -R ' . getcwd());
$aRetornoComandoPermissoes = $oComando->output;
$iStatusComandoPermissoes = $oComando->code;
if ($iStatusComandoPermissoes > 0) {
throw new Exception("Erro ao atualizar permissões dos arquivos, configura a senha do root: cvsgit config -e");
}
}
开发者ID:renanrmelo,项目名称:cvsgit,代码行数:41,代码来源:PullCommand.php
示例10: _run
/**
* Runs task
*/
protected function _run()
{
$this->_Process = new TaskProcess($this->_task['command'] . $this->_argsToString($this->_task['arguments']), $this->_task['path']);
$this->_Process->setTimeout($this->_task['timeout']);
try {
$this->_Process->start(function ($type, $buffer) {
if ('err' === $type) {
$this->_Shell->err($buffer);
$this->_task['stderr'] .= $buffer;
} else {
$this->_Shell->out($buffer);
$this->_task['stdout'] .= $buffer;
}
$this->_TaskServer->updated($this->_task);
});
while ($this->_Process->isRunning()) {
$this->_task['process_id'] = (int) $this->_Process->getPid();
$this->_TaskServer->updateStatistics($this->_task);
$this->_Process->checkTimeout();
sleep(Configure::read('Task.checkInterval'));
if ($this->_TaskServer->mustStop($this->_task['id'])) {
$this->_Process->stop(Configure::read('Task.stopTimeout'));
$this->_task['code'] = 143;
$this->_task['code_string'] = TaskProcess::$exitCodes[143];
return $this->_stopped(true);
}
}
$this->_task['code'] = $this->_Process->getExitCode();
$this->_task['code_string'] = $this->_Process->getExitCodeText();
} catch (Exception $Exception) {
$this->_task['code'] = 134;
$this->_task['code_string'] = $Exception->getMessage();
}
$this->_stopped(false);
}
开发者ID:imsamurai,项目名称:cakephp-task-plugin,代码行数:38,代码来源:TaskRunner.php
示例11: main
function main()
{
parent::loadTasks();
$this->out('Import Upload Shell');
$this->hr();
$this->_setAvailableImportFiles();
if (empty($this->args)) {
$imports = $this->_interactive();
} else {
$imports = $this->_determineImportIds(implode(' ', $this->args));
}
if (!empty($imports)) {
foreach ($imports as $import) {
$importUpload = $this->ImportUpload->create($import);
if ($filename = $this->ImportUpload->filePath()) {
$importUpload['ImportUpload']['file_path'] = $filename;
if (!empty($import['ImportDelimiter'])) {
$options = array('delimiter' => $import['ImportDelimiter']['delimiter'], 'excel_reader' => $import['ImportDelimiter']['use_excel_reader'], 'qualifier' => $import['ImportUpload']['text_qualifier']);
}
if ($this->Parser->execute($filename, $options)) {
$this->ImportUpload->saveField('total', $this->Parser->getRowCount());
$this->ImportUpload->saveField('is_importing', 1);
}
die('here');
} else {
}
}
}
}
开发者ID:nicoeche,项目名称:Finalus,代码行数:29,代码来源:import_upload.php
示例12: createFile
/**
* Creates a file at given path, checks if the file exists
*
* @param string $path Where to put the file.
* @param string $contents Content to put in the file.
* @return boolean Success
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::createFile
*/
public function createFile($path, $contents)
{
if (is_file($path) && $this->params['keep'] === true) {
$this->out(__d('cake_console', 'Skipping file %s.', $path));
return false;
}
return parent::createFile($path, $contents);
}
开发者ID:mathg,项目名称:skinsound,代码行数:16,代码来源:AppShell.php
示例13: read
/**
* @param array $args
*
* @return array
*/
public function read($args = [])
{
$args = $this->processOptions($args);
$this->shell->exec('git fetch -u');
$this->shell->exec("git log {$args['revision range']} --pretty=format:%s", $output);
return $output;
}
开发者ID:elsuperbeano,项目名称:curator,代码行数:12,代码来源:SimpleGitReader.php
示例14: testTruncateModels
/**
* Tests the truncateModels function
*
* @return void
* @covers ::truncateModels
*/
public function testTruncateModels()
{
$this->_shell->expects($this->at(0))->method('out')->with($this->equalTo('Truncate model Apple...'));
$this->_shell->expects($this->at(1))->method('out')->with($this->equalTo('Truncate model Banana...'));
$this->_shell->expects($this->at(2))->method('out')->with($this->equalTo('Truncate model Pear...'));
$models = array('Apple', 'Banana', 'Pear');
$this->_truncator->truncateModels($models);
}
开发者ID:ravage84,项目名称:cakephp-fake-seeder,代码行数:14,代码来源:ShellModelTruncatorTest.php
示例15: read
/**
* @param array $args
*
* @return array
*/
public function read($args = [])
{
$args = $this->processOptions($args);
$delim = "---<EOM>---";
$command = "git log {$args['revision range']} --pretty=format:\"{$this->format}{$delim}\"";
$output = substr($this->shell->shell_exec($command), 0, -1 * strlen($delim . PHP_EOL));
$output = explode(PHP_EOL . $delim . PHP_EOL, $output);
return $output;
}
开发者ID:elsuperbeano,项目名称:curator,代码行数:14,代码来源:GitReader.php
示例16: getOptionParser
/**
* Add sub-commands.
*
* @return ConsoleOptionParser
*/
public function getOptionParser()
{
$parser = parent::getOptionParser();
$parser->addSubcommand('core', array('help' => 'Delete all cache within CakePHP', 'parser' => array('description' => 'This command will clear all cache in CakePHP using the Cache engine settings.', 'options' => array('config' => array('short' => 'c', 'help' => 'Cache Config', 'default' => 'default'), 'key' => array('short' => 'k', 'help' => 'Cache Key', 'default' => '')))));
$parser->addSubcommand('apc', array('help' => 'Delete all cache within APC', 'parser' => array('description' => 'This command will clear all cache in APC, including user, system and opcode caches.')));
return $parser;
}
开发者ID:alescx,项目名称:cakephp-utils,代码行数:12,代码来源:CacheKillShell.php
示例17: loadTasks
/**
* Override loadTasks() to handle paths
*
* @access public
*/
function loadTasks()
{
parent::loadTasks();
$task = Inflector::classify($this->command);
if (isset($this->{$task}) && !in_array($task, array('Project', 'DbConfig'))) {
if (empty($this->{$task}->path)) {
$path = Inflector::underscore(Inflector::pluralize($this->command));
$this->{$task}->path = $this->params['working'] . DS . $path . DS;
}
if (isset($this->params['connection'])) {
$this->{$task}->connection = $this->params['connection'];
}
foreach ($this->args as $i => $arg) {
if (strpos($arg, '.')) {
list($this->params['plugin'], $this->args[$i]) = pluginSplit($arg);
break;
}
}
if (isset($this->params['plugin'])) {
$this->{$task}->plugin = $this->params['plugin'];
}
if (!is_dir($this->{$task}->path)) {
$this->err(sprintf(__("%s directory could not be found.\nBe sure you have created %s", true), $task, $this->{$task}->path));
$this->_stop();
}
}
}
开发者ID:enangyusup,项目名称:vbulletin-cakephp,代码行数:32,代码来源:bake.php
示例18: initialize
/**
* Initialization method. We have to jump through some hoops to
* allow our shell to work correctly from a plugin path.
* @return null
* @access public
*/
public function initialize()
{
require realpath(CAKE . '..' . DS) . DS . 'app' . DS . 'config' . DS . 'database.php';
require CAKE . 'libs' . DS . 'model' . DS . 'model.php';
require CAKE . 'libs' . DS . 'model' . DS . 'app_model.php';
parent::initialize();
}
开发者ID:predominant,项目名称:referee,代码行数:13,代码来源:errors.php
示例19: initialize
/**
* initialize
*
* @access public
*/
public function initialize()
{
parent::initialize();
if ($this->_dataPath == null) {
$this->_dataPath = APP . 'Plugin' . DS . 'Ekidata' . DS . 'Vendor' . DS . 'data' . DS;
}
}
开发者ID:go2coffee,项目名称:CakePHP2-Ekidata,代码行数:12,代码来源:ImportTask.php
示例20: out
function out($data)
{
if (is_scalar($data)) {
parent::out($data);
} else {
parent::out(print_r($data, true));
}
}
开发者ID:surjit,项目名称:Multitask,代码行数:8,代码来源:threaded_task.php
注:本文中的Shell类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论