Tim Landscheidt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/201923

Change subject: WIP: Fix undefined variable warnings in status.php
......................................................................

WIP: Fix undefined variable warnings in status.php

Live test at https://tools.wmflabs.org/?statusscfc; isn't done yet.

Change-Id: I90b7c8278e6f9877e043b21841e74182ee1d6b91
---
M www/content/status.php
1 file changed, 22 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/labs/toollabs 
refs/changes/23/201923/1

diff --git a/www/content/status.php b/www/content/status.php
index 4fa2554..eea8f60 100644
--- a/www/content/status.php
+++ b/www/content/status.php
@@ -1,4 +1,4 @@
-<?
+<?php
   function humantime($secs) {
     if($secs < 120)
       return "$secs"."s";
@@ -44,19 +44,25 @@
           'submit' => (string)$xjob->JB_submission_time,
           'owner'  => (string)$xjob->JB_owner,
           'tool'   => preg_replace('/^tools\.(.*)$/', '$1', 
(string)$xjob->JB_owner),
-          'queue'  => 
(string)$xjob->JB_hard_queue_list->destin_ident_list->QR_name,
       );
-      if($job['queue'] == '')
+      if($xjob->JB_hard_queue_list) {
+          $job['queue'] = 
(string)$xjob->JB_hard_queue_list->destin_ident_list->QR_name;
+      } else {
           $job['queue'] = '(manual)';
+      }
       foreach($xjob->JB_hard_resource_list->qstat_l_requests as $lreq) {
           if($lreq->CE_name == 'h_vmem')
               $job['h_vmem'] = (int)$lreq->CE_doubleval;
       }
-      foreach($xjob->JB_ja_tasks->jatask->JAT_scaled_usage_list->scaled as 
$usage) {
-          $job[(string)$usage->UA_name] = (int)$usage->UA_value;
+      if($xjob->JB_ja_tasks->jatask && 
$xjob->JB_ja_tasks->jatask->JAT_scaled_usage_list) {
+          foreach($xjob->JB_ja_tasks->jatask->JAT_scaled_usage_list->scaled as 
$usage) {
+              $job[(string)$usage->UA_name] = (int)$usage->UA_value;
+          }
       }
-      foreach($xjob->JB_ja_tasks->ulong_sublist->JAT_scaled_usage_list->scaled 
as $usage) {
-          $job[(string)$usage->UA_name] = (int)$usage->UA_value;
+      if($xjob->JB_ja_tasks->ulong_sublist && 
$xjob->JB_ja_tasks->ulong_sublist->JAT_scaled_usage_list) {
+          
foreach($xjob->JB_ja_tasks->ulong_sublist->JAT_scaled_usage_list->scaled as 
$usage) {
+              $job[(string)$usage->UA_name] = (int)$usage->UA_value;
+          }
       }
       $jobs[$job['num']] = $job;
   }
@@ -104,12 +110,13 @@
             <p>This is the web server for the Tool Labs project, the home of 
community-maintained external tools supporting Wikimedia projects and their 
users.</p>
 
             <h2>Grid Status</h2>
-<?
+<?php
 
   ksort($hosts);
   ksort($jobs);
 
   foreach($hosts as $host => $h):
+      # fwrite(STDERR, '#####' . var_export($host, true) . '#' . 
var_export($h, true));
       $hvmem = $h['h_vmem'];
       foreach($h['jobs'] as $jn) {
           $hvmem -= $jobs[$jn]['h_vmem'];
@@ -122,9 +129,9 @@
               <span class="hostname"><?= $host ?></span>
               <b>Load:</b> <?= (int)($h['load_avg']*1000)/($h['num_proc']*10) 
?>%
               <b>Memory:</b> <?= (int)($h['mem']*1000)/10 ?>%
-              <? if($h['h_vmem'] > 0): ?>
-                  <b>Free vmem:</b> <? echo humanmem($hvmem); ?>
-              <? endif; ?>
+              <?php if($h['h_vmem'] > 0): ?>
+                  <b>Free vmem:</b> <?php echo humanmem($hvmem); ?>
+              <?php endif; ?>
             </div>
             <table class="hostjobs tablesorter">
               <thead>
@@ -139,7 +146,7 @@
                 </tr>
               </thead>
               <tbody>
-      <?
+      <?php
       foreach($jobs as $jobid => $j):
       if($j['host'] != $host)
         continue;
@@ -152,14 +159,14 @@
                   <td class="jobtime"><?= strftime("%F %T", $j['submit']) 
?></td>
                   <td class="jobcpu"><?= humantime($j['cpu']) ?></td>
                   <td class="jobvmem">
-                    <?= humanmem($j['vmem']/(1024*1024)) ?>/<?= 
humanmem($j['h_vmem']/(1024*1024)) ?> <? if($j['maxvmem'] > $j['vmem']*1.02): 
?>(peak <?= humanmem($j['maxvmem']/(1024*1024)) ?>)<? endif; ?>
+                    <?= humanmem($j['vmem']/(1024*1024)) ?>/<?= 
humanmem($j['h_vmem']/(1024*1024)) ?> <?php if($j['maxvmem'] > 
$j['vmem']*1.02): ?>(peak <?= humanmem($j['maxvmem']/(1024*1024)) ?>)<?php 
endif; ?>
                   </td>
                 </tr>
-      <?
+      <?php
           endforeach;
       ?>
               </tbody>
             </table>
-<?
+<?php
   endforeach;
 ?>

-- 
To view, visit https://gerrit.wikimedia.org/r/201923
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I90b7c8278e6f9877e043b21841e74182ee1d6b91
Gerrit-PatchSet: 1
Gerrit-Project: labs/toollabs
Gerrit-Branch: master
Gerrit-Owner: Tim Landscheidt <t...@tim-landscheidt.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to