コード例 #1
0
 public function operate(kOperator $operator = null, $inFilePath, $configFilePath = null)
 {
     $res = parent::operate($operator, $inFilePath, $configFilePath);
     if ($res == false) {
         return false;
     }
     $rvPath = pathinfo($inFilePath);
     $fileName = $rvPath['filename'];
     $baseName = $rvPath['basename'];
     $ismStr = file_get_contents("{$this->outFilePath}.ism");
     $ismStr = str_replace(array("{$this->outFilePath}.ismc", $inFilePath), array("{$fileName}.ismc", $baseName), $ismStr);
     file_put_contents("{$this->outFilePath}.ism", $ismStr);
     $rv = mkdir($this->outFilePath . "_tmpism", 0777);
     if ($rv == false) {
         return false;
     }
     $newIsmBaseName = $this->outFilePath . "_tmpism/{$fileName}";
     rename("{$this->outFilePath}.ism", "{$newIsmBaseName}.ism");
     rename("{$this->outFilePath}.ismc", "{$newIsmBaseName}.ismc");
     $fsDescArr = array();
     $fsDesc = new KalturaDestFileSyncDescriptor();
     $fsDesc->fileSyncLocalPath = "{$newIsmBaseName}.ism";
     $fsDesc->fileSyncObjectSubType = 3;
     //".ism";
     $fsDescArr[] = $fsDesc;
     $fsDesc = new KalturaDestFileSyncDescriptor();
     $fsDesc->fileSyncLocalPath = "{$newIsmBaseName}.ismc";
     $fsDesc->fileSyncObjectSubType = 4;
     //".ismc";
     $fsDescArr[] = $fsDesc;
     $this->data->extraDestFileSyncs = $fsDescArr;
     $this->data->destFileSyncLocalPath = null;
     $this->outFilePath = null;
     return $res;
 }
コード例 #2
0
 protected function getCmdLine()
 {
     $exeCmd = parent::getCmdLine();
     if (strstr($exeCmd, KDLOperatorMp4box::ACTION_EMBED_SUBTITLES) !== FALSE) {
         $captionsStr = null;
         // impersonite
         KBatchBase::impersonate($this->job->partnerId);
         $captionsStr = $this->buildSubTitleCommandParam($this->data);
         // un-impersonite
         KBatchBase::unimpersonate();
         if (isset($captionsStr)) {
             $exeCmd = str_replace(array(KDLOperatorMp4box::ACTION_EMBED_SUBTITLES, KDLOperatorMp4box::SUBTITLE_PLACEHOLDER), array("", $captionsStr), $exeCmd);
         } else {
             if (!(isset($this->operator) && isset($this->operator->isOptional) && $this->operator->isOptional > 0)) {
                 $this->message .= "." . print_r($this->operator, 1);
                 throw new KOperationEngineException($this->message);
             }
         }
     } else {
         if (strstr($exeCmd, KDLOperatorMp4box::ACTION_HINT) !== FALSE) {
             $exeCmd = str_replace(KDLOperatorMp4box::ACTION_HINT, "", $exeCmd);
         }
     }
     return $exeCmd;
 }
コード例 #3
0
 protected function getCmdLine()
 {
     $cmdLine = parent::getCmdLine();
     $cmdLine = KConversionEngineFfmpeg::experimentalFixing($cmdLine, $this->data->flavorParamsOutput, $this->cmd, $this->inFilePath, $this->outFilePath);
     $cmdLine = KConversionEngineFfmpeg::expandForcedKeyframesParams($cmdLine);
     $wmStr = strstr($this->operator->params, "watermark:");
     if ($wmStr == false) {
         return $cmdLine;
     }
     $wmStr = trim(substr($this->operator->params, strlen("watermark:")));
     /*
      * If no watermarkData, carry on 
      */
     if ($wmStr == null) {
         return $cmdLine;
     }
     KalturaLog::log("Watermark string({$wmStr})");
     $wmData = json_decode($wmStr);
     if (!isset($wmData)) {
         KalturaLog::err("Bad watermark JSON string({$wmStr}), carry on without watermark");
     }
     KalturaLog::log("Watermark data:\n" . print_r($wmData, 1));
     // impersonite
     KBatchBase::impersonate($this->data->flavorParamsOutput->partnerId);
     // !!!!!!!!!!!$this->job->partnerId);
     $wmCmdLine = KConversionEngineFfmpeg::buildWatermarkedCommandLine($wmData, $this->data->destFileSyncLocalPath, $cmdLine, KBatchBase::$taskConfig->params->ffmpegCmd, KBatchBase::$taskConfig->params->mediaInfoCmd);
     // un-impersonite
     KBatchBase::unimpersonate();
     if (isset($wmCmdLine)) {
         $cmdLine = $wmCmdLine;
     }
     return $cmdLine;
 }
