aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam McLoughlin <hexxeh@hexxeh.net>2011-07-11 14:59:51 +0100
committerLiam McLoughlin <hexxeh@hexxeh.net>2011-07-11 14:59:51 +0100
commitcb7c822b0284d11d16b49023162820d1ffca6fdd (patch)
tree18102deaecf445568d30bb63187294b0cceb10f2 /status.php
parentAdded compress flag to build tool (diff)
downloadgentoaster-cb7c822b0284d11d16b49023162820d1ffca6fdd.tar.gz
gentoaster-cb7c822b0284d11d16b49023162820d1ffca6fdd.tar.bz2
gentoaster-cb7c822b0284d11d16b49023162820d1ffca6fdd.zip
Fixed hostname setting and changed Gearman daemon/client to meet Zend coding standard
Diffstat (limited to 'status.php')
-rw-r--r--status.php65
1 files changed, 35 insertions, 30 deletions
diff --git a/status.php b/status.php
index e5624dd..a69bc35 100644
--- a/status.php
+++ b/status.php
@@ -1,33 +1,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");
- $result = mysql_query("SELECT handle FROM builds WHERE id = '".mysql_real_escape_string($argv[1])."'");
- if(mysql_num_rows($result) == 1) {
- $handles = mysql_fetch_array($result);
- $handle = $handles[0];
- $client = new GearmanClient();
- $client->addServer();
+ 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") . ", progress: " . ceil($status[2]/$status[3]*100) . "%, numerator: " . $status[2] . ", denomintor: " . $status[3] . "\n";
- } else {
- echo "Task has not yet been processed\n";
- }
- } else {
- $result = mysql_query("SELECT returncode, result FROM builds WHERE id = '".mysql_real_escape_string($argv[1])."'");
- $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";
- }
+ $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";
+ }
-?>