当前位置: 首页>>代码示例>>PHP>>正文


PHP CM_Util::exec方法代码示例

本文整理汇总了PHP中CM_Util::exec方法的典型用法代码示例。如果您正苦于以下问题:PHP CM_Util::exec方法的具体用法?PHP CM_Util::exec怎么用?PHP CM_Util::exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CM_Util的用法示例。


在下文中一共展示了CM_Util::exec方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _browserify

 /**
  * @param string[] $mainPaths
  * @param string[] $sourcePaths
  * @param bool     $generateSourceMaps
  * @return string
  */
 protected function _browserify(array $mainPaths, array $sourcePaths, $generateSourceMaps)
 {
     if (!count($mainPaths)) {
         return '';
     }
     $involvedFiles = [];
     foreach ($sourcePaths as $sourcePath) {
         $involvedFiles = array_merge($involvedFiles, CM_Util::rglob('*.js', $sourcePath));
     }
     foreach ($mainPaths as $mainPath) {
         $involvedFiles[] = $mainPath;
     }
     $cacheKeyContent = \Functional\reduce_left(array_unique($involvedFiles), function ($path, $index, $collection, $carry) {
         return md5($carry . (new CM_File($path))->read());
     }, '');
     $cacheKeyMainPaths = \Functional\reduce_left($mainPaths, function ($path, $index, $collection, $carry) {
         return md5($carry . $path);
     }, '');
     $cache = CM_Cache_Persistent::getInstance();
     $cacheKey = $cache->key(__METHOD__, $cacheKeyContent, $cacheKeyMainPaths, $generateSourceMaps);
     return $cache->get($cacheKey, function () use($mainPaths, $sourcePaths, $generateSourceMaps) {
         $args = $mainPaths;
         if ($generateSourceMaps) {
             $args[] = '--debug';
         }
         return CM_Util::exec('NODE_PATH="' . implode(':', $sourcePaths) . '" browserify', $args);
     });
 }
开发者ID:cargomedia,项目名称:cm,代码行数:34,代码来源:Abstract.php

示例2: iconRefresh

 public function iconRefresh()
 {
     /** @var CM_File[] $svgFileList */
     $svgFileList = array();
     foreach (CM_Bootloader::getInstance()->getModules() as $moduleName) {
         $iconPath = CM_Util::getModulePath($moduleName) . 'layout/default/resource/img/icon/';
         foreach (glob($iconPath . '*.svg') as $svgPath) {
             $svgFile = new CM_File($svgPath);
             $svgFileList[strtolower($svgFile->getFileName())] = $svgFile;
         }
     }
     if (0 === count($svgFileList)) {
         throw new CM_Exception_Invalid('Cannot process `0` icons');
     }
     $this->_getStreamOutput()->writeln('Processing ' . count($svgFileList) . ' unique icons...');
     $dirWork = CM_File::createTmpDir();
     $dirBuild = $dirWork->joinPath('/build');
     foreach ($svgFileList as $fontFile) {
         $fontFile->copyToFile($dirWork->joinPath($fontFile->getFileName()));
     }
     CM_Util::exec('fontcustom', array('compile', $dirWork->getPathOnLocalFilesystem(), '--no-hash', '--autowidth', '--font-name=icon-webfont', '--output=' . $dirBuild->getPathOnLocalFilesystem()));
     $cssFile = $dirBuild->joinPath('/icon-webfont.css');
     $less = preg_replace('/url\\("(?:.*?\\/)(.+?)(\\??#.+?)?"\\)/', 'url(urlFont("\\1") + "\\2")', $cssFile->read());
     CM_File::create(DIR_PUBLIC . 'static/css/library/icon.less', $less);
     foreach (glob($dirBuild->joinPath('/icon-webfont.*')->getPathOnLocalFilesystem()) as $fontPath) {
         $fontFile = new CM_File($fontPath);
         $fontFile->rename(DIR_PUBLIC . 'static/font/' . $fontFile->getFileName());
     }
     $dirWork->delete(true);
     $this->_getStreamOutput()->writeln('Created web-font and stylesheet.');
 }
开发者ID:cargomedia,项目名称:cm,代码行数:31,代码来源:Cli.php