コード例 #4
0
 public function operate(kOperator $operator = null, $inFilePath, $configFilePath = null)
 {
     $qtInFilePath = "{$this->tmpFolder}/{$inFilePath}.stb";
     if (symlink($inFilePath, $qtInFilePath)) {
         $inFilePath = $qtInFilePath;
     }
     return parent::operate($operator, $inFilePath, $configFilePath);
 }
コード例 #5
0
 public function operate(kOperator $operator = null, $inFilePath, $configFilePath = null)
 {
     $res = parent::operate($operator, $inFilePath, $configFilePath);
     if ($res == false) {
         return false;
     }
     $inPathInfo = pathinfo($inFilePath);
     $inFileName = $inPathInfo['filename'];
     $outPathInfo = pathinfo($this->outFilePath);
     $outFileName = $outPathInfo['filename'];
     $outBaseName = $outPathInfo['basename'];
     $outFolderName = $outPathInfo['dirname'];
     $auxOutName = "{$outFolderName}//{$inFileName}";
     /*
      * Update ISM manifest file with correct output file names
      */
     $ismStr = file_get_contents($auxOutName . ".ism");
     KalturaLog::info("Before file name update:\n{$ismStr}");
     $ismXml = new SimpleXMLElement($ismStr);
     $ismXml->head->meta['content'] = $outFileName . ".ismc";
     if (isset($ismXml->body->switch->video)) {
         $extStr = pathinfo((string) $ismXml->body->switch->video['src'], PATHINFO_EXTENSION);
         $ismXml->body->switch->video['src'] = $outBaseName;
     }
     if (isset($ismXml->body->switch->audio)) {
         $extStr = pathinfo((string) $ismXml->body->switch->audio['src'], PATHINFO_EXTENSION);
         $ismXml->body->switch->audio['src'] = $outBaseName;
     }
     $ismStr = $ismXml->asXML();
     KalturaLog::info("After file name update:\n{$ismStr}");
     file_put_contents($auxOutName . ".ism", $ismStr);
     /*
      * Update the ISM/ISMC/ISMV file names to correct output file names
      */
     rename($auxOutName . ".ism", "{$outFolderName}//{$outFileName}.ism");
     rename($auxOutName . ".ismc", "{$outFolderName}//{$outFileName}.ismc");
     if (isset($extStr)) {
         rename($auxOutName . ".{$extStr}", "{$outFolderName}//{$outBaseName}");
     } else {
         rename($auxOutName, "{$outFolderName}//{$outBaseName}");
     }
     /*
      * Notify batch job flow to bind the ISM/ISMC files to the asset
      */
     $fsDescArr = array();
     $fsDesc = new KalturaDestFileSyncDescriptor();
     $fsDesc->fileSyncLocalPath = "{$outFolderName}//{$outFileName}.ism";
     $fsDesc->fileSyncObjectSubType = 3;
     //".ism";
     $fsDescArr[] = $fsDesc;
     $fsDesc = new KalturaDestFileSyncDescriptor();
     $fsDesc->fileSyncLocalPath = "{$outFolderName}//{$outFileName}.ismc";
     $fsDesc->fileSyncObjectSubType = 4;
     //".ismc";
     $fsDescArr[] = $fsDesc;
     $this->data->extraDestFileSyncs = $fsDescArr;
     return $res;
 }
