Commit dcb59fdf908c59a7d5612e20f286bf4ef995317e
1 parent
d680a61c
Exists in
master
and in
9 other branches
new CALLEXT
Showing
8 changed files
with
139 additions
and
761 deletions
Show diff stats
src/CALLEXT/createHeaderVEXGRAZ.php deleted
... | ... | @@ -1,64 +0,0 @@ |
1 | -<?php | |
2 | -/** | |
3 | -* @file createHeaderVEXGRAZ.php | |
4 | -* @version $Id: createHeaderVEXGRAZ.php,v 1.1 2009/03/23 14:02:39 budnik Exp $ | |
5 | -* @brief Function to create header.nc for MapsKP datasets which are not self-described | |
6 | -* @todo Exclude absolute path for /usr/local/bin/ncgen | |
7 | -*/ | |
8 | - | |
9 | - | |
10 | -function createHeaderVEXGRAZ($remSetID) { | |
11 | - | |
12 | - $infoDom = new DOMDocument(); | |
13 | - $infoDom->load(INFODIR."../AmdaInfo/MAG_VSO.xml"); | |
14 | - | |
15 | - $sampling = $infoDom->getElementsByTagName("TIME_RESOLUTION")->item(0)->nodeValue; | |
16 | - $globalAttrs = ":minSampling = ".$sampling.";"; | |
17 | - | |
18 | - $params = $infoDom->getElementsByTagName("PARAM_METADATA"); | |
19 | - | |
20 | - $Dimensions = "Time = unlimited, TimeLength = 17 "; | |
21 | - $charVariables = "char Time(Time,TimeLength), StartTime(TimeLength), StopTime(TimeLength);"; | |
22 | - $floatVariables = "float "; | |
23 | - | |
24 | - $Size = array(); | |
25 | - $addDim = true; | |
26 | - | |
27 | - for ($i = 0; $i < $params->length; $i++) { | |
28 | - | |
29 | - $Name = $params->item($i)->getElementsByTagName("PARAM_ID")->item(0)->nodeValue; | |
30 | - $Size[$i] = $params->item($i)->getElementsByTagName("SIZES")->item(0)->nodeValue; | |
31 | - $Type = $params->item($i)->getElementsByTagName("DATA_TYPE")->item(0)->nodeValue; | |
32 | - | |
33 | - if ($i > 0) $floatVariables .= ","; | |
34 | - | |
35 | - if ($Size[$i] != "1" ) { | |
36 | - for ($j = 0; $j < $i+1; $j++) | |
37 | - if ($Size[$i] == $Size[$j]) { | |
38 | - if ($i != 0 && $j != $i) $addDim = false; | |
39 | - break; | |
40 | - } | |
41 | - if ($addDim) $Dimensions .= ", Dim".$j." = ".$Size[$j]; | |
42 | - $floatVariables .= $Name."(Time, Dim".$j.")"; | |
43 | - $addDim = true; | |
44 | - } | |
45 | - else | |
46 | - $floatVariables .= $Name."(Time)"; | |
47 | -// | |
48 | - } | |
49 | - | |
50 | -// Create CDL ASCII file | |
51 | - $cdl = fopen("header.cdl","w"); | |
52 | - fwrite($cdl, "netcdf header { \n \n dimensions: \n"); | |
53 | - fwrite($cdl,$Dimensions."; \n\n"); | |
54 | - | |
55 | - fwrite($cdl, "variables: \n "); | |
56 | - fwrite($cdl, $charVariables."\n"); | |
57 | - fwrite($cdl, $floatVariables."; \n \n"); | |
58 | - fwrite($cdl, $globalAttrs."\n"); | |
59 | - fwrite($cdl, "data: \n\n }"); | |
60 | - fclose($cdl); | |
61 | -// transform to nc | |
62 | - system("/usr/local/bin/ncgen -o header.nc header.cdl"); | |
63 | - } | |
64 | -?> |
src/CALLEXT/createVI.php
1 | 1 | <?php |
2 | -/*---------------------------------------------------------------------- | |
3 | - * DD SERVER TOOLS | |
4 | - * data update collection | |
5 | - * createVI.php | |
6 | - * 17 Jun 2007 V.1.0 | |
7 | - * 01 Aug 2007 V.1.1 Only one argument in info2nc call | |
8 | - * 02 Aug 2007 V.1.2 rebuild, clean & cash from templates in DDLIB | |
9 | - * 05 Sep 2007 V.1.3 creates empty *times.nc | |
10 | - * 24 Nov 2007 V.1.4 DDrehash -> TimesUpdate | |
11 | - * 14 Feb 2008 V.1.5 added Mission & Instrument tags ; and createHeader if neccessary | |
12 | - * 11 Sep 2012 V.1.6 get dataset info from remote DB to keep it at server side in the only one place | |
13 | - *-----------------------------------------------------------------------*/ | |
14 | - | |
15 | -function getCDF($remSetID){ | |
16 | - | |
17 | - $client = new SoapClient(wsdlCDAWEB); | |
18 | -/* Get "VIEW" descriptions, select "istp_public" and set endPoint address*/ | |
19 | - $metaData = $client->__soapCall("getAllViewDescriptions", array()); | |
20 | - | |
21 | - for ($k = 0; $k < count($metaData); $k++) { | |
22 | - if ($metaData[$k]->id != viewID) continue; | |
23 | - try { | |
24 | - $client->__setLocation($metaData[$k]->endpointAddress); | |
25 | - break; | |
26 | - } | |
27 | - catch (SoapFault $exception){ | |
28 | - error_log($exception.PHP_EOL, 3, err); | |
29 | - return false; | |
30 | - } | |
31 | - } | |
32 | - $fileXML = INFODIR.'CDAWEB/'.$remSetID.'.xml'; | |
33 | - if (!file_exists($fileXML)) { | |
34 | - error_log('No DDServer XML description '.$remSetID.PHP_EOL, 3, err); | |
35 | - return false; | |
36 | - } | |
37 | - $XML= new DomDocument("1.0"); | |
38 | - $XML->load($fileXML); | |
39 | - | |
40 | - $Start = $XML->getElementsByTagName('GlobalStart')->item(0)->nodeValue; | |
41 | - $fileName = strtolower($remSetID)."_00000000_v01.cdf"; | |
42 | - $Stop = strftime("%Y-%m-%dT%H:%M:%S.000Z",strtotime($Start) + 82800); | |
43 | - $nFiles = 0; | |
44 | - $INFO_DIR = INFODIR."../CDAWEB/DATASETS/"; | |
45 | - | |
46 | - while ($nFiles == 0){ | |
47 | - $dataFileDesc = $client->__soapCall("getDataFiles", array($remSetID, $Start, $Stop)); | |
48 | - $nFiles = count($dataFileDesc); | |
49 | - if ($nFiles > 0) { | |
50 | - if (!copy($dataFileDesc[0]->name, $INFO_DIR.$fileName)){ | |
51 | - error_log('Cannot copy '.$dataFileDesc[0]->name.PHP_EOL, 3, err); | |
52 | - return false; | |
53 | - } | |
54 | - } | |
55 | - $Start = strftime("%Y-%m-%dT%H:%M:%S.000Z",strtotime($Stop) + 82800); | |
56 | - $Stop = strftime("%Y-%m-%dT%H:%M:%S.000Z",strtotime($Start) + 82800); | |
57 | - } | |
58 | - if ($nFiles == 0) { | |
59 | - error_log('No data file '.$remSetID.' '.$Start.PHP_EOL, 3, err); | |
60 | - return false; | |
61 | - } | |
62 | - | |
63 | - return true; | |
64 | -} | |
65 | - | |
66 | -function getInfoFromRemoteBase($dataBaseID, $remSetID){ | |
67 | - | |
68 | - $INFO_DIR = INFODIR."../".$dataBaseID."/DATASETS/"; | |
69 | - if (!is_dir($INFO_DIR)) mkdir($INFO_DIR, 0755, true); | |
70 | - | |
71 | - switch ($dataBaseID) { | |
72 | - case 'CDAWEB' : | |
73 | - require_once "ftpWrapper.php"; | |
74 | - require_once "cdaweb_cfg.php"; | |
75 | - | |
76 | - $fileName = strtolower($remSetID)."_00000000_v01.cdf"; | |
77 | - if (file_exists($INFO_DIR.$fileName)) return true; | |
78 | - | |
79 | - // Get master CDF | |
80 | - if (!ftpWrapper(ftp_server, ftp_user_name, ftp_user_pass, | |
81 | - ftp_dir.$fileName, $INFO_DIR.$fileName)) { | |
82 | - error_log('No master CDF for '.$remSetID.PHP_EOL, 3, err); | |
83 | - // No master CDF - try regular file | |
84 | - return getCDF($remSetID); | |
85 | - } | |
86 | - | |
87 | - return true; | |
88 | - | |
89 | - break; | |
90 | - case "MAPSKP": | |
91 | - | |
92 | - require_once "mapskp_cfg.php"; | |
93 | - | |
94 | - $XML_NAME = $remSetID.".xml"; | |
95 | - if (file_exists($INFO_DIR.$XML_NAME)) return true; | |
96 | - | |
97 | - $args = array('service'=>'getInfoUrl', 'datasetId'=>$remSetID); | |
98 | - | |
99 | - $url = url.http_build_query($args); | |
100 | - | |
101 | - $infoDom = new DOMDocument(); | |
102 | - $infoDom->load($url); | |
103 | - $File = $infoDom->getElementsByTagName("infoUrl")->item(0)->nodeValue; | |
104 | - | |
105 | - $fileName_ = explode("ftp://",$File); | |
106 | - $fileName = $fileName_[0].passwd.$fileName_[1]; | |
107 | - | |
108 | - if (!copy($fileName,$INFO_DIR.$XML_NAME)) return false; | |
109 | - return true; | |
110 | - | |
111 | - break; | |
112 | - | |
113 | - case "VEXGRAZ" : | |
114 | - $fileName = "MAG_VSO.xml"; | |
115 | - if (file_exists($INFO_DIR.$fileName)) return true; | |
116 | - return false; | |
117 | - break; | |
118 | - | |
119 | - case "CDPP" : | |
120 | - | |
121 | - break; | |
122 | - | |
123 | - default: | |
124 | - } | |
125 | - | |
126 | - return true; | |
127 | - | |
128 | -}; | |
129 | - | |
130 | -function getInfoFromAmda($dataBaseID, $remSetID) | |
131 | -{ | |
132 | - | |
133 | - global $DDsysInfo; | |
134 | - | |
135 | - if (file_exists(BASEDIR.'info.xml')) unlink(BASEDIR.'info.xml'); | |
136 | - | |
137 | - $DDinfo = new DomDocument("1.0"); | |
138 | - $VI = $DDinfo->createElement("VI"); | |
139 | - | |
140 | - $InfoArr = $DDsysInfo->getElementsByTagName("VI")->item(0)->childNodes; | |
141 | - for ($i = 0; $i < $InfoArr->length; $i++) | |
142 | - if ($InfoArr->item($i)->nodeName != '#text' && $InfoArr->item($i)->nodeName != 'PARAMETER') | |
143 | - $VI->appendChild($DDinfo->importNode($InfoArr->item($i), true)); | |
144 | - $VI->appendChild($DDinfo->createElement("LocalStart")); | |
145 | - $VI->appendChild($DDinfo->createElement("LocalStop")); | |
146 | - $DDinfo->appendChild($VI); | |
147 | - $DDinfo->save(BASEDIR.'info.xml'); | |
148 | - | |
149 | - return true; | |
150 | -} | |
151 | - | |
152 | -/** | |
2 | +/**---------------------------------------------------------------------- | |
3 | +* DD SERVER TOOLS | |
4 | +* data update collection | |
153 | 5 | * @file createVI.php |
154 | 6 | * @brief DD_Server tool <br> Creates New Virtual Instrument |
155 | -* @version $Id: createVI.php,v 1.11 2013/09/23 09:02:28 budnik Exp $ | |
7 | +* @version | |
156 | 8 | * Creates New VI at DD_Server Side \n |
157 | 9 | * Args: dataBaseID ddDataSetID remoteDataSetID \n |
158 | 10 | * Env Vars: $DDBASE $DDBASEBIN $DDLIB \n |
159 | 11 | * Executables: makeDDsys info2nc TimesUpdate \n |
160 | -* Functions: getInfoFromAmda | |
161 | 12 | * |
162 | -* @arg Checks if VI already exists in dataBase desctiptor $DDBASE/DDsys.xml | |
13 | +* @arg Checks if VI already exists in dataBase desctiptor DDsys.xml | |
163 | 14 | * @arg Adds non-existing VI to DDres.xml |
164 | -* @arg $DDBASEBIN/makeDDsys creats refer.nc file from DDsys.xml | |
15 | +* @arg makeDDsys creats refer.nc file from DDsys.xml | |
165 | 16 | * @arg Gets dataSet Info from INFO/DDServer dir |
166 | -* @arg Creates dir, *_cash.nc, *_info.nc and empty *_times.nc | |
17 | +* @arg Creates dir, *_cache.nc, *_info.nc and empty *_times.nc | |
167 | 18 | * |
168 | 19 | */ |
169 | 20 | |
170 | - global $DDsysInfo; | |
171 | - | |
172 | - define("verbose", true); | |
173 | - | |
174 | - | |
175 | - define("BASEDIR",getenv("DDBASE")."/"); | |
176 | - define("INFODIR",BASEDIR."../INFO/DDServer/"); | |
177 | - define("DDBASEBIN",getenv("DDBASEBIN")); | |
178 | - define("DDLIB", getenv("DDLIB")."/"); | |
179 | - | |
180 | - define ("log",BASEDIR."../INFO/addVI.log"); | |
181 | - define ("err",BASEDIR."../INFO/addVI.err"); | |
182 | - | |
183 | - | |
184 | - if ($argc != 4) { | |
185 | - error_log("Usage: php createVI.php <BaseID> <RemSetID> <NewVIName>".PHP_EOL, 3, err); | |
186 | - exit("Usage: php createVI.php <BaseID> <RemSetID> <NewVIName>".PHP_EOL); | |
187 | - } | |
21 | + if (!function_exists('__autoload')) | |
22 | + { | |
23 | + function __autoload($class_name) { | |
24 | + require_once $class_name . '.php'; | |
25 | + } | |
26 | + } | |
27 | + | |
28 | + date_default_timezone_set('UTC'); | |
29 | + putenv("LD_LIBRARY_PATH=".getenv("LD_LIBRARY_PATH")); | |
30 | + putenv("PATH=./:".getenv("DDBASEBIN").":/bin:/usr/bin"); | |
31 | + set_include_path("./:".getenv("DATAMANAGER").":".getenv("REMOTEDATA").":".getenv("CALLEXT")); | |
32 | + | |
33 | + define("verbose", true); | |
34 | + | |
35 | + define("INFODIR",getenv("DDBASE")."../INFO/"); | |
36 | + define ("log",INFODIR."addVI.log"); | |
37 | + define ("err",INFODIR."addVI.err"); | |
38 | + | |
39 | + if ($argc != 4) | |
40 | + { | |
41 | + // error_log("Usage: php createVI.php <BaseID> <RemSetID> <NewVIName>".PHP_EOL, 3, err); | |
42 | + exit("Usage: php createVI.php <BaseID> <RemSetID> <NewVIName>".PHP_EOL); | |
43 | + } | |
188 | 44 | |
189 | - $dataBaseID = strtoupper($argv[1]); | |
190 | - $remSetID = $argv[2]; | |
191 | - $VIID = strtolower($argv[3]); | |
45 | + $base = strtoupper($argv[1]); | |
46 | + $remSetID = $argv[2]; | |
47 | + $ViId = strtolower($argv[3]); | |
48 | + | |
49 | + $baseMgr = new DDBaseMgr(); | |
50 | + | |
51 | + $nc_prefix = strlen($ViId) > RemoteDataCenterClass::$MAX_VI_NAME_LENGTH ? | |
52 | + substr($ViId, 0, RemoteDataCenterClass::$MAX_VI_NAME_LENGTH - 1): $ViId; | |
192 | 53 | |
193 | - | |
194 | - | |
195 | - $MAX_VI_NAME_LENGTH = 16; | |
196 | - $nc_prefix = strlen($VIID) > $MAX_VI_NAME_LENGTH ? substr($VIID,0,15): $VIID; | |
197 | - | |
198 | - $newDataSet = false; | |
199 | - $DDsysRefer = BASEDIR."DDsys.xml"; | |
200 | - if (verbose) | |
201 | - error_log("request to add Data Set ".$dataBaseID.":".$remSetID." as ".$VIID.PHP_EOL, 3, log); | |
202 | -// Check if dataSet exists already | |
203 | - $DDsys = new DomDocument("1.0"); | |
204 | - $DDsys->preserveWhiteSpace = false; | |
205 | - $DDsys->formatOutput = true; | |
206 | - $DDsys->load($DDsysRefer); | |
207 | - | |
208 | - $xp = new domxpath($DDsys); | |
209 | - $dataSet = $xp->query("//NAME[.='".$VIID."']"); | |
210 | - | |
211 | - if ($dataSet->item(0) != NULL) | |
212 | - if ($dataSet->item(0)->getAttribute("base") != $dataBaseID) { | |
213 | - error_log(" Data Set ".$VIID." exists! Corresponding BaseID is " | |
214 | - .$dataSet->item(0)->getAttribute("base")." not ".$dataBaseID.PHP_EOL, 3, err); | |
215 | - | |
216 | - $newDataSet = true; | |
217 | - } | |
218 | - if ($dataSet->item(0) == NULL) $newDataSet = true; | |
219 | - | |
54 | + if ($baseMgr->viExists($ViId, $base)) die("$ViId Already Exists!!!".PHP_EOL); | |
55 | + | |
56 | + $baseMgr->setViId($ViId); | |
57 | + $baseMgr->setViInfo($nc_prefix); | |
58 | + $status = $baseMgr->setViInfoFromFile($base, $remSetID); | |
59 | + | |
60 | + if ($status === 0) | |
61 | + { | |
62 | + $baseMgr->createVi(); | |
63 | +// if (verbose) | |
64 | +// error_log("request to add Data Set ".$base.":".$remSetID." as ".$ViId.PHP_EOL, 3, log); | |
65 | +// | |
220 | 66 | //-------------- Get Full Dataset Info file from distant database------------- |
221 | -//TODO error processing here | |
222 | - $res = getInfoFromRemoteBase($dataBaseID, $remSetID); | |
223 | - if (!$res) | |
224 | - error_log("Error: Can't get dataset info for ".$remSetID." from ".$dataBaseID.PHP_EOL, 3, err); | |
225 | - | |
226 | - if (verbose) error_log("Get dataset info for ".$remSetID." from ".$dataBaseID." returns ".$res.PHP_EOL, 3, log); | |
227 | - if ($newDataSet) { | |
228 | - | |
229 | -//----------- Gets INFO from INFO/DDServer ------------------- | |
230 | - if (verbose) error_log("Ready to Add ".$VIID.PHP_EOL, 3, log); | |
231 | - $DDsysInfo = new DomDocument("1.0"); | |
232 | - | |
233 | -//----------- Getting INFO file for DataSet | |
234 | - $XmlName = INFODIR.$dataBaseID."/".$remSetID.".xml"; | |
235 | - | |
236 | - if (file_exists($XmlName)){ | |
237 | - | |
238 | - $DDsysInfo->load($XmlName); | |
239 | - $mission = $DDsysInfo->getElementsByTagName("Mission")->item(0)->nodeValue; | |
240 | - $instrument = $DDsysInfo->getElementsByTagName("Instrument")->item(0)->nodeValue; | |
241 | - | |
242 | -//--------- Check if additional Info should be added to VI | |
243 | - | |
244 | - $theFormat = $DDsysInfo->getElementsByTagName("Format")->item(0); | |
245 | - if ($theFormat != NULL) | |
246 | - $AddInfo = ($theFormat->nodeValue == "Text"); | |
247 | - if (!$AddInfo) | |
248 | - $AddInfo = ($DDsysInfo->getElementsByTagName("AdditionalInfoNeed")->item(0) != NULL); | |
249 | - | |
250 | - //--------------------------------------------------------- | |
251 | - $newVIdir = BASEDIR.$dataBaseID."/".strtoupper($VIID)."/"; | |
252 | -// New Data Set - add to DDsys.xml | |
253 | - $base = $xp->query("/DD_BASE")->item(0); | |
254 | - $newVI= $DDsys->createElement("VI"); | |
255 | - $newName = $DDsys->createElement("NAME",$VIID); | |
256 | - $newattrBase = new DomAttr('base', $dataBaseID); | |
257 | - $newattrMission = new DomAttr('mission', $mission); | |
258 | - $newattrIns = new DomAttr('instrument', $instrument); | |
259 | - $newName->appendChild($newattrBase); | |
260 | - $newName->appendChild($newattrMission); | |
261 | - $newName->appendChild($newattrIns); | |
262 | - $newVI->appendChild($newName); | |
263 | - $newVI->appendChild($DDsys->createElement("LOCATION", $newVIdir)); | |
264 | - $newVI->appendChild($DDsys->createElement("TIMES", $VIID."_times.nc")); | |
265 | - $newVI->appendChild($DDsys->createElement("INFO", $VIID."_info.nc")); | |
266 | - $newVI->appendChild($DDsys->createElement("CACHE", $VIID."_cash.nc")); | |
267 | - $base->appendChild($newVI); | |
268 | - | |
269 | - $DDsys->save($DDsysRefer); | |
270 | -// xml to refer.nc | |
271 | - exec(DDBASEBIN.'/makeDDsys'); | |
272 | - | |
273 | -// Now make new dir ..... | |
274 | - if (!is_dir(BASEDIR.$dataBaseID)) mkdir(BASEDIR.$dataBaseID."/", 0755, true); | |
275 | - if (!is_dir($newVIdir)) mkdir($newVIdir, 0755, true); | |
276 | - copy (DDLIB."Cash.template", $newVIdir."/".$VIID."_cash.nc"); | |
277 | - $SED = "sed 's/NAME/".$nc_prefix."/g' ".DDLIB."Clean.template | sed 's/CACHE/".$VIID."/g' > ".$newVIdir."/clean"; | |
278 | - exec($SED); | |
279 | - exec('chmod ugo+x '.$newVIdir.'/clean'); | |
280 | -// Now info.nc from metadonnees | |
281 | - $err = getInfoFromAmda($dataBaseID, $remSetID); | |
282 | - if ($err) exec(DDBASEBIN.'/info2nc '.$newVIdir.'/'.$VIID.'_info.nc'); | |
283 | -// Create empty times file | |
284 | - chdir($newVIdir); | |
285 | - exec(DDBASEBIN.'/TimesUpdate -r '.$VIID.'_times.nc '.$VIID.'_[0-9]*.nc'); | |
286 | - | |
287 | - if ($AddInfo) { | |
288 | - $function_name = "createHeader".$dataBaseID; | |
289 | - require_once(DDLIB.$function_name.".php"); | |
290 | - $function_name($remSetID); | |
291 | - } | |
292 | - if (verbose) error_log("Added ".$VIID.PHP_EOL, 3, log); | |
293 | - } | |
294 | - else { | |
295 | - error_log("Error: ".$VIID." not added: no XML DDServer info file ".PHP_EOL, 3, err); | |
296 | - } | |
297 | - } | |
67 | +// | |
68 | + $center = new $base(); | |
69 | + | |
70 | + $startStamp = strtotime($baseMgr->globalStart); | |
71 | + $stopStamp = strtotime($baseMgr->globalStart."+1 day"); | |
72 | + $start = date( "Ymd\THis\Z", $startStamp); | |
73 | + $stop = date( "Ymd\THis\Z", $stopStamp); | |
74 | + | |
75 | + $startIso = date( "Y-m-d\TH:i:s\.000\Z", $startStamp); | |
76 | + $stopIso = date( "Y-m-d\TH:i:s\.000\Z", $stopStamp); | |
77 | + | |
78 | + $ncFiles = $center->getData($remSetID, $start, $stop); | |
79 | + | |
80 | + $baseMgr->addRemoteData($remSetID, $ncFiles, $startIso, $stopIso); | |
81 | + echo " START-STOP ".$start." ".$stop.PHP_EOL; | |
82 | +// if (!$res) | |
83 | +// error_log("Error: Can't get dataset info for ".$remSetID." from ".$dataBaseID.PHP_EOL, 3, err); | |
84 | + | |
85 | +// if (verbose) error_log("Get dataset info for ".$remSetID." from ".$dataBaseID." returns ".$res.PHP_EOL, 3, log); | |
86 | + | |
87 | + | |
88 | + | |
89 | +// if ($AddInfo) | |
90 | +// { | |
91 | +// $function_name = "createHeader".$dataBaseID; | |
92 | +// require_once(DDLIB.$function_name.".php"); | |
93 | +// $function_name($remSetID); | |
94 | +// } | |
95 | +// if (verbose) error_log("Added ".$VIID.PHP_EOL, 3, log); | |
96 | + } | |
97 | + else | |
98 | + { | |
99 | + if (verbose) error_log("No DDServer Info File for $base $ViId".PHP_EOL, 3, log); | |
100 | + } | |
101 | + | |
298 | 102 | ?> |
299 | 103 | \ No newline at end of file |
... | ... |
src/CALLEXT/ftpWrapper.php deleted
... | ... | @@ -1,24 +0,0 @@ |
1 | -<?php | |
2 | -/** \file ftpWrapper.php | |
3 | -* \brief FTP Wrapper for FTP Servers passive | |
4 | -* | |
5 | -? | |
6 | -/*Wrapper to FTP - standard wrapper doesn't work in our case - we need passive mode */ | |
7 | -function ftpWrapper($ftp_server, $ftp_user_name, $ftp_user_pass, $server_file, $local_file) { | |
8 | - | |
9 | - try | |
10 | - { | |
11 | - $conn_id = ftp_connect($ftp_server); | |
12 | - $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); | |
13 | - ftp_pasv($conn_id, true); | |
14 | - $ftp_get = ftp_get($conn_id, $local_file, $server_file, FTP_BINARY); | |
15 | - ftp_close($conn_id); | |
16 | - } | |
17 | - catch (Exception $e) | |
18 | - { | |
19 | - return false; | |
20 | - } | |
21 | - | |
22 | - | |
23 | - return $ftp_get; | |
24 | -} |
... | ... | @@ -0,0 +1,54 @@ |
1 | +<?php | |
2 | +/** | |
3 | +* @file getData.php | |
4 | +* @version $Id: getData.php,v 1.5 2009/08/26 09:32:40 budnik Exp $ | |
5 | +* @brief DD_Server tools <br> Gets Data from Remote | |
6 | +* | |
7 | +* Args: remDataSetID ddVIdir StartTime StopTime \n | |
8 | +* Env Vars: $DDBASE $DDBASEBIN \n | |
9 | +* Executables: cdf2nc(DECODERS) TimesUpdate clean | |
10 | +*/ | |
11 | + | |
12 | +/*---------------------------------------------------------------------- | |
13 | + * DD SERVER TOOLS | |
14 | + * data update collection | |
15 | + * getData.php | |
16 | + * php getData.php <baseID> <remDataSetID> <ddVIdir> <StartTime> <StopTime> | |
17 | + *-----------------------------------------------------------------------*/ | |
18 | + | |
19 | +// Args | |
20 | + $base = $argv[1]; | |
21 | + $id = $argv[2]; | |
22 | + $ViDir = $argv[3]; | |
23 | + $Start = $argv[4]; | |
24 | + $Stop = $argv[5]; | |
25 | + | |
26 | + if (!function_exists('__autoload')) | |
27 | + { | |
28 | + function __autoload($class_name) { | |
29 | + require_once $class_name . '.php'; | |
30 | + } | |
31 | + } | |
32 | + | |
33 | + putenv("LD_LIBRARY_PATH=".getenv("LD_LIBRARY_PATH")); | |
34 | + putenv("PATH=./:".getenv("DDBASEBIN").":/bin:/usr/bin"); | |
35 | + set_include_path("./:".getenv("DATAMANAGER").":".getenv("REMOTEDATA").":".getenv("CALLEXT")); | |
36 | + date_default_timezone_set('UTC'); | |
37 | + $startStamp = strtotime($Start); | |
38 | + $stopStamp = strtotime($Stop); | |
39 | + $start = date( "Ymd\THis\Z", $startStamp); | |
40 | + $stop = date( "Ymd\THis\Z", $stopStamp); | |
41 | + | |
42 | + $startIso = date( "Y-m-d\TH:i:s\.000\Z", $startStamp); | |
43 | + $stopIso = date( "Y-m-d\TH:i:s\.000\Z", $stopStamp); | |
44 | + // Get data and convert to nc | |
45 | + $center = new $base(); | |
46 | + | |
47 | + $ncFiles = $base->getData($id, $start, $stop); | |
48 | + | |
49 | + // Add nc to Vi | |
50 | + $baseMgr = new DDBaseMgr(); | |
51 | + $baseMgr->setViDir($ViDir); | |
52 | + $baseMgr->addRemoteData($id, $ncFiles, $startIso, $StopIso); | |
53 | + | |
54 | +?> | |
... | ... |
src/CALLEXT/getDataCDAWEB.php deleted
... | ... | @@ -1,103 +0,0 @@ |
1 | -<?php | |
2 | -/** | |
3 | -* @file getDataCDAWEB.php | |
4 | -* @version $Id: getDataCDAWEB.php,v 1.5 2009/08/26 09:32:40 budnik Exp $ | |
5 | -* @brief DD_Server tools <br> Gets Data from CDAWEB | |
6 | -* | |
7 | -* Args: remDataSetID ddVIdir StartTime StopTime \n | |
8 | -* Env Vars: $DDBASE $DDBASEBIN \n | |
9 | -* Executables: cdf2nc(DECODERS) TimesUpdate clean | |
10 | -* | |
11 | -* | |
12 | -* @todo General getData.php(dataBaseID) | |
13 | -*/ | |
14 | - | |
15 | -/*---------------------------------------------------------------------- | |
16 | - * DD SERVER TOOLS | |
17 | - * data update collection | |
18 | - * getDataCDAWEB.php | |
19 | - * php getDataCDAWEB.php <remDataSetID> <ddVIdir> <StartTime> <StopTime> | |
20 | - * 17 June 2007 V.1.0 | |
21 | - * 02 Aug 2007 V.1.1 | |
22 | - * 06 Aug 2007 V.1.2, cd to Data directory | |
23 | - * 23 Aug 2007 V.1.3, Another program for VI times update | |
24 | - * 23 Aug 2007 V.1.4, ZIP files before updating | |
25 | - * 23 Nov 2007 V.1.5 Copy LOCK file | |
26 | - * 21 jan 2008 V.1.6 Process all SOAP exceptions | |
27 | - * cut file names longer than 32 | |
28 | - *-----------------------------------------------------------------------*/ | |
29 | - | |
30 | -// Args | |
31 | - $id = $argv[1]; | |
32 | - $ViDir = $argv[2]; | |
33 | - $Start = $argv[3]; | |
34 | - $Stop = $argv[4]; | |
35 | -// Env variables | |
36 | - $DDBASEBIN = getenv("DDBASEBIN"); | |
37 | - $DDBASE = getenv("DDBASE"); | |
38 | - $MAX_NAME_LENGTH = 31; | |
39 | - $MAX_VI_NAME_LENGTH = 16; | |
40 | - | |
41 | - $wsdl = "http://cdaweb.gsfc.nasa.gov/WS/istp_public/jaxrpc?WSDL"; | |
42 | -// Opent STDERR stream | |
43 | - $STDERR = fopen("php://stderr","w"); | |
44 | - | |
45 | - try { | |
46 | - $client = new SoapClient($wsdl); | |
47 | - } | |
48 | - catch (SoapFault $exception) { | |
49 | - | |
50 | -fprintf($STDERR,"CDAWEB WSDL is unreachable \n"); | |
51 | - exit(0); | |
52 | - } | |
53 | - | |
54 | -// Stamp -> this directory is being updated | |
55 | - $LockName = $ViDir."/LOCK"; | |
56 | - touch($LockName); | |
57 | - | |
58 | -fprintf($STDERR,$ViDir." is LOCKED\n"); | |
59 | - | |
60 | - system("cd ".$ViDir."; ./clean"); | |
61 | -// If name is too long. | |
62 | - $nc_prefix = strlen($id) > $MAX_VI_NAME_LENGTH ? substr(strtolower($id),0,15): strtolower($id); | |
63 | - | |
64 | - try | |
65 | - { | |
66 | - $dataFileDesc = $client->__soapCall("getDataFiles", array($id, $Start, $Stop)); | |
67 | -fprintf($STDERR, "FILES GOT ".count($dataFileDesc)."\n"); | |
68 | - } | |
69 | - catch (SoapFault $exception) | |
70 | - { | |
71 | - unlink($LockName); | |
72 | - fprintf($STDERR, $exception."\n"); | |
73 | - exit(0); | |
74 | - } | |
75 | - if (count($dataFileDesc) > 0) | |
76 | - { | |
77 | - for ($i = 0; $i < count($dataFileDesc); $i++) { | |
78 | - $file = $dataFileDesc[$i]->name; | |
79 | - $fileArr = split("/",$file); | |
80 | -// fprintf($STDERR, $fileArr[count($fileArr)-1]."\n"); | |
81 | - if (copy($file, $fileArr[count($fileArr)-1])) { | |
82 | - system($DDBASEBIN."/cdf2nc ".$fileArr[count($fileArr)-1]); | |
83 | -fprintf($STDERR, "FILES TRANSLATED ".$i."\n"); | |
84 | - $ncFile = str_replace(".cdf", ".nc", $fileArr[count($fileArr)-1]); | |
85 | - unlink($fileArr[count($fileArr)-1]); | |
86 | - | |
87 | - $ncFileTrue = ($strLength = strlen($ncFile)) > $MAX_NAME_LENGTH ? | |
88 | - $nc_prefix."_".time().$i.".nc" : $ncFile; | |
89 | - | |
90 | - rename($ncFile,$ViDir."/".$ncFileTrue); | |
91 | - system("cd ".$ViDir."; ".$DDBASEBIN."/TimesUpdate -u ".strtolower($id)."_times.nc ".$ncFileTrue); | |
92 | -fprintf($STDERR, "TIMES IS UPDATED ".$i."\n"); | |
93 | - } | |
94 | - else fprintf($STDERR, $file." is not found\n"); | |
95 | - } | |
96 | - } | |
97 | - | |
98 | - system("cd ".$ViDir."; ".$DDBASEBIN."/TimesUpdateNoData ".strtolower($id)."_times.nc ".$argv[3]." ".$argv[4]); | |
99 | - unlink($LockName); | |
100 | -fprintf($STDERR, "UNLOCK \n"); | |
101 | - | |
102 | - | |
103 | -?> |
src/CALLEXT/getDataCDPP.php deleted
... | ... | @@ -1,119 +0,0 @@ |
1 | -<?php | |
2 | - | |
3 | -/** | |
4 | -* @file getDataCDPP.php | |
5 | -* @version $Id: getDataCDPP.php,v 1.4 2009/08/26 09:32:56 budnik Exp $ | |
6 | -* @brief DD_Server tools <br> Gets Data from CDPP | |
7 | -* | |
8 | -* Args: remDataSetID ddVIdir StartTime StopTime \n | |
9 | -* Env Vars: $DDBASE $DDBASEBIN \n | |
10 | -* Executables: TimesUpdate TimesUpdateNoData clean | |
11 | -* | |
12 | -* | |
13 | -* @todo General getData.php(dataBaseID) | |
14 | -*/ | |
15 | - | |
16 | -/*---------------------------------------------------------------------- | |
17 | - * DD SERVER TOOLS | |
18 | - * data update collection | |
19 | - * getDataCDPP.php | |
20 | - *-----------------------------------------------------------------------*/ | |
21 | - | |
22 | -// Args | |
23 | - $id = $argv[1]; | |
24 | - $ViDir = $argv[2]; | |
25 | - $Start = $argv[3]; | |
26 | - $Stop = $argv[4]; | |
27 | - | |
28 | - | |
29 | -// Env variables | |
30 | - $DDBASEBIN = getenv("DDBASEBIN"); | |
31 | - $DDBASE = getenv("DDBASE"); | |
32 | - $MAX_NAME_LENGTH = 31; | |
33 | - $MAX_VI_NAME_LENGTH = 16; | |
34 | - | |
35 | - $wsdl = "http://cdpp2.cesr.fr:8080/AMDA/services/AMDAServer?WSDL"; | |
36 | -// Opent STDERR stream | |
37 | - $STDERR = fopen("php://stderr","w"); | |
38 | - | |
39 | - define("restrictions", $DDBASE."/../INFO/CDPP_restrictions.xml"); | |
40 | - | |
41 | - try { | |
42 | - $client = new SoapClient($wsdl); | |
43 | - } | |
44 | - catch (SoapFault $exception) { | |
45 | - | |
46 | -fprintf($STDERR,"CDPP WSDL is unreachable \n"); | |
47 | - exit(-1); | |
48 | - } | |
49 | - | |
50 | -// Stamp -> this directory is being updated | |
51 | - $LockName = $ViDir."/LOCK"; | |
52 | - touch($LockName); | |
53 | - | |
54 | -fprintf($STDERR,$ViDir." is LOCKED\n"); | |
55 | - | |
56 | - system("cd ".$ViDir."; ./clean"); | |
57 | -// If name is too long.... | |
58 | - $nc_prefix = strlen($id) > $MAX_VI_NAME_LENGTH ? substr(strtolower($id),0,15): strtolower($id); | |
59 | - | |
60 | - | |
61 | -// If restrictions exists... | |
62 | - $dataset->parameters = null; | |
63 | - if (file_exists(restrictions)) { | |
64 | - $restrictionsDom = new DomDocument('1.0'); | |
65 | - $restrictionsDom -> load(restrictions); | |
66 | - | |
67 | - $dataSetRestrictions = $restrictionsDom->getElementById($id); | |
68 | - | |
69 | - if ($dataSetRestrictions != null) { | |
70 | - $parametres = $dataSetRestrictions->getElementsByTagName("PARAMETER_ID"); | |
71 | - foreach ($parametres as $parameter) { | |
72 | - $param_id = phpversion() >= "5.2.0" ? $parameter->getAttribute("xml:id") : $parameter->getAttribute("id"); | |
73 | - $dataset->parameters .= strtoupper($param_id)." "; | |
74 | - } | |
75 | - } | |
76 | - } | |
77 | - $dataset->datasetID = $id; | |
78 | - $dataset->timeStart = $Start; | |
79 | - $dataset->timeStop = $Stop; | |
80 | - try | |
81 | - { | |
82 | - $result = $client->__soapCall("getNcdfUrls", array($dataset)); | |
83 | - } | |
84 | - catch (SoapFault $exception) | |
85 | - { | |
86 | - unlink($LockName); | |
87 | - fprintf($STDERR, "EXCEPTION".$exception->faultstring."\n"); | |
88 | - exit(-1); | |
89 | - } | |
90 | - | |
91 | - $files = $result->getNcdfUrlsReturn; | |
92 | -fprintf($STDERR, "FILES GOT ".count($files)."\n"); | |
93 | - | |
94 | - if (count($files) > 0) | |
95 | - { | |
96 | - for ($i = 0; $i < count($files); $i++) { | |
97 | - $file = count($files) == 1 ? $files : $files[$i]; | |
98 | - $fileArr = split("/",$file); | |
99 | - $ncFile = $fileArr[count($fileArr)-1]; | |
100 | - $ncFileTrue = ($strLength = strlen($ncFile)) > $MAX_NAME_LENGTH ? | |
101 | - $nc_prefix."_".time().$i.".nc" : $ncFile; | |
102 | - | |
103 | - | |
104 | - if (copy($file,$ViDir."/".$ncFileTrue)) { | |
105 | - | |
106 | - if (strpos($ViDir, "CP_CIS_CODIF_HS_H1_MOMENTS") !== false) system("nc2nc ".$ViDir."/".$ncFileTrue); | |
107 | - | |
108 | - system("cd ".$ViDir."; ".$DDBASEBIN."/TimesUpdate -u ".strtolower($id)."_times.nc ".$ncFileTrue); | |
109 | -fprintf($STDERR, "TIMES IS UPDATED ".$i."\n"); | |
110 | - } | |
111 | - else fprintf($STDERR, $file." is not found\n"); | |
112 | - } | |
113 | - } | |
114 | - | |
115 | - system("cd ".$ViDir."; ".$DDBASEBIN."/TimesUpdateNoData ".strtolower($id)."_times.nc ".$argv[3]." ".$argv[4]); | |
116 | - unlink($LockName); | |
117 | -fprintf($STDERR, "UNLOCK \n"); | |
118 | - | |
119 | -?> |
src/CALLEXT/getDataSKR.php deleted
... | ... | @@ -1,80 +0,0 @@ |
1 | -<?php | |
2 | -/** | |
3 | -* @file getDataSKR.php | |
4 | -* @brief DD_Server tools <br> Gets Data from SKR | |
5 | -* | |
6 | -* @arg remDataSetID ddVIdir StartTime StopTime | |
7 | -* @arg Env Vars: $DDBASE $DDBASEBIN \n | |
8 | -* @arg Executables: skr2nc(DECODERS) TimesUpdate TimesUpdateNoData clean | |
9 | -* | |
10 | -* | |
11 | -* @todo General getData.php(dataBaseID) | |
12 | -* @version $Id: $ | |
13 | -* @date 20 june 2008 | |
14 | -*/ | |
15 | - | |
16 | -// Args | |
17 | - $id = $argv[1]; | |
18 | - $ViDir = $argv[2]; | |
19 | - $Start = $argv[3]; | |
20 | - $Stop = $argv[4]; | |
21 | - | |
22 | -// Env variables | |
23 | - $DDBASEBIN = getenv("DDBASEBIN"); | |
24 | - $DDBASE = getenv("DDBASE"); | |
25 | - $MAX_NAME_LENGTH = 31; | |
26 | - | |
27 | -// SKR STUFF | |
28 | - | |
29 | - $url = "http://rpwsTeam:KronoS04@www.lesia.obspm.fr/kronos/" | |
30 | - | |
31 | -// Open STDERR stream | |
32 | - $STDERR = fopen("php://stderr","w"); | |
33 | - | |
34 | -// Lock VI directory for Updating | |
35 | -// Stamp -> this directory is being updated | |
36 | - $LockName = $ViDir."/LOCK"; | |
37 | - touch($LockName); | |
38 | - | |
39 | -fprintf($STDERR,$ViDir." is LOCKED\n"); | |
40 | -// Send - Receive query | |
41 | - $url .= http_build_query($args); | |
42 | - $fileList = new DOMDocument(); | |
43 | - $fileList->load($url); | |
44 | - $Files = $fileList->getElementsByTagName("url"); | |
45 | - | |
46 | - fprintf($STDERR, "FILES RETURN ". $Files->length."\n"); | |
47 | - | |
48 | -// Clean VI directory | |
49 | - system("cd ".$ViDir."; clean"); | |
50 | - if ($Files->length > 0) { | |
51 | - for ($i = 0; $i < $Files->length; $i++) { | |
52 | - | |
53 | - copy($ViDir."/header.nc","temp.nc"); | |
54 | - $fileName_ = explode("//",$Files->item($i)->nodeValue); | |
55 | - $fileName = $fileName_[0].$passwd.$fileName_[1]; | |
56 | - $fileArr = split("/",$fileName); | |
57 | -// Copy URL file to DD_Server dir | |
58 | - copy($fileName, $fileArr[count($fileArr)-1]); | |
59 | -// Convert ascii TAB to nc using header.nc | |
60 | - system($DDBASEBIN."/ascii2nc ".$fileArr[count($fileArr)-1]); | |
61 | - fprintf($STDERR, "FILE $i TRANSLATED \n"); | |
62 | - unlink($fileArr[count($fileArr)-1]); | |
63 | - $ncFile = name2DD($fileArr[count($fileArr)-1]); | |
64 | -// Truncate file if it is too long | |
65 | - $ncFileTrue = ($strLength = strlen($ncFile)) > $MAX_NAME_LENGTH ? | |
66 | - "t".substr(substr($ncFile, 0, $strLength-3), $strLength-$MAX_NAME_LENGTH+1, $MAX_NAME_LENGTH-4).".nc" : $ncFile; | |
67 | -// Move nc file to VIdir | |
68 | - rename("temp.nc", $ViDir."/".$ncFileTrue); | |
69 | - | |
70 | -// Updates VI time info | |
71 | - system("cd ".$ViDir."; ".$DDBASEBIN."/TimesUpdate -u ".strtolower($id)."_times.nc ".$ncFileTrue); | |
72 | - } | |
73 | - fprintf($STDERR, "TIMES IS UPDATED \n"); | |
74 | - } | |
75 | - | |
76 | - system("cd ".$ViDir."; ".$DDBASEBIN."/TimesUpdateNoData ".strtolower($id)."_times.nc ".$argv[3]." ".$argv[4]); | |
77 | -// Unlock VI dir | |
78 | - unlink($LockName); | |
79 | - fprintf($STDERR, "UNLOCK \n"); | |
80 | -?> |
src/CALLEXT/getDataVEXGRAZ.php deleted
... | ... | @@ -1,90 +0,0 @@ |
1 | -<?php | |
2 | - | |
3 | -/** | |
4 | -* @file getDataVEXGRAZ.php | |
5 | -* @version $Id: getDataVEXGRAZ.php,v 1.4 2009/08/26 09:32:56 budnik Exp $ | |
6 | -* @brief DD_Server tools <br> Gets Data from VEXGRAZ | |
7 | -* | |
8 | -* @arg remDataSetID ddVIdir StartTime StopTime | |
9 | -* Env Vars: $DDBASE $DDBASEBIN \n | |
10 | -* Executables: ascii2nc(DECODERS) TimesUpdate TimesUpdateNoData clean | |
11 | -* | |
12 | -*/ | |
13 | - | |
14 | - require_once 'ddserver_ini.php'; | |
15 | - require_once 'vexgraz_ini.php'; | |
16 | - | |
17 | - function name2DD($fileName) { | |
18 | - | |
19 | - $ncName = prefix.substr($fileName,3,11).".nc"; | |
20 | - | |
21 | - return $ncName; | |
22 | -} | |
23 | - | |
24 | -/* | |
25 | -* Args | |
26 | -*/ | |
27 | - | |
28 | - $id = $argv[1]; | |
29 | - $ViDir = $argv[2]; | |
30 | - $Start = $argv[3]; | |
31 | - $Stop = $argv[4]; | |
32 | - | |
33 | -/* | |
34 | -* Lock VI directory for Updating | |
35 | -* Stamp -> this directory is being updated | |
36 | -*/ | |
37 | - $LockName = $ViDir."/LOCK"; | |
38 | - touch($LockName); | |
39 | - fprintf(STDERR,$ViDir." is LOCKED \n"); | |
40 | - | |
41 | - | |
42 | -/* | |
43 | -* Clean VI directory | |
44 | -*/ | |
45 | - system("cd ".$ViDir."; ./clean"); | |
46 | - | |
47 | -/* | |
48 | -* SPASE Web Service getDatasetUrl() | |
49 | -*/ | |
50 | - $mySpaseDataAccess = new DataAccessSpase(); | |
51 | - | |
52 | - $urlArray = $mySpaseDataAccess->getDatasetUrl($id, $Start, $Stop); | |
53 | - | |
54 | - if ($urlArray !== "NODATA") | |
55 | - foreach ($urlArray as $theUrl) { | |
56 | - | |
57 | - copy($ViDir."/header.nc","temp.nc"); | |
58 | - $fileArr = split("/",$theUrl); | |
59 | - $fileName = $fileArr[count($fileArr)-1]; | |
60 | -/* | |
61 | -* Copy URL file to DD_Server dir and | |
62 | -* Convert ascii TAB to nc using header.nc | |
63 | -*/ | |
64 | - copy($theUrl, $fileName); | |
65 | - system(DDBASEBIN."/ascii2nc ".$fileName." 1"); | |
66 | - fprintf(STDERR, "FILE $theUrl TRANSLATED \n"); | |
67 | - unlink($fileName); | |
68 | - $ncFile = name2DD($fileName); | |
69 | -/* | |
70 | -* Move new nc file to VIdir | |
71 | -*/ | |
72 | - rename("temp.nc", $ViDir."/".$ncFile); | |
73 | - | |
74 | -/* | |
75 | -* Updates VI time info | |
76 | -*/ | |
77 | - system("cd ".$ViDir."; ".DDBASEBIN."/TimesUpdate -u ".prefix."_times.nc ".$ncFile); | |
78 | - | |
79 | - fprintf(STDERR, "TIMES IS UPDATED \n"); | |
80 | - } | |
81 | -/* | |
82 | -* Fill NODATA times in VI time info | |
83 | -*/ | |
84 | - system("cd ".$ViDir."; ".DDBASEBIN."/TimesUpdateNoData ".prefix."_times.nc ".$argv[3]." ".$argv[4]); | |
85 | -/* | |
86 | -* Unlock VI dir | |
87 | -*/ | |
88 | - unlink($LockName); | |
89 | - fprintf(STDERR, "UNLOCK \n"); | |
90 | -?> |