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


PHP Utils::sendErrMailReport方法代码示例

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


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

示例1: doAction

 /**
  * When Called it perform the controller action to retrieve/manipulate data
  *
  * @return mixed
  */
 function doAction()
 {
     if (count($this->errors) > 0) {
         return null;
     }
     //get job language and data
     //Fixed Bug: need a specific job, because we need The target Language
     //Removed from within the foreach cycle, the job is always the same...
     $jobData = $this->jobInfo = getJobData($this->jobID, $this->jobPass);
     $pCheck = new AjaxPasswordCheck();
     //check for Password correctness
     if (empty($jobData) || !$pCheck->grantJobAccessByJobData($jobData, $this->jobPass)) {
         $msg = "Error : wrong password provided for download \n\n " . var_export($_POST, true) . "\n";
         Log::doLog($msg);
         Utils::sendErrMailReport($msg);
         return null;
     }
     $projectData = getProject($jobData['id_project']);
     $source = $jobData['source'];
     $target = $jobData['target'];
     $tmsService = new TMSService();
     /**
      * @var $tmx SplTempFileObject
      */
     $this->tmx = $tmsService->exportJobAsTMX($this->jobID, $this->jobPass, $source, $target);
     $this->fileName = $projectData[0]['name'] . "-" . $this->jobID . ".tmx";
 }
开发者ID:reysub,项目名称:MateCat,代码行数:32,代码来源:exportTMXController.php

示例2: doAction

 public function doAction()
 {
     if (empty($this->segment)) {
         $this->result['errors'][] = array("code" => -1, "message" => "missing source segment");
     }
     if (empty($this->translation)) {
         $this->result['errors'][] = array("code" => -2, "message" => "missing target translation");
     }
     if (empty($this->source_lang)) {
         $this->result['errors'][] = array("code" => -3, "message" => "missing source lang");
     }
     if (empty($this->target_lang)) {
         $this->result['errors'][] = array("code" => -4, "message" => "missing target lang");
     }
     if (empty($this->time_to_edit)) {
         $this->result['errors'][] = array("code" => -5, "message" => "missing time to edit");
     }
     if (empty($this->id_segment)) {
         $this->result['errors'][] = array("code" => -6, "message" => "missing segment id");
     }
     //get Job Infos, we need only a row of jobs ( split )
     $job_data = getJobData((int) $this->id_job, $this->password);
     $pCheck = new AjaxPasswordCheck();
     //check for Password correctness
     if (empty($job_data) || !$pCheck->grantJobAccessByJobData($job_data, $this->password)) {
         $this->result['errors'][] = array("code" => -10, "message" => "wrong password");
         $msg = "\n\n Error \n\n " . var_export(array_merge($this->result, $_POST), true);
         Log::doLog($msg);
         Utils::sendErrMailReport($msg);
         return;
     }
     //mt engine to contribute to
     if ($job_data['id_mt_engine'] <= 1) {
         return false;
     }
     $this->mt = Engine::getInstance($job_data['id_mt_engine']);
     //array of storicised suggestions for current segment
     $this->suggestion_json_array = json_decode(getArrayOfSuggestionsJSON($this->id_segment), true);
     //extra parameters
     $extra = json_encode(array('id_segment' => $this->id_segment, 'suggestion_json_array' => $this->suggestion_json_array, 'chosen_suggestion_index' => $this->chosen_suggestion_index, 'time_to_edit' => $this->time_to_edit));
     //send stuff
     $config = $this->mt->getConfigStruct();
     $config['segment'] = CatUtils::view2rawxliff($this->segment);
     $config['translation'] = CatUtils::view2rawxliff($this->translation);
     $config['source'] = $this->source_lang;
     $config['target'] = $this->target_lang;
     $config['email'] = INIT::$MYMEMORY_API_KEY;
     $config['segid'] = $this->id_segment;
     $config['extra'] = $extra;
     $config['id_user'] = array("TESTKEY");
     $outcome = $this->mt->set($config);
     if ($outcome->error->code < 0) {
         $this->result['errors'] = $outcome->error->get_as_array();
     }
 }
开发者ID:indynagpal,项目名称:MateCat,代码行数:55,代码来源:setContributionMTController.php

示例3: doAction

 /**
  * When Called it perform the controller action to retrieve/manipulate data
  *
  * @return mixed
  */
 function doAction()
 {
     try {
         $this->_checkData("auto_propagation.log");
     } catch (Exception $e) {
         if ($e->getCode() == -1) {
             Utils::sendErrMailReport($e->getMessage());
         }
         Log::doLog($e->getMessage());
         return $e->getCode();
     }
     $cookie_key = '_auto-propagation-' . $this->id_job . "-" . $this->password;
     $boolString = (string) (int) $this->propagateAll;
     $cookieLife = new DateTime();
     $cookieLife->modify('+15 days');
     $db = Database::obtain();
     if ($this->propagateAll) {
         $db->begin();
         $old_translation = getCurrentTranslation($this->id_job, $this->id_segment);
         //check tag mismatch
         //get original source segment, first
         $segment = getSegment($this->id_segment);
         //compare segment-translation and get results
         $check = new QA($segment['segment'], $this->translation);
         $check->performConsistencyCheck();
         if ($check->thereAreWarnings()) {
             $err_json = $check->getWarningsJSON();
             $translation = $this->translation;
         } else {
             $err_json = '';
             $translation = $check->getTrgNormalized();
         }
         $TPropagation = array();
         $TPropagation['id_job'] = $this->id_job;
         $TPropagation['translation'] = $translation;
         $TPropagation['status'] = Constants_TranslationStatus::STATUS_DRAFT;
         $TPropagation['autopropagated_from'] = $this->id_segment;
         $_Translation['serialized_errors_list'] = $err_json;
         $TPropagation['warning'] = $check->thereAreWarnings();
         $TPropagation['translation_date'] = date("Y-m-d H:i:s");
         $TPropagation['segment_hash'] = $old_translation['segment_hash'];
         try {
             propagateTranslation($TPropagation, $this->jobData, $this->id_segment, true);
             $db->commit();
         } catch (Exception $e) {
             $db->rollback();
             $msg = $e->getMessage() . "\n\n" . $e->getTraceAsString();
             Log::doLog($msg);
             Utils::sendErrMailReport($msg);
         }
     }
     setcookie($cookie_key, $boolString, $cookieLife->getTimestamp(), "/", $_SERVER['HTTP_HOST']);
     Log::doLog("Auto-propagation for already translated segments on Job " . $this->id_job . " set to '" . var_export($this->propagateAll, true) . "'. Cookie Expire at " . $cookieLife->format('Y-m-d H:i:s'));
     $this->result['errors'][] = array("code" => 0, "message" => "OK");
 }