コード例 #6
0
 public function operate(kOperator $operator = null, $inFilePath, $configFilePath = null)
 {
     //$this->outFilePath = "k:".$this->outFilePath;
     KalturaLog::debug("creating directory:" . $this->outFilePath);
     kFile::fullMkfileDir($this->outFilePath, 0777, true);
     $res = parent::operate($operator, $inFilePath, $configFilePath);
     rename("{$this->outFilePath}//playlist.m3u8", "{$this->outFilePath}//playlist.tmp");
     self::parsePlayList("{$this->outFilePath}//playlist.tmp", "{$this->outFilePath}//playlist.m3u8");
     //		rename("out_dummy.m3u8", "$this->outFilePath//out_dummy.m3u8");
     //		KalturaLog::info("operator($operator), inFilePath($inFilePath), configFilePath($configFilePath)");
     return $res;
 }
 public function operate(kOperator $operator = null, $inFilePath, $configFilePath = null)
 {
     if (kFile::fullMkfileDir($this->outFilePath)) {
         KalturaLog::debug('dir [' . $this->outFilePath . '] created');
         //outFilePath will be the path to the directory in which the images will be saved.
         $outDirPath = $this->outFilePath;
         //imageMagick decides the format of the output file according to the outFilePath's extension.so the format need to be added.
         $this->outFilePath = $this->outFilePath . DIRECTORY_SEPARATOR . basename($this->outFilePath) . self::LEADING_ZEROS_PADDING . '.' . $this->flavorParamsOutput->format;
     } else {
         KalturaLog::debug('failed to create [' . $this->outFilePath . '] directory');
         throw new KOperationEngineException('failed to create [' . $this->outFilePath . '] directory');
     }
     parent::operate($operator, $inFilePath, $configFilePath);
     $imagesListXML = $this->createImagesListXML($outDirPath);
     kFile::setFileContent($outDirPath . DIRECTORY_SEPARATOR . self::IMAGES_LIST_XML_NAME, $imagesListXML->asXML());
     kalturalog::info('images list xml [' . $outDirPath . DIRECTORY_SEPARATOR . self::IMAGES_LIST_XML_NAME . '] created');
 }
 public function operate(kOperator $operator = null, $inFilePath, $configFilePath = null)
 {
     /*
      * The EE3 tends to lock the source file for a short period. Since the same source file might be used 
      * by number of transcoding process, occasionally, one of the transcoding processes gets denied on an 
      * attempt to access the source file. 
      * The code catches the Exceptions thrown by the KOperrationEngine. 
      * On exception caused by the above state - 3 retries are performed w/10sec delay in between.
      * All other exceptions are 're-thrown'.
      *
      * Note: For PHP 5.3 the exception re-throw should be enhanced with 'e->getPrevious()'
      */
     $ex = null;
     for ($iEx = 0; $iEx < 3; $iEx++) {
         try {
             /*
              * Successfull execution attempt
              */
             parent::operate($operator, $inFilePath, $configFilePath);
             return;
         } catch (Exception $e) {
             $ex = $e;
             /* 
              * If there is no log file (to check the error type) 
              * - halt retries and re-through the same exception
              */
             if (file_exists($this->logFilePath) == false) {
                 break;
             }
             //				$usedMsg="Cannot access the file because it is being used by another process";
             $usedMsg = "Cannot access the file because it is being used";
             $logStr = $this->getLogData();
             /* 
              * If the log does not contain the 'being used' error 
              * - halt retries and re-through the same exception
              */
             if (strstr($logStr, $usedMsg) == false) {
                 break;
             }
             $secsToSleep = 10;
             KalturaLog::info("EE3 failed with 'Cannot access the file because it is being used by another process'. Waiting {$secsToSleep} sec. Attempt:{$iEx}");
             sleep($secsToSleep);
         }
     }
     throw new KOperationEngineException($ex->getMessage(), $ex->getCode());
 }
