blob: a69bc35f50a2bf829adcc43405581a0fbe138cfd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
<?php
if (!isset($argv[1])) die("No handle hash given\n");
$db = mysql_connect("localhost", "gentoaster", "");
if (!$db) die("Could not connect to database ".mysql_error()."\n");
mysql_select_db("gentoaster");
$query = "SELECT handle FROM builds ".
"WHERE id = '".mysql_real_escape_string($argv[1])."'";
$result = mysql_query($query);
if (mysql_num_rows($result) == 1) {
$handles = mysql_fetch_array($result);
$handle = $handles[0];
$client = new GearmanClient();
$client->addServer();
$status = $client->jobStatus($handle);
if ($status[0]) {
if ($status[3] != 0) {
echo "Running: " . ($status[1] ? "true" : "false");
echo ", progress: ".ceil($status[2]/$status[3]*100) . "%, ";
echo $status[2] . "/" . $status[3] . "\n";
} else {
echo "Task has not yet been processed\n";
}
} else {
$query = "SELECT returncode, result FROM builds ".
"WHERE id = '".mysql_real_escape_string($argv[1])."'";
$result = mysql_query($query);
$jobres = mysql_fetch_array($result);
if ($jobres[0] !== NULL) {
echo "Job returned with code ".$jobres[0].": ".$jobres[1]."\n";
} else {
echo "Job failed\n";
}
}
} else {
echo "Invalid handle hash\n";
}
|