示例3: _minify

 /**
  * @param string $content
  * @return string
  */
 protected function _minify($content)
 {
     $md5 = md5($content);
     $cacheKey = CM_CacheConst::App_Resource . '_md5:' . $md5;
     $cache = new CM_Cache_Storage_File();
     if (false === ($contentMinified = $cache->get($cacheKey))) {
         $uglifyCommand = 'uglifyjs --no-copyright';
         /**
          * Quote keys in literal objects, otherwise some browsers break.
          * E.g. "select2.js" on "Android 4.0.4"
          */
         $uglifyCommand .= ' --beautify beautify=false,quote-keys=true';
         $contentMinified = CM_Util::exec($uglifyCommand, null, $content);
         $cache->set($cacheKey, $contentMinified);
     }
     return $contentMinified;
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:21,代码来源:Abstract.php

示例4: _partition

 protected function _partition()
 {
     CM_Util::exec('sgdisk', ['-o', $this->_path]);
     $startSector = CM_Util::exec('sgdisk', ['-F', $this->_path]);
     $endSector = CM_Util::exec('sgdisk', ['-E', $this->_path]);
     CM_Util::exec('sgdisk', ['-n', '1:' . $startSector . ':' . $endSector, $this->_path]);
     $this->_path .= '1';
 }
开发者ID:cargomedia,项目名称:s3export_backup,代码行数:8,代码来源:Device.php

示例5: _compileAutoprefixer

 /**
  * @param string $content
  * @return string
  */
 private function _compileAutoprefixer($content)
 {
     $command = 'autoprefixer';
     $args = [];
     if (null !== $this->_autoprefixerBrowsers) {
         $args[] = '--browsers';
         $args[] = $this->_autoprefixerBrowsers;
     }
     return CM_Util::exec($command, $args, $content);
 }
开发者ID:cargomedia,项目名称:cm,代码行数:14,代码来源:Css.php

示例6: _getChildrenPidList

 /**
  * @return int[]
  * @throws CM_Exception
  */
 private function _getChildrenPidList()
 {
     $psCommand = 'ps axo pid,ppid,args';
     $psOutput = CM_Util::exec($psCommand);
     if (false === preg_match_all('/^\\s*(?<pid>\\d+)\\s+(?<ppid>\\d+)\\s+(?<args>.+)$/m', $psOutput, $matches, PREG_SET_ORDER)) {
         throw new CM_Exception('Cannot parse ps output `' . $psOutput . '`.');
     }
     $pid = CM_Process::getInstance()->getProcessId();
     $pidList = array();
     foreach ($matches as $match) {
         if ($match['ppid'] == $pid && false === strpos($match['args'], $psCommand)) {
             $pidList[] = (int) $match['pid'];
         }
     }
     return $pidList;
 }
开发者ID:cargomedia,项目名称:cm,代码行数:20,代码来源:ProcessTest.php

示例7: getHostId

 /**
  * @return int
  */
 public function getHostId()
 {
     return (int) hexdec(CM_Util::exec('hostid'));
 }
开发者ID:aladin1394,项目名称:CM,代码行数:7,代码来源:Process.php

示例8: runDump

 /**
  * @param string  $dbName
  * @param CM_File $dump
  */
 public static function runDump($dbName, CM_File $dump)
 {
     $client = CM_Service_Manager::getInstance()->getDatabases()->getMaster();
     $args = array();
     $args[] = '--host=' . $client->getHost();
     $args[] = '--port=' . $client->getPort();
     $args[] = '--user=' . $client->getUsername();
     $args[] = '--password=' . $client->getPassword();
     $args[] = $dbName;
     CM_Util::exec('mysql', $args, null, $dump->getPath());
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:15,代码来源:Db.php

示例9: testFreeMemory

 public function testFreeMemory()
 {
     $getMemoryUsage = function () {
         $pid = CM_Process::getInstance()->getProcessId();
         $memory = CM_Util::exec('ps', ['-o', 'rss', '--no-headers', '--pid', $pid]);
         return (int) $memory;
     };
     $imageOriginal = new CM_File_Image(DIR_TEST_DATA . 'img/test.jpg');
     $image = CM_File_Image::createTmp(null, $imageOriginal->read());
     $memoryUsage = $getMemoryUsage();
     $memoryUsageMaxExpected = $memoryUsage + 20 * 1000;
     $image->resizeSpecific(3000, 3000);
     $this->assertGreaterThan($memoryUsageMaxExpected, $getMemoryUsage());
     $image->freeMemory();
     $this->assertLessThan($memoryUsageMaxExpected, $getMemoryUsage());
     $image->validateImage();
 }
开发者ID:aladin1394,项目名称:CM,代码行数:17,代码来源:ImageTest.php


注:本文中的CM_Util::exec方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。