コード例 #9
0
 public function operate(kOperator $operator = null, $inFilePath, $configFilePath = null)
 {
     /*
      * The EE3 tends to lock the source file for a short period. Since the same source file might be used 
      * by number of transcoding process, occasionally, one of the transcoding processes gets denied on an 
      * attempt to access the source file. 
      * The code catches the Exceptions thrown by the KOperrationEngine. 
      * On exception caused by the above state - 3 retries are performed w/10sec delay in between.
      * All other exceptions are 're-thrown'.
      *
      * Note: For PHP 5.3 the exception re-throw should be enhanced with 'e->getPrevious()'
      */
     $ex = null;
     for ($iEx = 0; $iEx < 5; $iEx++) {
         try {
             /*
              * Successfull execution attempt
              */
             return parent::operate($operator, $inFilePath, $configFilePath);
         } catch (Exception $e) {
             $ex = $e;
             $logStr = $this->getLogData();
             /* 
              * 'Progress:100' in the log means that the conversion was completed successfully, 
              * and got hang on exit. An external script will hopefully kill the EE task.
              * If the log contains the 'Progress:100' string, wait 10 sec and retry (up to 3 retries). 
              * Otherwise - halt retries and re-through the same exception
              */
             if (strstr($logStr, "Progress:100") == false) {
                 break;
             }
             $secsToSleep = rand(10, 30);
             KalturaLog::info("EE got hang up. Waiting {$secsToSleep} sec for next attempt. Attempt:{$iEx}");
             sleep($secsToSleep);
         }
     }
     throw new KOperationEngineException($ex->getMessage(), $ex->getCode());
 }
コード例 #10
0
 public function operate(kOperator $operator = null, $inFilePath, $configFilePath = null)
 {
     KalturaLog::debug("document : operator [" . print_r($operator, true) . "] inFilePath [{$inFilePath}]");
     if ($configFilePath) {
         $configFilePath = realpath($configFilePath);
     }
     // bypassing PDF Creator for source PDF files
     $inputExtension = strtolower(pathinfo($inFilePath, PATHINFO_EXTENSION));
     if ($inputExtension == 'pdf' && !$this->flavorParamsOutput->readonly) {
         KalturaLog::notice('Bypassing PDF Creator for source PDF files');
         if (!@copy($inFilePath, $this->outFilePath)) {
             $error = '';
             if (function_exists('error_get_last')) {
                 $error = error_get_last();
             }
             throw new KOperationEngineException('Cannot copy PDF file [' . $this->inFilePath . '] to [' . $this->outFilePath . '] - [' . $error . ']');
         } else {
             // PDF input file copied as is to output file
             return;
         }
     }
     // renaming with unique name to allow conversion 2 conversions of same input file to be done together (PDF+SWF)
     $tmpUniqInFilePath = dirname($inFilePath) . '/' . uniqid() . '_' . basename($inFilePath);
     $realInFilePath = '';
     $uniqueName = false;
     if (@copy($inFilePath, $tmpUniqInFilePath)) {
         $realInFilePath = realpath($tmpUniqInFilePath);
         $uniqueName = true;
     } else {
         KalturaLog::notice('Could not rename input file [' . $inFilePath . '] with a unique name [' . $tmpUniqInFilePath . ']');
         $realInFilePath = realpath($inFilePath);
     }
     parent::operate($operator, $realInFilePath, $configFilePath);
     if ($uniqueName) {
         @unlink($tmpUniqInFilePath);
     }
     //TODO: RENAME - will not be needed once PDFCreator can work with a configurations file
     if ($inputExtension == 'pdf' && $this->flavorParamsOutput->readonly == true) {
         $tmpFile = $this->outFilePath . '.pdf';
     } else {
         $tmpFile = kFile::replaceExt(basename($realInFilePath), 'pdf');
         $tmpFile = dirname($this->outFilePath) . '/' . $tmpFile;
     }
     // sleeping while file not ready, since PDFCreator exists a bit before the file is actually ready
     $sleepTimes = 50;
     $sleepSeconds = 3;
     while (!file_exists(realpath($tmpFile)) && $sleepTimes > 0) {
         sleep($sleepSeconds);
         $sleepTimes--;
         clearstatcache();
     }
     if (!file_exists(realpath($tmpFile))) {
         throw new kTemporaryException('Temp PDF Creator file not found [' . $tmpFile . '] output file [' . $this->outFilePath . ']');
     } else {
         KalturaLog::notice('document temp  found [' . $tmpFile . '] output file [' . $this->outFilePath . ']');
     }
     //TODO: RENAME - will not be needed once PDFCreator can work with a configurations file
     $tmpFile = realpath($tmpFile);
     while (!rename($tmpFile, $this->outFilePath) && $sleepTimes > 0) {
         sleep($sleepSeconds);
         $sleepTimes--;
         clearstatcache();
     }
     if (!file_exists($this->outFilePath)) {
         $error = '';
         if (function_exists('error_get_last')) {
             $error = error_get_last();
         }
         throw new KOperationEngineException('Cannot rename file [' . $tmpFile . '] to [' . $this->outFilePath . '] - [' . $error . ']');
     }
 }