开发者ID:kevinvnloctra,项目名称:MateCat,代码行数:60,代码来源:setAutoPropagationController.php

示例4: doAction

 /**
  * When Called it perform the controller action to retrieve/manipulate data
  *
  * @return mixed
  */
 function doAction()
 {
     $_project_data = getProjectJobData($this->id_project);
     $pCheck = new AjaxPasswordCheck();
     $access = $pCheck->grantProjectAccess($_project_data, $this->password);
     //check for Password correctness
     if (!$access) {
         $msg = "Error : wrong password provided for download \n\n " . var_export($_POST, true) . "\n";
         Log::doLog($msg);
         Utils::sendErrMailReport($msg);
         return null;
     }
     $analysisStatus = new Analysis_XTRFStatus($_project_data);
     $outputContent = $analysisStatus->fetchData()->getResult();
     $this->content = $this->composeZip($_project_data[0]['pname'], $outputContent);
     $this->_filename = $_project_data[0]['pname'] . ".zip";
 }
开发者ID:reysub,项目名称:MateCat,代码行数:22,代码来源:downloadAnalysisReportController.php

示例5: insertFastAnalysis

function insertFastAnalysis($pid, &$fastReport, $equivalentWordMapping, $perform_Tms_Analysis = true)
{
    $db = Database::obtain();
    $data = array();
    $amqHandler = new Analysis_QueueHandler();
    $total_eq_wc = 0;
    $total_standard_wc = 0;
    $data['id_segment'] = null;
    $data['id_job'] = null;
    $data['segment_hash'] = null;
    $data['match_type'] = null;
    $data['eq_word_count'] = null;
    $data['standard_word_count'] = null;
    $segment_translations = "INSERT INTO `segment_translations` ( " . implode(", ", array_keys($data)) . " ) VALUES ";
    $st_values = array();
    foreach ($fastReport as $k => $v) {
        $jid_fid = explode("-", $k);
        $id_segment = $jid_fid[0];
        $list_id_jobs_password = $jid_fid[1];
        if (array_key_exists($v['match_type'], $equivalentWordMapping)) {
            $eq_word = $v['wc'] * $equivalentWordMapping[$v['match_type']] / 100;
            if ($v['match_type'] == "INTERNAL") {
            }
        } else {
            $eq_word = $v['wc'];
        }
        $total_eq_wc += $eq_word;
        $standard_words = $eq_word;
        if ($v['match_type'] == "INTERNAL" or $v['match_type'] == "MT") {
            $standard_words = $v['wc'] * $equivalentWordMapping["NO_MATCH"] / 100;
        }
        $total_standard_wc += $standard_words;
        unset($fastReport[$k]['wc']);
        $list_id_jobs_password = explode(',', $list_id_jobs_password);
        foreach ($list_id_jobs_password as $id_job) {
            list($id_job, $job_pass) = explode(":", $id_job);
            $data['id_job'] = (int) $id_job;
            $data['id_segment'] = (int) $fastReport[$k]['id_segment'];
            $data['segment_hash'] = $db->escape($v['segment_hash']);
            $data['match_type'] = $db->escape($v['match_type']);
            if (!empty($v['segment_hash']) && empty($data['segment_hash'])) {
                $data['segment_hash'] = $v['segment_hash'];
                $msg = "mysql_real_escape_string failed!!! String was empty. Replaced with original {$v['segment_hash']}";
                _TimeStampMsg($msg);
                Utils::sendErrMailReport("<strong>{$msg}</strong>", "Fast Analysis mysql_real_escape_string failed.");
            }
            $data['eq_word_count'] = (double) $eq_word;
            $data['standard_word_count'] = (double) $standard_words;
            $st_values[] = " ( '" . implode("', '", array_values($data)) . "' )";
            if ($data['eq_word_count'] > 0 && $perform_Tms_Analysis) {
                /**
                 *
                 * IMPORTANT
                 * id_job will be taken from languages ( 80415:fr-FR,80416:it-IT )
                 */
                $fastReport[$k]['pid'] = (int) $pid;
                $fastReport[$k]['date_insert'] = date_create()->format('Y-m-d H:i:s');
                $fastReport[$k]['eq_word_count'] = (double) $eq_word;
                $fastReport[$k]['standard_word_count'] = (double) $standard_words;
            } else {
                //                Log::doLog( 'Skipped Fast Segment: ' . var_export( $fastReport[ $k ], true ) );
                unset($fastReport[$k]);
            }
        }
    }
    unset($data);
    $chunks_st = array_chunk($st_values, 200);
    _TimeStampMsg('Insert Segment Translations: ' . count($st_values));
    _TimeStampMsg('Queries: ' . count($chunks_st));
    //USE the MySQL InnoDB isolation Level to protect from thread high concurrency access
    $db->query('SET autocommit=0');
    $db->query('START TRANSACTION');
    foreach ($chunks_st as $k => $chunk) {
        $query_st = $segment_translations . implode(", ", $chunk) . " ON DUPLICATE KEY UPDATE\n            match_type = VALUES( match_type ),\n                       eq_word_count = VALUES( eq_word_count ),\n                       standard_word_count = VALUES( standard_word_count )\n                           ";
        $db->query($query_st);
        _TimeStampMsg("Executed " . ($k + 1));
        $err = $db->get_error();
        if ($err['error_code'] != 0) {
            _TimeStampMsg($err);
            return $err['error_code'] * -1;
        }
    }
    _TimeStampMsg("Memory: " . memory_get_usage(true) / (1024 * 1024) . "MB");
    unset($st_values);
    unset($chunks_st);
    _TimeStampMsg("Memory: " . memory_get_usage(true) / (1024 * 1024) . "MB");
    /*
     * IF NO TM ANALYSIS, upload the jobs global word count
     */
    if (!$perform_Tms_Analysis) {
        $_details = getProjectSegmentsTranslationSummary($pid);
        _TimeStampMsg("--- trying to initialize job total word count.");
        $project_details = array_pop($_details);
        //remove rollup
        foreach ($_details as $job_info) {
            $counter = new WordCount_Counter();
            $counter->initializeJobWordCount($job_info['id_job'], $job_info['password']);
        }
    }
    /* IF NO TM ANALYSIS, upload the jobs global word count */
//.........这里部分代码省略.........
开发者ID:Bullettoothtobi,项目名称:MateCat,代码行数:101,代码来源:fastAnalysis.php

示例6: doAction

 /**
  * When Called it perform the controller action to retrieve/manipulate data
  *
  * @throws Exception
  */
 public function doAction()
 {
     if (!empty($this->result['errors'])) {
         return;
     }
     $job_data = getJobData((int) $this->id_job, $this->password_job);
     if (empty($job_data)) {
         $msg = "Error : empty job data \n\n " . var_export($_POST, true) . "\n";
         Log::doLog($msg);
         Utils::sendErrMailReport($msg);
     }
     //add check for job status archived.
     if (strtolower($job_data['status']) == Constants_JobStatus::STATUS_ARCHIVED) {
         $this->result['errors'][] = array("code" => -6, "message" => "job archived");
     }
     $this->parseIDSegment();
     $pCheck = new AjaxPasswordCheck();
     //check for Password correctness
     if (empty($job_data) || !$pCheck->grantJobAccessByJobData($job_data, $this->password_job, $this->id_segment)) {
         $this->result['errors'][] = array("code" => -7, "message" => "wrong password");
     }
     $wStruct = new WordCount_Struct();
     $wStruct->setIdJob($this->id_job);
     $wStruct->setJobPassword($this->password_job);
     $wStruct->setNewWords($job_data['new_words']);
     $wStruct->setDraftWords($job_data['draft_words']);
     $wStruct->setTranslatedWords($job_data['translated_words']);
     $wStruct->setApprovedWords($job_data['approved_words']);
     $wStruct->setRejectedWords($job_data['rejected_words']);
     $reviseDAO = new Revise_ReviseDAO(Database::obtain());
     //store segment revision in DB
     $revisionStruct = Revise_ReviseStruct::getStruct();
     $revisionStruct->id_job = $this->id_job;
     $revisionStruct->id_segment = $this->id_segment;
     //check if an old revision exists. If it does, retrieve it and save it.
     $oldRevision = $reviseDAO->read($revisionStruct);
     $oldRevision = isset($oldRevision[0]) ? $oldRevision[0] : Revise_ReviseStruct::setDefaultValues(Revise_ReviseStruct::getStruct());
     $revisionStruct->err_typing = $this->err_typing;
     $revisionStruct->err_translation = $this->err_translation;
     $revisionStruct->err_terminology = $this->err_terminology;
     $revisionStruct->err_language = $this->err_language;
     $revisionStruct->err_style = $this->err_style;
     $revisionStruct->original_translation = $this->original_translation;
     //save the new revision in the database.
     try {
         $reviseDAO->create($revisionStruct);
     } catch (Exception $e) {
         Log::doLog(__METHOD__ . " -> " . $e->getMessage());
         $this->result['errors'][] = array('code' => -4, 'message' => "Insert failed");
         return;
     }
     /**
      * Refresh error counters in the job table
      */
     $errorCountStruct = new ErrorCount_DiffStruct($oldRevision, $revisionStruct);
     $errorCountStruct->setIdJob($this->id_job);
     $errorCountStruct->setJobPassword($this->password_job);
     $errorCountDao = new ErrorCount_ErrorCountDAO(Database::obtain());
     try {
         $errorCountDao->update($errorCountStruct);
     } catch (Exception $e) {
         Log::doLog(__METHOD__ . " -> " . $e->getMessage());
         $this->result['errors'][] = array('code' => -5, 'message' => "Did not update job error counters.");
         return;
     }
     /**
      * Retrieve information about job errors
      * ( Note: these information are fed by the revision process )
      * @see setRevisionController
      */
     $jobQA = new Revise_JobQA($this->id_job, $this->password_job, $wStruct->getTotal());
     $jobQA->retrieveJobErrorTotals();
     $jobVote = $jobQA->evalJobVote();
     $this->result['data']['message'] = 'OK';
     $this->result['data']['stat_quality'] = $jobQA->getQaData();
     $this->result['data']['overall_quality'] = $jobVote['minText'];
     $this->result['data']['overall_quality_class'] = strtolower(str_replace(' ', '', $jobVote['minText']));
 }
开发者ID:indynagpal,项目名称:MateCat,代码行数:83,代码来源:setRevisionController.php

示例7: __notifyError

 private function __notifyError($conversionObject)
 {
     $remote_user = isset($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'] : "N/A";
     $link_file = "http://" . $_SERVER['SERVER_NAME'] . "/" . INIT::$CONVERSIONERRORS_REPOSITORY_WEB . "/" . $_COOKIE['upload_session'] . "/" . rawurlencode($conversionObject->file_name);
     $message = "MATECAT : conversion error notifier\n\nDetails:\n\t\t\t- machine_ip : " . $conversionObject->ip_machine . "\n\t\t\t- client ip :  " . $conversionObject->ip_client . "\n\t\t\t- source :     " . $conversionObject->src_lang . "\n\t\t\t- target :     " . $conversionObject->trg_lang . "\n\t\t\t- client user (if any used) : {$remote_user}\n\t\t\t\t\t\t\t\t\t\t   - direction : " . $conversionObject->direction . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t- error : " . $conversionObject->error_message . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  Download file clicking to {$link_file}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  ";
     Utils::sendErrMailReport($message);
 }
开发者ID:kevinvnloctra,项目名称:MateCat,代码行数:7,代码来源:FileFormatConverter.php

示例8: doAction

 public function doAction()
 {
     $debug = array();
     $debug['total'][] = time();
     //get job language and data
     //Fixed Bug: need a specific job, because we need The target Language
     //Removed from within the foreach cycle, the job is always the same....
     $jobData = $this->jobInfo = getJobData($this->id_job, $this->password);
     $pCheck = new AjaxPasswordCheck();
     //check for Password correctness
     if (empty($jobData) || !$pCheck->grantJobAccessByJobData($jobData, $this->password)) {
         $msg = "Error : wrong password provided for download \n\n " . var_export($_POST, true) . "\n";
         Log::doLog($msg);
         Utils::sendErrMailReport($msg);
         return null;
     }
     $debug['get_file'][] = time();
     $files_job = getFilesForJob($this->id_job, $this->id_file);
     $debug['get_file'][] = time();
     $nonew = 0;
     $output_content = array();
     /*
      * the procedure is now as follows:
      * 1)original file is loaded from DB into RAM and the flushed in a temp file on disk; a file handler is obtained
      * 2)RAM gets freed from original content
      * 3)the file is read chunk by chunk by a stream parser: for each tran-unit that is encountered,
      *     target is replaced (or added) with the corresponding translation among segments
      *     the current string in the buffer is flushed on standard output
      * 4)the temporary file is deleted by another process after some time
      *
      */
     //file array is chuncked. Each chunk will be used for a parallel conversion request.
     $files_job = array_chunk($files_job, self::FILES_CHUNK_SIZE);
     foreach ($files_job as $chunk) {
         $converter = new FileFormatConverter();
         $files_buffer = array();
         foreach ($chunk as $file) {
             $mime_type = $file['mime_type'];
             $fileID = $file['id_file'];
             $current_filename = $file['filename'];
             $original_xliff = $file['xliff_file'];
             //get path
             $path = INIT::$TMP_DOWNLOAD . '/' . $this->id_job . '/' . $fileID . '/' . $current_filename . "_" . uniqid('', true) . '.sdlxliff';
             //make dir if doesn't exist
             if (!file_exists(dirname($path))) {
                 Log::doLog('exec ("chmod 666 ' . escapeshellarg($path) . '");');
                 mkdir(dirname($path), 0777, true);
                 exec("chmod 666 " . escapeshellarg($path));
             }
             //create file
             $fp = fopen($path, 'w+');
             //flush file to disk
             fwrite($fp, $original_xliff);
             //free memory, as we can work with file on disk now
             unset($original_xliff);
             $debug['get_segments'][] = time();
             $data = getSegmentsDownload($this->id_job, $this->password, $fileID, $nonew);
             $debug['get_segments'][] = time();
             //create a secondary indexing mechanism on segments' array; this will be useful
             //prepend a string so non-trans unit id ( ex: numerical ) are not overwritten
             //clean also not valid xml entities ( charactes with ascii < 32 and different from 0A, 0D and 09
             $regexpEntity = '/&#x(0[0-8BCEF]|1[0-9A-F]|7F);/u';
             //remove binary chars in some xliff files
             $regexpAscii = '/([\\x{00}-\\x{1F}\\x{7F}]{1})/u';
             foreach ($data as $i => $k) {
                 $data['matecat|' . $k['internal_id']][] = $i;
                 //FIXME: temporary patch
                 $data[$i]['translation'] = str_replace('<x id="nbsp"/>', '&#xA0;', $data[$i]['translation']);
                 $data[$i]['segment'] = str_replace('<x id="nbsp"/>', '&#xA0;', $data[$i]['segment']);
                 $sanitized_src = preg_replace($regexpAscii, '', $data[$i]['segment']);
                 $sanitized_trg = preg_replace($regexpAscii, '', $data[$i]['translation']);
                 $sanitized_src = preg_replace($regexpEntity, '', $sanitized_src);
                 $sanitized_trg = preg_replace($regexpEntity, '', $sanitized_trg);
                 if ($sanitized_src != null) {
                     $data[$i]['segment'] = $sanitized_src;
                 }
                 if ($sanitized_trg != null) {
                     $data[$i]['translation'] = $sanitized_trg;
                 }
             }
             $debug['replace'][] = time();
             //instatiate parser
             $xsp = new XliffSAXTranslationReplacer($path, $data, Langs_Languages::getInstance()->getLangRegionCode($jobData['target']), $fp);
             if ($this->download_type == 'omegat') {
                 $xsp->setSourceInTarget(true);
             }
             //run parsing
             Log::doLog("work on " . $fileID . " " . $current_filename);
             $xsp->replaceTranslation();
             fclose($fp);
             unset($xsp);
             $debug['replace'][] = time();
             $output_xliff = file_get_contents($path . '.out.sdlxliff');
             $output_content[$fileID]['documentContent'] = $output_xliff;
             $output_content[$fileID]['filename'] = $current_filename;
             unset($output_xliff);
             if ($this->forceXliff) {
                 $file_info_details = pathinfo($output_content[$fileID]['filename']);
                 $output_content[$fileID]['filename'] = $file_info_details['filename'] . ".out.sdlxliff";
             }
//.........这里部分代码省略.........
开发者ID:kevinvnloctra,项目名称:MateCat,代码行数:101,代码来源:downloadFileController.php

示例9: main

 function main($args = null)
 {
     $db = Database::obtain();
     $lastProcessedJob = (int) file_get_contents(self::$last_job_file_name);
     do {
         $queryMaxJob = "select min(id) as min, max(id) as max\n                            from jobs\n                            where completed = 1\n                            and id > %d";
         $queryFirst = "select id, password, job_first_segment, job_last_segment\n                            from jobs\n                            where completed = 1\n                            and id >= %d and id <= %d";
         $querySegments = "select suggestion,\n                         translation,\n                         raw_word_count,\n                         time_to_edit\n                         from segment_translations st\n                         join segments s on st.id_segment = s.id\n                            and s.id between %d and %d\n                         where status='translated'\n                         and id_job = %d\n                         and show_in_cattool = 1\n                         and id_segment >= %d\n                         limit %d";
         $queryUpdateJob = "update jobs\n                                set avg_post_editing_effort = %f,\n                                total_time_to_edit = %f,\n                                total_raw_wc = %d\n                                where id = %d and password = '%s'";
         $minJobMaxJob = $db->query_first(sprintf($queryMaxJob, (int) $lastProcessedJob));
         $maxJob = (int) $minJobMaxJob['max'];
         $minJob = (int) $minJobMaxJob['min'];
         $start = time();
         //get a chunk of self::NR_OF_JOBS each time.
         for ($firstJob = $minJob; $this->RUNNING && $firstJob < $maxJob; $firstJob += self::NR_OF_JOBS) {
             $jobs = $db->fetch_array(sprintf($queryFirst, $firstJob, $firstJob + self::NR_OF_JOBS));
             //iterate over completed jobs, evaluate incremental PEE and save it in the job row
             //Incremental PEE = sum( segment_pee * segment_raw_wordcount)
             //It will be normalized when necessary
             for ($j = 0; $this->RUNNING && $j < count($jobs); $j++) {
                 $job = $jobs[$j];
                 //BEGIN TRANSACTION
                 $db->begin();
                 $_jid = $job['id'];
                 $_password = $job['password'];
                 $_job_first_segment = $job['job_first_segment'];
                 $_job_last_segment = $job['job_last_segment'];
                 Log::doLog("job {$_jid} -> " . ($_job_last_segment - $_job_first_segment) . " segments");
                 echo "job {$_jid} -> " . ($_job_last_segment - $_job_first_segment) . " segments\n";
                 $raw_post_editing_effort_job = 0;
                 $raw_wc_job = 0;
                 $time_to_edit_job = 0;
                 //get a chunk of self::NR_OF_SEGS segments each time.
                 for ($firstSeg = $_job_first_segment; $firstSeg <= $_job_last_segment; $firstSeg += self::NR_OF_SEGS) {
                     if ($firstSeg > $_job_last_segment) {
                         $firstSeg = $_job_last_segment;
                     }
                     Log::doLog("starting from segment {$firstSeg}");
                     echo "starting from segment {$firstSeg}\n";
                     $segments = $db->fetch_array(sprintf($querySegments, $_job_first_segment, $_job_last_segment, $_jid, $firstSeg, self::NR_OF_SEGS));
                     //iterate over segments.
                     foreach ($segments as $i => $segment) {
                         $segment = new EditLog_EditLogSegmentStruct($segment);
                         $raw_wc_job += $segment->raw_word_count;
                         $time_to_edit_job += $segment->time_to_edit;
                         if ($segment->isValidForEditLog()) {
                             $raw_post_editing_effort_job += $segment->getPEE() * $segment->raw_word_count;
                         }
                     }
                     //sleep 100 nanosecs
                     usleep(100);
                 }
                 $job_incremental_pee = $raw_post_editing_effort_job;
                 Log::doLog("job pee: {$job_incremental_pee}\njob time to edit: {$time_to_edit_job}\njob total wc:{$raw_wc_job}\nWriting into DB");
                 echo "job pee: {$job_incremental_pee}\njob time to edit: {$time_to_edit_job}\njob total wc:{$raw_wc_job}\nWriting into DB\n";
                 $db->query(sprintf($queryUpdateJob, $job_incremental_pee, $time_to_edit_job, $raw_wc_job, $_jid, $_password));
                 Log::doLog("done");
                 echo "done.\n";
                 if (!file_put_contents(self::$last_job_file_name, $_jid)) {
                     $db->rollback();
                     Utils::sendErrMailReport("", "[JobPostEditingEffortRunner] Failed to process job {$_jid}");
                     $this->RUNNING = false;
                     continue;
                     //exit;
                 }
                 //COMMIT TRANSACTION
                 $db->commit();
             }
         }
         Log::doLog("took " . (time() - $start) / 60 . " seconds");
         echo "took " . (time() - $start) / 60 . " seconds\n";
         Log::doLog("sleeping for 1 month");
         echo "sleeping for 1 month\n";
         if ($this->RUNNING) {
             sleep(self::$sleeptime);
         }
     } while ($this->RUNNING);
 }
开发者ID:bcrazvan,项目名称:MateCat,代码行数:78,代码来源:JobPEEAndTimeToEditRunner.php

示例10: _checkForRebootFailed

 /**
  * This check for reboot status, if it is at least the third check failed after a reboot command,
  * it return a failure
  *
  * @param $ip_converter
  *
  * @return mixed
  */
 protected function _checkForRebootFailed($ip_converter)
 {
     $selectLogs_afterLastUpdate = sprintf(self::selectLogs_afterLastUpdate, $this->resultSet[$ip_converter]['id'], $this->resultSet[$ip_converter]['last_update']);
     $failedConversionsAfterRebootLogs = $this->db->fetch_array($selectLogs_afterLastUpdate);
     //if there are failed conversions test after the reboot time ( long reboot )
     if (count($failedConversionsAfterRebootLogs) != 0) {
         $rebootTime = new DateTime($this->resultSet[$ip_converter]['last_update']);
         $thisTimeFailure = new DateTime();
         //if this failure happened 10 minutes after reboot time
         if ($thisTimeFailure->modify('-10 minutes') >= $rebootTime) {
             self::_prettyEcho("> *** FAILED REBOOT FOUND....", 4);
             $msg = "\n\n *** FAILED REBOOT STATUS FOUND FOR CONVERTER {$ip_converter} -> " . $this->host_machine_map[$ip_converter]['instance_name'] . "\n         - instance_name:   " . $this->host_machine_map[$ip_converter]['instance_name'] . "\n         - ip_machine_host: " . $this->host_machine_map[$ip_converter]['ip_machine_host'] . "\n" . "\n" . "\n *** WARNING: THIS MACHINE IS SET AS OFFLINE, WILL NEVER PUT BACK IN POOL ***";
             //send Alert report
             Utils::sendErrMailReport($msg);
             self::_prettyEcho("> *** MESSAGE SENT....", 4);
             $this->resultSet[$ip_converter]['status_active'] = 0;
             $this->resultSet[$ip_converter]['status_reboot'] = 0;
             $this->resultSet[$ip_converter]['status_offline'] = 1;
             $this->db->update('converters', $this->resultSet[$ip_converter], " ip_converter = '{$ip_converter}' LIMIT 1");
             return $ip_converter;
         }
     }
 }
开发者ID:indynagpal,项目名称:MateCat,代码行数:31,代码来源:check_converter_by_file_content.php

示例11: doAction

 /**
  * When Called it perform the controller action to retrieve/manipulate data
  *
  * @return mixed
  */
 function doAction()
 {
     Utils::sendErrMailReport($this->error_mail_content);
     //echo $this->error_mail_content;exit;
     parent::makeTemplate("badConfiguration.html");
 }
开发者ID:indynagpal,项目名称:MateCat,代码行数:11,代码来源:badConfigurationController.php

示例12: doAction

 public function doAction()
 {
     $uploadFile = new Upload();
     try {
         $stdResult = $uploadFile->uploadFiles($_FILES);
     } catch (Exception $e) {
         $stdResult = array();
         $this->result = array('errors' => array(array("code" => -1, "message" => $e->getMessage())));
         $this->api_output['message'] = $e->getMessage();
     }
     $arFiles = array();
     foreach ($stdResult as $input_name => $input_value) {
         $arFiles[] = $input_value->name;
     }
     //if fileupload was failed this index ( 0 = does not exists )
     $default_project_name = @$arFiles[0];
     if (count($arFiles) > 1) {
         $default_project_name = "MATECAT_PROJ-" . date("Ymdhi");
     }
     if (empty($this->project_name)) {
         $this->project_name = $default_project_name;
         //'NO_NAME'.$this->create_project_name();
     }
     if (empty($this->source_lang)) {
         $this->api_output['message'] = "Missing source language.";
         $this->result['errors'][] = array("code" => -3, "message" => "Missing source language.");
     }
     if (empty($this->target_lang)) {
         $this->api_output['message'] = "Missing target language.";
         $this->result['errors'][] = array("code" => -4, "message" => "Missing target language.");
     }
     //ONE OR MORE ERRORS OCCURRED : EXITING
     //for now we sent to api output only the LAST error message, but we log all
     if (!empty($this->result['errors'])) {
         $msg = "Error \n\n " . var_export(array_merge($this->result, $_POST), true);
         Log::doLog($msg);
         Utils::sendErrMailReport($msg);
         return -1;
         //exit code
     }
     /* Do conversions here */
     $converter = new ConvertFileWrapper($stdResult);
     $converter->intDir = $uploadFile->getUploadPath();
     $converter->errDir = INIT::$CONVERSIONERRORS_REPOSITORY . DIRECTORY_SEPARATOR . $uploadFile->getDirUploadToken();
     $converter->cookieDir = $uploadFile->getDirUploadToken();
     $converter->source_lang = $this->source_lang;
     $converter->target_lang = $this->target_lang;
     $converter->doAction();
     $status = $converter->checkResult();
     if (!empty($status)) {
         $this->api_output['message'] = 'Project Conversion Failure';
         $this->api_output['debug'] = $status;
         $this->result['errors'] = $status;
         Log::doLog($status);
         return -1;
     }
     /* Do conversions here */
     $projectManager = new ProjectManager();
     $projectStructure = $projectManager->getProjectStructure();
     $projectStructure['project_name'] = $this->project_name;
     $projectStructure['result'] = $this->result;
     $projectStructure['private_tm_key'] = $this->private_tm_key;
     $projectStructure['private_tm_user'] = $this->private_tm_user;
     $projectStructure['private_tm_pass'] = $this->private_tm_pass;
     $projectStructure['uploadToken'] = $uploadFile->getDirUploadToken();
     $projectStructure['array_files'] = $arFiles;
     //list of file name
     $projectStructure['source_language'] = $this->source_lang;
     $projectStructure['target_language'] = explode(',', $this->target_lang);
     $projectStructure['mt_engine'] = $this->mt_engine;
     $projectStructure['tms_engine'] = $this->tms_engine;
     $projectStructure['status'] = Constants_ProjectStatus::STATUS_NOT_READY_FOR_ANALYSIS;
     $projectStructure['skip_lang_validation'] = true;
     $projectManager = new ProjectManager($projectStructure);
     $projectManager->createProject();
     $this->result = $projectStructure['result'];
     if (!empty($projectStructure['result']['errors'])) {
         //errors already logged
         $this->api_output['message'] = 'Project Creation Failure';
         $this->api_output['debug'] = $projectStructure['result']['errors'];
     } else {
         //everything ok
         $this->api_output['status'] = 'OK';
         $this->api_output['message'] = 'Success';
         $this->api_output['id_project'] = $projectStructure['result']['id_project'];
         $this->api_output['project_pass'] = $projectStructure['result']['ppassword'];
     }
 }
开发者ID:reysub,项目名称:MateCat,代码行数:88,代码来源:NewController.php

示例13: doAction

 public function doAction()
 {
     try {
         $this->_checkData();
     } catch (Exception $e) {
         if ($e->getCode() == -1) {
             Utils::sendErrMailReport($e->getMessage());
         }
         Log::doLog($e->getMessage());
         return $e->getCode();
     }
     //check tag mismatch
     //get original source segment, first
     $segment = getSegment($this->id_segment);
     //compare segment-translation and get results
     $check = new QA($segment['segment'], $this->translation);
     $check->performConsistencyCheck();
     if ($check->thereAreWarnings()) {
         $err_json = $check->getWarningsJSON();
         $translation = $this->translation;
     } else {
         $err_json = '';
         $translation = $check->getTrgNormalized();
     }
     /*
      * begin stats counter
      *
      * It works good with default InnoDB Isolation level
      *
      * REPEATABLE-READ offering a row level lock for this id_segment
      *
      */
     $db = Database::obtain();
     $db->begin();
     $old_translation = getCurrentTranslation($this->id_job, $this->id_segment);
     //        $old_version = ( empty( $old_translation['translation_date'] ) ? '0' : date_create( $old_translation['translation_date'] )->getTimestamp() );
     //        if( $this->client_target_version != $old_version ){
     //            $this->result[ 'errors' ][ ] = array( "code" => -102, "message" => "Translation version mismatch" );
     //            $db->rollback();
     //            return false;
     //        }
     //if volume analysis is not enabled and no translation rows exists
     //create the row
     if (!INIT::$VOLUME_ANALYSIS_ENABLED && empty($old_translation['status'])) {
         $_Translation = array();
         $_Translation['id_segment'] = (int) $this->id_segment;
         $_Translation['id_job'] = (int) $this->id_job;
         $_Translation['status'] = Constants_TranslationStatus::STATUS_NEW;
         $_Translation['segment_hash'] = $segment['segment_hash'];
         $_Translation['translation'] = $segment['segment'];
         $_Translation['standard_word_count'] = $segment['raw_word_count'];
         $_Translation['serialized_errors_list'] = '';
         $_Translation['suggestion_position'] = 0;
         $_Translation['warning'] = false;
         $_Translation['translation_date'] = date("Y-m-d H:i:s");
         $res = addTranslation($_Translation);
         if ($res < 0) {
             $this->result['errors'][] = array("code" => -101, "message" => "database errors");
             $db->rollback();
             return $res;
         }
         /*
          * begin stats counter
          *
          */
         $old_translation = $_Translation;
     }
     $_Translation = array();
     $_Translation['id_segment'] = $this->id_segment;
     $_Translation['id_job'] = $this->id_job;
     $_Translation['status'] = $this->status;
     $_Translation['time_to_edit'] = $this->time_to_edit;
     $_Translation['translation'] = preg_replace('/[ \\t\\n\\r\\0\\x0A\\xA0]+$/u', '', $translation);
     $_Translation['serialized_errors_list'] = $err_json;
     $_Translation['suggestion_position'] = $this->chosen_suggestion_index;
     $_Translation['warning'] = $check->thereAreWarnings();
     $_Translation['translation_date'] = date("Y-m-d H:i:s");
     /**
      * when the status of the translation changes, the auto propagation flag
      * must be removed
      */
     if ($_Translation['translation'] != $old_translation['translation'] || $this->status == Constants_TranslationStatus::STATUS_TRANSLATED || $this->status == Constants_TranslationStatus::STATUS_APPROVED) {
         $_Translation['autopropagated_from'] = 'NULL';
     }
     $res = CatUtils::addSegmentTranslation($_Translation);
     if (!empty($res['errors'])) {
         $this->result['errors'] = $res['errors'];
         $msg = "\n\n Error addSegmentTranslation \n\n Database Error \n\n " . var_export(array_merge($this->result, $_POST), true);
         Log::doLog($msg);
         Utils::sendErrMailReport($msg);
         $db->rollback();
         return -1;
     }
     if (INIT::$DQF_ENABLED && !empty($this->jobData['dqf_key']) && $_Translation['status'] == Constants_TranslationStatus::STATUS_TRANSLATED) {
         $dqfSegmentStruct = DQF_DqfSegmentStruct::getStruct();
         if ($old_translation['suggestion'] == null) {
             $dqfSegmentStruct->target_segment = "";
             $dqfSegmentStruct->tm_match = 0;
         } else {
             $dqfSegmentStruct->target_segment = $old_translation['suggestion'];
//.........这里部分代码省略.........
开发者ID:reysub,项目名称:MateCat,代码行数:101,代码来源:setTranslationController.php

示例14: addTranslation

function addTranslation(array $_Translation)
{
    $db = Database::obtain();
    $query = "INSERT INTO `segment_translations` ";
    foreach ($_Translation as $key => $val) {
        if ($key == 'translation') {
            $_Translation[$key] = "'" . $db->escape($val) . "'";
            continue;
        }
        if (strtolower($val) == 'now()' || strtolower($val) == 'current_timestamp()' || strtolower($val) == 'sysdate()') {
            $_Translation[$key] = "NOW()";
        } elseif (is_numeric($val)) {
            $_Translation[$key] = (double) $val;
        } elseif (is_bool($val)) {
            $_Translation[$key] = var_export($val, true);
        } elseif (strtolower($val) == 'null' || empty($val)) {
            $_Translation[$key] = "NULL";
        } else {
            $_Translation[$key] = "'" . $db->escape($val) . "'";
        }
    }
    $query .= "(" . implode(", ", array_keys($_Translation)) . ") VALUES (" . implode(", ", array_values($_Translation)) . ")";
    $query .= "\n\t\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\tstatus = {$_Translation['status']},\n                suggestion_position = {$_Translation['suggestion_position']},\n                serialized_errors_list = {$_Translation['serialized_errors_list']},\n                time_to_edit = time_to_edit + VALUES( time_to_edit ),\n                translation = {$_Translation['translation']},\n                translation_date = {$_Translation['translation_date']},\n                warning = " . $_Translation['warning'];
    if (isset($_Translation['autopropagated_from'])) {
        $query .= " , autopropagated_from = NULL";
    }
    if (empty($_Translation['translation']) && !is_numeric($_Translation['translation'])) {
        $msg = "\n\n Error setTranslationUpdate \n\n Empty translation found after DB Escape: \n\n " . var_export(array_merge(array('db_query' => $query), $_POST), true);
        Log::doLog($msg);
        Utils::sendErrMailReport($msg);
        return -1;
    }
    Log::doLog($query);
    $db->query($query);
    $err = $db->get_error();
    $errno = $err['error_code'];
    //    Log::doLog( $err );
    //    Log::doLog( $db->affected_rows );
    if ($errno != 0) {
        Log::doLog("{$errno}: " . var_export($err, true));
        return $errno * -1;
    }
    return $db->affected_rows;
}
开发者ID:reysub,项目名称:MateCat,代码行数:44,代码来源:queries.php

示例15: doAction

 public function doAction()
 {
     if (!$this->validateAuthHeader()) {
         header('HTTP/1.0 401 Unauthorized');
         $this->api_output['message'] = 'Authentication failed';
         return -1;
     }
     if (@count($this->api_output['debug']) > 0) {
         return;
     }
     $uploadFile = new Upload();
     try {
         $stdResult = $uploadFile->uploadFiles($_FILES);
     } catch (Exception $e) {
         $stdResult = array();
         $this->result = array('errors' => array(array("code" => -1, "message" => $e->getMessage())));
         $this->api_output['message'] = $e->getMessage();
     }
     $arFiles = array();
     foreach ($stdResult as $input_name => $input_value) {
         $arFiles[] = $input_value->name;
     }
     //if fileupload was failed this index ( 0 = does not exists )
     $default_project_name = @$arFiles[0];
     if (count($arFiles) > 1) {
         $default_project_name = "MATECAT_PROJ-" . date("Ymdhi");
     }
     if (empty($this->project_name)) {
         $this->project_name = $default_project_name;
         //'NO_NAME'.$this->create_project_name();
     }
     if (empty($this->source_lang)) {
         $this->api_output['message'] = "Missing source language.";
         $this->result['errors'][] = array("code" => -3, "message" => "Missing source language.");
     }
     if (empty($this->target_lang)) {
         $this->api_output['message'] = "Missing target language.";
         $this->result['errors'][] = array("code" => -4, "message" => "Missing target language.");
     }
     //ONE OR MORE ERRORS OCCURRED : EXITING
     //for now we sent to api output only the LAST error message, but we log all
     if (!empty($this->result['errors'])) {
         $msg = "Error \n\n " . var_export(array_merge($this->result, $_POST), true);
         Log::doLog($msg);
         Utils::sendErrMailReport($msg);
         return -1;
         //exit code
     }
     $cookieDir = $uploadFile->getDirUploadToken();
     $intDir = INIT::$UPLOAD_REPOSITORY . DIRECTORY_SEPARATOR . $cookieDir;
     $errDir = INIT::$STORAGE_DIR . DIRECTORY_SEPARATOR . 'conversion_errors' . DIRECTORY_SEPARATOR . $cookieDir;
     $response_stack = array();
     foreach ($arFiles as $file_name) {
         $ext = FilesStorage::pathinfo_fix($file_name, PATHINFO_EXTENSION);
         $conversionHandler = new ConversionHandler();
         $conversionHandler->setFileName($file_name);
         $conversionHandler->setSourceLang($this->source_lang);
         $conversionHandler->setTargetLang($this->target_lang);
         $conversionHandler->setSegmentationRule($this->seg_rule);
         $conversionHandler->setCookieDir($cookieDir);
         $conversionHandler->setIntDir($intDir);
         $conversionHandler->setErrDir($errDir);
         $status = array();
         if ($ext == "zip") {
             // this makes the conversionhandler accumulate eventual errors on files and continue
             $conversionHandler->setStopOnFileException(false);
             $fileObjects = $conversionHandler->extractZipFile();
             //call convertFileWrapper and start conversions for each file
             if ($conversionHandler->uploadError) {
                 $fileErrors = $conversionHandler->getUploadedFiles();
                 foreach ($fileErrors as $fileError) {
                     if (count($fileError->error) == 0) {
                         continue;
                     }
                     $brokenFileName = ZipArchiveExtended::getFileName($fileError->name);
                     /*
                      * TODO
                      * return error code is 2 because
                      *      <=0 is for errors
                      *      1   is OK
                      *
                      * In this case, we raise warnings, hence the return code must be a new code
                      */
                     $this->result['code'] = 2;
                     $this->result['errors'][$brokenFileName] = array('code' => $fileError->error['code'], 'message' => $fileError->error['message'], 'debug' => $brokenFileName);
                 }
             }
             $realFileObjectInfo = $fileObjects;
             $realFileObjectNames = array_map(array('ZipArchiveExtended', 'getFileName'), $fileObjects);
             foreach ($realFileObjectNames as $i => &$fileObject) {
                 $__fileName = $fileObject;
                 $__realFileName = $realFileObjectInfo[$i];
                 $filesize = filesize($intDir . DIRECTORY_SEPARATOR . $__realFileName);
                 $fileObject = array('name' => $__fileName, 'size' => $filesize);
                 $realFileObjectInfo[$i] = $fileObject;
             }
             $this->result['data'][$file_name] = json_encode($realFileObjectNames);
             $stdFileObjects = array();
             if ($fileObjects !== null) {
                 foreach ($fileObjects as $fName) {
//.........这里部分代码省略.........
开发者ID:bcrazvan,项目名称:MateCat,代码行数:101,代码来源:NewController.php


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