4
"db_server" => "katrin",
5
"db_name" => "hauptspektrometer"
10
function signal_handler($signal) {
15
pcntl_signal(SIGINT, "signal_handler");
18
$res = exec('ps xa | grep "cache.php" | grep -v grep | wc -l');
21
if (preg_match("/(.*)cache.php$/", $_SERVER['SCRIPT_FILENAME'], $m)) @chdir($m[1]);
23
require("../adei.php");
25
function ROOTCache(&$cache, $rootdb, $app, $inq_app, $rootdb_name) {
29
0 => array("pipe", "r"),
30
1 => array("pipe", "w"),
31
2 => array("pipe", "w")
34
$cmd = proc_open($inq_app, $desc, $pipes);
37
fwrite($pipes[0], $rootdb['user'] . "\n");
38
fwrite($pipes[0], $rootdb['password'] . "\n");
42
$start = stream_get_contents($pipes[1]);
45
$errors = stream_get_contents($pipes[2]);
46
$ret = proc_close($cmd);
47
if ($ret) throw new ADEIException("Execution of csv2root is finished with error code $ret");
49
} else throw new ADEIException("Execution of csv2root is failed");
51
if ($start < 0) $start = 0;
53
$ivl = $cache->CreateInterval();
56
$cmd = popen($app, "w");
58
fwrite($cmd, $rootdb['user'] . "\n");
59
fwrite($cmd, $rootdb['password'] . "\n");
61
$cache->ExportCSV(new DATAStreamHandler($cmd), $mask = NULL, $ivl);
62
if ($err = pclose($cmd)) throw new ADEIException("csv2root is finished with error: $err");
63
} catch(ADEIException $e) {
64
echo "Problem processing ROOT database \"" . $rootdb_name . "\": " . $e->getMessage() . "\n";
68
function DoCache(&$req) {
72
$reader = $req->CreateReader(REQUEST::READER_FORBID_CACHEREADER);
73
} catch(ADEIException $e) {
74
return $req->GetLocationString() . ", Error: " . $e->getMessage();
78
$opts = &$req->GetOptions();
79
$rootdb = $opts->Get('root_database');
81
$list = $req->GetGroupList($reader);
82
} catch(ADEIException $e) {
83
return $req->GetLocationString() . ", Error: " . $e->getMessage();
87
if (strchr($rootdb, "/")) {
89
$inq_app = adei_app("csv2root", "--file " . $rootdb . " --inquiry-latest-data", true);
90
$app = adei_app("csv2root", "--file " . $rootdb, true);
94
$db_info['database'] = $rootdb;
95
$database = new DATABASE($db_info);
96
} catch (ADEIException $e) {
97
unset($db_info['database']);
99
$database = new DATABASE($ROOT_DB);
100
$database->CreateDatabase($rootdb);
101
} catch(ADEIException $e) {
102
echo "Problem accessing ROOT database \"$rootdb\": " . $e->getMessage() . "\n";
108
$conprm = $db_info['driver'] . "://" . $db_info['host'] . ($db_info['port']?(":" . $db_info['port']):"") . "/" . $rootdb;
109
$inq_app = adei_app("csv2root", "--db " . $conprm . " --inquiry-latest-data", true);
110
$app = adei_app("csv2root", "--db " . $conprm, true);
114
if ((!$app)||(!$inq_app)) {
115
echo("csv2root is not present");
118
$groups = $reader->GetGroupList(READER::NEED_INFO);
123
foreach ($list as $gid => $greq) {
125
$cache = $greq->CreateCacheUpdater($reader);
128
$grname = " --group " . $groups[$gid]["name"];
129
// ROOTCache($cache, $db_info, $app . $grname, $inq_app . $grname, $conprm?$conprm:$rootdb);
131
} catch(ADEIException $e) {
132
return $greq->GetLocationString() . ", Error: " . $e->getMessage();
139
$req = new REQUEST($config);
140
$list = $req->GetSourceList();
142
foreach ($list as $sreq) {
143
$err = DoCache($sreq);
144
if ($err) echo "$err\n\n\n";
b'\\ No newline at end of file'