コード例 #11
0
 public function operate(kOperator $operator = null, $inFilePath, $configFilePath = null)
 {
     parent::operate($operator, $inFilePath, $configFilePath);
     //		KalturaLog::info("operator($operator), inFilePath($inFilePath), configFilePath($configFilePath)");
 }
コード例 #12
0
 public function configure(KalturaConvartableJobData $data, KalturaBatchJob $job)
 {
     parent::configure($data, $job);
     $errStr = null;
     if (!KBatchBase::$taskConfig->params->InletArmadaUrl) {
         $errStr = "InletArmadaUrl";
     }
     if (!KBatchBase::$taskConfig->params->InletArmadaLogin) {
         if ($errStr) {
             $errStr .= ",InletArmadaLogin";
         } else {
             $errStr = "InletArmadaLogin";
         }
     }
     if (!KBatchBase::$taskConfig->params->InletArmadaPassword) {
         if ($errStr) {
             $errStr .= ",InletArmadaPassword";
         } else {
             $errStr = "InletArmadaPassword";
         }
     }
     if ($errStr) {
         throw new KOperationEngineException("Inlet failure: missing credentials - {$errStr}");
     }
     //, url(".$taskConfig->params->InletArmadaUrl."), login(."$taskConfig->params->InletArmadaLogin."),passw(".$taskConfig->params->InletArmadaPassword.")");
     /*		
     		$this->url =	$taskConfig->params->InletArmadaUrl;
     		$this->login =	$taskConfig->params->InletArmadaLogin;
     		$this->passw =	$taskConfig->params->InletArmadaPassword;
     		if($taskConfig->params->InletArmadaPriority)
     			$this->prio =	$taskConfig->params->InletArmadaPriority;
     		else
     			$this->prio = 5;
     */
 }
コード例 #13
0
 public function configure(KSchedularTaskConfig $taskConfig, KalturaConvartableJobData $data)
 {
     parent::configure($taskConfig, $data);
     KalturaLog::info("taskConfig-->" . print_r($taskConfig, true) . "\ndata->" . print_r($data, true));
 }
コード例 #14
0
 protected function doOperation()
 {
     $this->validateFormat(self::PDF_FORMAT);
     return parent::doOperation();
 }
