Commit a55dc57ad141127f71c0f8779d325898a1815c85

Authored by Elena.Budnik
1 parent 8385c27c

interim commit

Showing 1 changed file with 57 additions and 77 deletions   Show diff stats
php/classes/WebServer.php
... ... @@ -82,7 +82,7 @@ class WebServer
82 82  
83 83 function __construct()
84 84 {
85   -
  85 + if (!is_dir(WSConfigClass::getWsResultDir())) mkdir(WSConfigClass::getWsResultDir(), 0775);
86 86 // $this->resultMgr = new WebResultMgr();
87 87 }
88 88  
... ... @@ -158,33 +158,6 @@ class WebServer
158 158 return $realIP;
159 159 }
160 160  
161   -// private function timeInterval2Days($TimeInterval)
162   -// {
163   -// $divDays = 60*60*24;
164   -// $nbDays = floor($TimeInterval / $divDays);
165   -// $divHours = 60*60;
166   -// $nbHours = floor(($TimeInterval - $divDays*$nbDays)/$divHours);
167   -// $nbMin = floor(($TimeInterval - $divDays*$nbDays - $divHours*$nbHours)/60);
168   -// $nbSec = $TimeInterval - $divDays*$nbDays - $divHours*$nbHours - $nbMin*60;
169   -//
170   -// $DD = sprintf("%03d", $nbDays); // format ex. 005 not 5
171   -// $HH = sprintf("%02d", $nbHours); // format ex. 25
172   -// $MM = sprintf("%02d", $nbMin); // format ex. 03 not 3
173   -// $SS = sprintf("%02d", $nbSec); // format ex. 02 not 2
174   -//
175   -// return $DD.':'.$HH.':'.$MM.':'.$SS;
176   -// }
177   -
178   - /* Start Time into AMDA format YYYY:DOY-1:HH:MM:SS */
179   -// private function startTime2Days($startTime)
180   -// {
181   -// $ddStart = getdate($startTime);
182   -// $date_start = sprintf("%04d",$ddStart["year"]).":".sprintf("%03d", $ddStart["yday"]).":"
183   -// .sprintf("%02d",$ddStart["hours"]).":".sprintf("%02d",$ddStart["minutes"]).":"
184   -// .sprintf("%02d",$ddStart["seconds"]);
185   -// return $date_start;
186   -// }
187   -
188 161 private function rrmdir($dir)
189 162 {
190 163 if (is_dir($dir)) {
... ... @@ -457,61 +430,68 @@ class WebServer
457 430  
458 431 public function getStatus($id)
459 432 {
460   - $processManager = new ProcessManagerClass(IHMConfigClass::getProcessManagerFilePath());
  433 + $this->userID = 'impex';
  434 +
  435 + if (!isset($this->requestManager))
  436 + $this->requestManager = new RequestManagerClass();
461 437  
462 438 try {
463   - $res = $processManager->getProcessInfo($id, true);
  439 + $res = $this->requestManager->runWSRequest($this->userID, $this->getIPclient(), FunctionTypeEnumClass::PROCESSGETINFO, null, $id);
464 440 } catch (Exception $e) {
465   - $this->throwError("serverError","Exception detected : ".$e->getMessage());
466   - }
467   -// [success] => 1
468   -// [result] => Array
469   -// (
470   -// [id] => process_ADBCw1_1519836455_19505
471   -// [cmd] => /home/budnik/AMDA/AMDA_Kernel/build/Debug/bin/amdaXMLRequestorTool /home/budnik/AMDA/AMDA_IHM/data/budnik/RES/DDnT8PLR_/request_0.xml
472   -// [outputfile] => cmd_output
473   -// [exitcodefile] => cmd_exitcode
474   -// [processfile] => cmd_process
475   -// [exitcode] => 0
476   -// [PID] => 19505
477   -// [runningpath] => /home/budnik/AMDA/AMDA_IHM/data/budnik/RES/DDnT8PLR_/
478   -// [runningstart] => 1519836455
479   -// [isrunning] =>
480   -// [iskilled] =>
481   -// [lastupdate] => 1519837450
482   -// )
  441 + return array("error" => $e->getMessage());
  442 + // $this->throwError("serverError", "Exeption detected : ".$e->getMessage());
  443 + }
  444 +// [success] => 1
  445 +// [id] => process_t7ovpn_1520344095_13119
  446 +// [name] => download_1520344108
  447 +// [status] => done
  448 +// [jobType] => download
  449 +// [info] => imf
  450 +// [start] => 06-03-2018 13:48:15
  451 +// [stop] => 06-03-2018 15:40:20
  452 +// [folder] => DDEUQzrM_
  453 +// [result] => result_EUQzrM
  454 +// [format] => unknown
  455 +// [compression] => 0
  456 +
  457 +// [success] => 1
  458 +// [id] => process_t7ovpn_1520344095_13119
  459 +// [name] => download_1520344108
  460 +// [status] => in_progress
  461 +// [jobType] => download
  462 +// [info] => imf
  463 +// [start] => 06-03-2018 13:48:15
  464 +// [stop] => unknown
  465 +// [folder] => DDEUQzrM_
  466 +// [result] => result_EUQzrM
  467 +// [format] => unknown
  468 +// [compression] => 0
483 469  
484 470 if (!$res['success']) {
485 471 $this->throwError("processError","Cannot retrieve process $id info");
486 472 }
487   -
488   - $result = $res['result'];
489   -
490   - if ($result['isrunning']) {
491   - return array('success' => true, 'status' => 'in_progress');
492   - }
493   -
494   - if ($result['iskilled']) {
495   - $this->throwError("processError","Process $id was killed");
496   - }
497   -
498   - if ($result['exitcode'] !== 0) {
499   - $this->throwError("processError","Process $id error code: ".$result['exitcode']);
  473 +
  474 + if ($res['status'] == 'in_progress') {
  475 + return array('success' => true, 'status' => 'in progress');
500 476 }
501 477  
502   - $vars = $this->getVarsFromRunningPath($result['runningpath']);
503   -
504   - if (!$vars['success']) {
505   - $this->throwError("processError","Process $id : cannot generate file name for result : ".$vars['message']);
  478 + if ($res['error']) {
  479 + $this->throwError("processError","Process $id error code");
506 480 }
507 481  
508   - $resultFile = glob($result['runningpath']."result_*");
  482 + // $vars = $this->getVarsFromRunningPath($result['runningpath']);
509 483  
510   - $tempFilePath = $result['runningpath'].$resultFile.$vars['kernelExtension'];
511   -
512   - $outputFilePath = WSRESULT.$vars['dataFileName'].$vars['wsExtension'];
  484 +// if (!$vars['success']) {
  485 +// $this->throwError("processError","Process $id : cannot generate file name for result : ".$vars['message']);
  486 +// }
  487 +//
  488 +// $resultFile = glob($result['runningpath']."result_*");
  489 +//
  490 +// $tempFilePath = $result['runningpath'].$resultFile.$vars['kernelExtension'];
  491 +//
  492 +// $outputFilePath = WSRESULT.$vars['dataFileName'].$vars['wsExtension'];
513 493  
514   - return $this->finishDownloadRequest($id, $tempFilePath, $outputFilePath);
  494 + return array('success' => true,'status' => $res['status']); //$this->finishDownloadRequest($id, $tempFilePath, $outputFilePath);
515 495 }
516 496  
517 497  
... ... @@ -911,7 +891,7 @@ class WebServer
911 891 $this->requestManager = new RequestManagerClass();
912 892  
913 893 try {
914   - $downloadResult = $this->requestManager->runWSRequest($this->userID, $this->getIPclient(), WSConfigClass::DOWNLOAD, $obj);
  894 + $downloadResult = $this->requestManager->runWSRequest($this->userID, $this->getIPclient(), FunctionTypeEnumClass::PARAMS, WSConfigClass::DOWNLOAD, $obj);
915 895 } catch (Exception $e) {
916 896 $this->throwError("executionError", "Exception detected : ".$e->getMessage());
917 897 }
... ... @@ -939,7 +919,7 @@ class WebServer
939 919 }
940 920  
941 921 rename($resTempFilePath, $resOutputFilePath);
942   - chmod($resOutputFilePath, 0664);
  922 + // chmod($resOutputFilePath, 0664);
943 923  
944 924 $outputURL = 'http://' . str_replace(BASE_PATH, $_SERVER['SERVER_NAME'] . APACHE_ALIAS, $resOutputFilePath);
945 925  
... ... @@ -950,11 +930,11 @@ class WebServer
950 930 if (!isset($this->requestManager))
951 931 $this->requestManager = new RequestManagerClass();
952 932  
953   - try {
954   - $downloadResult = $this->requestManager->runIHMRequest($this->userID, $this->getIPclient(), FunctionTypeEnumClass::PROCESSDELETE, $obj);
955   - } catch (Exception $e) {
956   - error_log("Can not delete file $resOutputFilePath: $e");
957   - }
  933 +// try {
  934 +// $downloadResult = $this->requestManager->runIHMRequest($this->userID, $this->getIPclient(), FunctionTypeEnumClass::PROCESSDELETE, $obj);
  935 +// } catch (Exception $e) {
  936 +// error_log("Can not delete file $resOutputFilePath: $e");
  937 +// }
958 938  
959 939 return array('success' => true, 'status' => 'done', 'dataFileURLs' => $outputURL);
960 940 }
... ...