コード例 #15
0
 public function operate(kOperator $operator = null, $inFilePath, $configFilePath = null)
 {
     /*
      * Creating unique output folder for nbrPlay/Webex sessions.
      * This is required in order to support concurrent conversion sessions,
      * because the nbrPlay tool generates temp files with the same name.
      * Upon completion move the generated file into the 'regular' outFilePath
      */
     $saveOutPath = $this->outFilePath;
     $path_parts = pathinfo($this->outFilePath);
     $outDir = realpath($path_parts['dirname']);
     /*
      * The temp folder name
      */
     $tempFolder = "{$outDir}/" . $path_parts['basename'] . ".webex_temp_folder";
     $tempOutPath = "{$tempFolder}/" . $path_parts['basename'];
     if (!file_exists($tempFolder)) {
         $oldUmask = umask(00);
         $result = @mkdir($tempFolder, 0777, true);
         umask($oldUmask);
     }
     /*
      * Switch to temp forlder
      */
     $this->outFilePath = $tempOutPath;
     $rv = parent::operate($operator, $inFilePath, $configFilePath);
     /*
      * Restore the original
      */
     if (file_exists($tempOutPath)) {
         $outFilelist = kFile::dirList($tempFolder);
         if (isset($outFilelist) && count($outFilelist) > 0) {
             foreach ($outFilelist as $fileName) {
                 for ($tries = 0; $tries < 5; $tries++) {
                     $toFile = "{$outDir}/" . pathinfo($fileName, PATHINFO_BASENAME);
                     $rv = kFile::moveFile($fileName, $toFile);
                     if (!file_exists($fileName)) {
                         break;
                     }
                     KalturaLog::err("Failed to move ({$fileName}) to ({$toFile})");
                     Sleep(60);
                 }
             }
             Sleep(60);
             rmdir($tempFolder);
         }
     }
     $this->outFilePath = $saveOutPath;
     return $rv;
 }
 protected function getCmdLine()
 {
     $cmdLine = parent::getCmdLine();
     $cmdLine = KConversionEngineFfmpeg::expandForcedKeyframesParams($cmdLine);
     return $cmdLine;
 }
 public function configure(KSchedularTaskConfig $taskConfig, KalturaConvartableJobData $data, KalturaClient $client)
 {
     parent::configure($taskConfig, $data, $client);
     $this->taskConfig = $taskConfig;
     $errStr = null;
     if (!$taskConfig->params->InletArmadaUrl) {
         $errStr = "InletArmadaUrl";
     }
     if (!$taskConfig->params->InletArmadaLogin) {
         if ($errStr) {
             $errStr .= ",InletArmadaLogin";
         } else {
             $errStr = "InletArmadaLogin";
         }
     }
     if (!$taskConfig->params->InletArmadaPassword) {
         if ($errStr) {
             $errStr .= ",InletArmadaPassword";
         } else {
             $errStr = "InletArmadaPassword";
         }
     }
     if ($errStr) {
         throw new KOperationEngineException("Inlet failure: missing credentials - {$errStr}");
     }
     //, url(".$taskConfig->params->InletArmadaUrl."), login(."$taskConfig->params->InletArmadaLogin."),passw(".$taskConfig->params->InletArmadaPassword.")");
     /*		
     		$this->url =	$taskConfig->params->InletArmadaUrl;
     		$this->login =	$taskConfig->params->InletArmadaLogin;
     		$this->passw =	$taskConfig->params->InletArmadaPassword;
     		if($taskConfig->params->InletArmadaPriority)
     			$this->prio =	$taskConfig->params->InletArmadaPriority;
     		else
     			$this->prio = 5;
     */
     KalturaLog::info("taskConfig-->" . print_r($taskConfig, true) . "\ndata->" . print_r($data, true));
 }
コード例 #18
0
 protected function getCmdLine()
 {
     $exeCmd = parent::getCmdLine();
     KalturaLog::info(print_r($this, true));
     return $exeCmd;
 }
 public function configure(KSchedularTaskConfig $taskConfig, KalturaConvartableJobData $data, KalturaClient $client)
 {
     parent::configure($taskConfig, $data, $client);
     $this->data = $data;
     $this->client = $client;
 }
 public function operate(kOperator $operator = null, $inFilePath, $configFilePath = null)
 {
     KalturaLog::debug("document : operator [" . print_r($operator, true) . "] inFilePath [{$inFilePath}]");
     if ($configFilePath) {
         $configFilePath = realpath($configFilePath);
     }
     // bypassing PDF Creator for source PDF files
     $inputExtension = strtolower(pathinfo($inFilePath, PATHINFO_EXTENSION));
     if ($inputExtension == 'pdf' && !$this->flavorParamsOutput->readonly) {
         KalturaLog::notice('Bypassing PDF Creator for source PDF files');
         if (!@copy($inFilePath, $this->outFilePath)) {
             $error = '';
             if (function_exists('error_get_last')) {
                 $error = error_get_last();
             }
             throw new KOperationEngineException('Cannot copy PDF file [' . $this->inFilePath . '] to [' . $this->outFilePath . '] - [' . $error . ']');
         } else {
             // PDF input file copied as is to output file
             return;
         }
     }
     // renaming with unique name to allow conversion 2 conversions of same input file to be done together (PDF+SWF)
     $tmpUniqInFilePath = dirname($inFilePath) . '/' . uniqid() . '_' . basename($inFilePath);
     $realInFilePath = '';
     $uniqueName = false;
     if (@copy($inFilePath, $tmpUniqInFilePath)) {
         $realInFilePath = realpath($tmpUniqInFilePath);
         $uniqueName = true;
     } else {
         KalturaLog::notice('Could not rename input file [' . $inFilePath . '] with a unique name [' . $tmpUniqInFilePath . ']');
         $realInFilePath = realpath($inFilePath);
     }
     $filePrefix = file_get_contents($realInFilePath, false, null, 0, strlen(self::OLD_OFFICE_SIGNATURE));
     $path_info = pathinfo($realInFilePath);
     $ext = $path_info['extension'];
     $newOfficeExtensions = array('pptx', 'docx', 'xlsx');
     $ext = strtolower($ext);
     //checks if $realInFilePath is an old office document with a new extension ('pptx|docx|xlsx')
     //if $realInFilePath is not the fileSync itself ($uniqueName = true) , rename the file by removing the 'x' from the extension.
     if ($uniqueName && in_array($ext, $newOfficeExtensions) && $filePrefix == self::OLD_OFFICE_SIGNATURE) {
         $RealInFilePathWithoutX = substr($realInFilePath, 0, -1);
         if (rename($realInFilePath, $RealInFilePathWithoutX)) {
             KalturaLog::notice("renamed file [{$realInFilePath}] to [{$RealInFilePathWithoutX}]");
             $realInFilePath = $RealInFilePathWithoutX;
         }
     }
     $finalOutputPath = $this->outFilePath;
     if ($inputExtension == 'pdf' && $this->flavorParamsOutput->readonly == true) {
         $tmpFile = $this->outFilePath . '.pdf';
     } else {
         $tmpFile = kFile::replaceExt(basename($realInFilePath), 'pdf');
         $tmpFile = dirname($this->outFilePath) . '/' . $tmpFile;
     }
     $this->outFilePath = $tmpFile;
     parent::operate($operator, $realInFilePath, $configFilePath);
     $this->outFilePath = $finalOutputPath;
     if ($uniqueName) {
         @unlink($tmpUniqInFilePath);
     }
     $sleepTimes = $this->taskConfiguration->fileExistReties;
     if (!$sleepTimes) {
         $sleepTimes = self::DEFAULT_SLEEP_TIMES;
     }
     $sleepSeconds = $this->taskConfiguration->fileExistInterval;
     if (!$sleepSeconds) {
         $sleepSeconds = self::DEFAULT_SLEEP_SECONDS;
     }
     // sleeping while file not ready, since PDFCreator exists a bit before the file is actually ready
     while (!file_exists(realpath($tmpFile)) && $sleepTimes > 0) {
         sleep($sleepSeconds);
         $sleepTimes--;
         clearstatcache();
     }
     if (!file_exists(realpath($tmpFile))) {
         throw new kTemporaryException('Temp PDF Creator file not found [' . $tmpFile . '] output file [' . $this->outFilePath . ']');
     } else {
         KalturaLog::notice('document temp  found [' . $tmpFile . '] output file [' . $this->outFilePath . ']');
     }
     $fileUnlockRetries = $this->taskConfiguration->params->fileUnlockRetries;
     if (!$fileUnlockRetries) {
         $fileUnlockRetries = self::DEFAULT_FILE_UNLOCK_RETRIES;
     }
     $fileUnlockInterval = $this->taskConfiguration->params->fileUnlockInterval;
     if (!$fileUnlockInterval) {
         $fileUnlockInterval = self::DEFAULT_FILE_UNLOCK_INTERVAL;
     }
     $tmpFile = realpath($tmpFile);
     while (!rename($tmpFile, $this->outFilePath) && $fileUnlockRetries > 0) {
         sleep($fileUnlockInterval);
         $fileUnlockRetries--;
         clearstatcache();
     }
     if (!file_exists($this->outFilePath)) {
         $error = '';
         if (function_exists('error_get_last')) {
             $error = error_get_last();
         }
         throw new KOperationEngineException('Cannot rename file [' . $tmpFile . '] to [' . $this->outFilePath . '] - [' . $error . ']');
     }
 }
コード例 #21
0
 public function __construct($cmd, $outFilePath)
 {
     parent::__construct($cmd, $outFilePath);
 }