[Dehs-devel] r70 - in trunk: . www

atomo64-guest at alioth.debian.org atomo64-guest at alioth.debian.org
Wed Dec 12 01:23:48 UTC 2007


Author: atomo64-guest
Date: 2007-12-12 01:23:48 +0000 (Wed, 12 Dec 2007)
New Revision: 70

Modified:
   trunk/dehs.config.inc
   trunk/dehs_pg.php
   trunk/update_wwwal.sh
   trunk/www/no_updated.php
Log:
update_wwwal.sh: added generation of simple stats
dehs_pg.php: added code for PTS-based new upstream version notification (currently disabled)
NOTE: 'updated' in the database is true when the package is NOT updated, and false when it is!

Modified: trunk/dehs.config.inc
===================================================================
--- trunk/dehs.config.inc	2007-12-09 16:22:12 UTC (rev 69)
+++ trunk/dehs.config.inc	2007-12-12 01:23:48 UTC (rev 70)
@@ -22,5 +22,7 @@
 /*1: watch url, 2: $space, 3: name, 4: file ext, 5: extra options*/
 $watchFormat = 'version=3' . "\n" . '%5$s' . "\n" . '%1$s%2$s%3$s-?_?([\d+\.]+|\d+)\.%4$s debian uupdate';
 $fetchUpstreamChanges = false;
+$sendNotifications = false;
+$notificationsMailFrom = 'Debian External Health System <dehs-devel at lists.alioth.debian.org>';
 $_SERVER['SERVER_NAME']=shell_exec("hostname -f 2>&1");
 ?>
\ No newline at end of file

Modified: trunk/dehs_pg.php
===================================================================
--- trunk/dehs_pg.php	2007-12-09 16:22:12 UTC (rev 69)
+++ trunk/dehs_pg.php	2007-12-12 01:23:48 UTC (rev 70)
@@ -463,6 +463,10 @@
         if ($uscan_res[3]!=null) $version=$uscan_res[3];
         #$updated=is_updated($uscan_res[0],$res_array[version]);
         $updated=$uscan_res[4];
+        if (!$updated) {
+            events::newVersion($res_array['name'], $res_array['version'], $uscan_res[0], $res_array['dist']);
+        }
+
         if ($uscan_res[0]!=$res_array[up_version]) ($keep_changes=1);
         else $keep_changes=0;
         $up_url=iconv("ISO-8859-1","UTF-8",$uscan_res[2]);
@@ -770,7 +774,13 @@
                     } else {
                         $keep_changes = 0;
                     }
-                    pg_exec($db, "UPDATE pkgs SET wwiz='" . pg_escape_string($watch) ."', wwiz_type='watch', wwiz_version='" . pg_escape_string($uscan_res[0]) . "', up_url='" . pg_escape_string($uscan_res[2]) . "', keep_changes='$keep_changes' where name='" . pg_escape_string($res_array[name]) . "' AND dist='" . $res_array[dist] ."'");
+                    $updated=$uscan_res[4];
+
+                    if (!$updated) {
+                        //FIXME: events::newVersion($res_array['name'], , $uscan_res[0], $res_array['dist']);
+                    }
+
+                    pg_exec($db, "UPDATE pkgs SET wwiz='" . pg_escape_string($watch) ."', wwiz_type='watch', wwiz_version='" . pg_escape_string($uscan_res[0]) . "', up_url='" . pg_escape_string($uscan_res[2]) . "', keep_changes='$keep_changes', updated='$updated' where name='" . pg_escape_string($res_array[name]) . "' AND dist='" . $res_array[dist] ."'");
                 }
             }
         } else {
@@ -799,7 +809,8 @@
     foreach ($dists as $dist) {
         $id=dbqa_conn($dir1 . "dehs_qa_" . $dist . ".db",'n');
         $db = pg_pconnect($dbconn) or die_status ("Db error");
-        $sql="SELECT name, id, up_version, wwiz_version, watch, wwiz_type, watch_warn, updated FROM pkgs WHERE dist='$dist'";
+        $sql="SELECT name, id, up_version, wwiz_version, watch, wwiz_type, watch_warn, updated, version FROM pkgs WHERE dist='$dist'";
+        //TOADD: versionmangled
         $rsql=pg_exec($db, $sql);
         while($res_array=pg_fetch_array($rsql)) {
 
@@ -812,7 +823,10 @@
 
             $xml="<data><id>$res_array[id]</id>" .
             "<up_version>$version</up_version>" .
+            //"<dversion>$res_array[version]</dversion>" .
+            //"<dversionmangled>$res_array[versionmangled]</dversionmangled>" .
             "<wwiz>$wwiz</wwiz>" .
+            //"<updated>" . ($res_array['updated']=='f')? 'true': 'false' . "</updated>" .
             "</data>";
             $value=addslashes($xml);
             dba_replace($res_array[name],$xml,$id);
@@ -913,4 +927,72 @@
         die($status);
     }
 }
+
+class events
+{
+    function newVersion($sourcePackage, $currentVersion, $newVersion, $distribution, $downloadLink = '')
+    {
+        global $base, $sendNotifications;
+
+        if (!$sendNotifications) {
+            return null;
+        }
+
+        $tpl = file_get_contents($base . '/tpls/new_version.mail.tpl');
+
+        $search  = array();
+        $replace = array();
+
+        $search [] = '#PACKAGE#';
+        $replace[] = $sourcePackage;
+        $search [] = '#DVERSION#';
+        $replace[] = $currentVersion;
+        $search [] = '#UVERSION#';
+        $replace[] = $newVersion;
+        $search [] = '#DISTRO#';
+        $replace[] = $distribution;
+
+        $message = str_replace($search, $replace, $tpl);
+        $subject = events::_extractHeader('subject', $message);
+        $to      = events::_extractHeader('to', $message);
+
+        $extraHeaders = events::_getTefaultExtraHeaders();
+        $extraHeaders[] = 'X-DEHS-UVERSION: ' . $newVersion;
+
+        return mail($to, $subject, $message, implode("\r\n", $extraHeaders));
+    }
+
+    function _extractHeader($header, &$message)
+    {
+        $regex  = '/^' . preg_quote($header, '/') . ':([ \t]*)(.*)$/i';
+
+        $matches = array();
+
+        if (preg_match($regex, $message, $matches)) {
+
+            $spacer = $matches[1];
+            $value  = $matches[2];
+
+            $message = ltrim(preg_replace($regex, '', $message));
+
+            return $value;
+
+        }
+        return false;
+    }
+
+    function _getTefaultExtraHeaders()
+    {
+        global $notificationsMailFrom;
+        $headers = array();
+
+        $headers[] = 'From: ' . $notificationsMailFrom;
+        $headers[] = 'X-PTS-Approved: sure';
+        $headers[] = 'X-BY-DEHS: sure';
+
+        return $headers;
+    }
+
+}
+
 ?>
\ No newline at end of file

Modified: trunk/update_wwwal.sh
===================================================================
--- trunk/update_wwwal.sh	2007-12-09 16:22:12 UTC (rev 69)
+++ trunk/update_wwwal.sh	2007-12-12 01:23:48 UTC (rev 70)
@@ -13,3 +13,36 @@
 psql -A -q -d dehs -c "SELECT name || ': Error' FROM pkgs WHERE up_version='' AND watch!='' AND dist='unstable' order by name asc;" | egrep -v '\?column\?|rows\)'  > /org/alioth.debian.org/chroot/home/groups/dehs/htdocs/no_upstream.txt
 psql -A -q -d dehs -c "SELECT name || ': ' || up_version FROM pkgs WHERE up_version!='' AND watch!='' AND dist='unstable' order by name asc;" | egrep -v '\?column\?|rows\)'  > /org/alioth.debian.org/chroot/home/groups/dehs/htdocs/no_updated.txt
 psql -A -q -d dehs -c "SELECT name || ': N/A' FROM pkgs WHERE watch IS NULL OR watch=''  AND dist='unstable' UNION SELECT name || ': Error' FROM pkgs WHERE up_version='' AND watch!='' AND dist='unstable' UNION SELECT name || ': ' || up_version FROM pkgs WHERE up_version!='' AND watch!='' AND dist='unstable';" | egrep -v '\?column\?|rows\)'  > /org/alioth.debian.org/chroot/home/groups/dehs/htdocs/dehs_debianqa.txt
+
+STATS=/org/alioth.debian.org/chroot/home/groups/dehs/htdocs/dehs_stats.txt
+cat /dev/null > $STATS
+echo -n 'watch_count:' >> $STATS
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE watch!='';" | egrep -v '[^0-9]' >> $STATS
+echo -n 'watch_count_unstable:' >> $STATS
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE watch!='' AND dist='unstable';" | egrep -v '[^0-9]' >> $STATS
+echo -n 'watch_count_experimental:' >> $STATS
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE watch!='' AND dist='experimental';" | egrep -v '[^0-9]' >> $STATS
+echo -n 'no_watch_count:' >> $STATS
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE watch IS NULL OR watch='';"  | egrep -v '[^0-9]' >> $STATS
+echo -n 'no_watch_count_unstable:' >> $STATS
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE (watch IS NULL OR watch='') AND dist='unstable';"  | egrep -v '[^0-9]' >> $STATS
+echo -n 'no_watch_count_experimental:' >> $STATS
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE (watch IS NULL OR watch='') AND dist='experimental';"  | egrep -v '[^0-9]' >> $STATS
+echo -n 'watch_failed:' >> $STATS
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE up_version='' AND watch!='';" | egrep -v '[^0-9]' >> $STATS
+echo -n 'watch_failed_unstable:' >> $STATS
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE up_version='' AND watch!='' AND dist='unstable';" | egrep -v '[^0-9]' >> $STATS
+echo -n 'watch_failed_experimental:' >> $STATS
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE up_version='' AND watch!='' AND dist='experimental';" | egrep -v '[^0-9]' >> $STATS
+echo -n 'wwiz_count:' >> $STATS
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE wwiz_type='watch';" | egrep -v '[^0-9]' >> $STATS
+echo -n 'wwiz_count_unstable:' >> $STATS
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE wwiz_type='watch' AND dist='unstable';" | egrep -v '[^0-9]' >> $STATS
+echo -n 'wwiz_count_experimental:' >> $STATS
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE wwiz_type='watch' AND dist='experimental';" | egrep -v '[^0-9]' >> $STATS
+echo -n 'updated_count:' >> $STATS
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='f';" | egrep -v '[^0-9]' >> $STATS
+echo -n 'updated_count_unstable:' >> $STATS
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='f' AND dist='unstable';" | egrep -v '[^0-9]' >> $STATS
+echo -n 'updated_count_experimental:' >> $STATS
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='f' AND dist='experimental';" | egrep -v '[^0-9]' >> $STATS
\ No newline at end of file

Modified: trunk/www/no_updated.php
===================================================================
--- trunk/www/no_updated.php	2007-12-09 16:22:12 UTC (rev 69)
+++ trunk/www/no_updated.php	2007-12-12 01:23:48 UTC (rev 70)
@@ -1,18 +1,18 @@
 <?/*
- 
+
  Originally written by Stefano Fabri <bluefuture at nospam@email.it>
  Copyright 2004, Stefano Fabri
- 
+
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
- 
+
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
- 
+
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
@@ -32,14 +32,14 @@
 <?
 require("config_www.inc");
 $rsql=pg_exec($db,
-"Select id,mpop_inst,name,version,bytes, tot_up_error,tot_avg_error_date,pkgs.dist,up_version,watch_warn, up_changes from pkgs 
-INNER join (Select max(pop_inst) as mpop_inst,SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist) as binpkgs using(name,dist) 
+"Select id,mpop_inst,name,version,bytes, tot_up_error,tot_avg_error_date,pkgs.dist,up_version,watch_warn, up_changes from pkgs
+INNER join (Select max(pop_inst) as mpop_inst,SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist) as binpkgs using(name,dist)
 where updated='1' AND up_version!=''
 order by mpop_inst desc;") OR Die("Error on query");;
 $rsql2=pg_exec($db, "SELECT count(name) from pkgs WHERE up_version IS NOT NULL") OR Die("Errore on query");
 $totnowatch=pg_numrows($rsql);
 $totpkgs=pg_fetch_array($rsql2,0);
-print "<b>Total Packages need to be get in sync</b>: $totnowatch 
+print "<b>Total packages needing to be synced</b>: $totnowatch
 		<b>Total with upstream found:</b> $totpkgs[0] <b>Percentage: </b> " . number_format ( $totnowatch/$totpkgs[0] * 100, 2, ",",".") . "%" ;
 ?>
 <table
@@ -58,7 +58,7 @@
 		 <td style="vertical-align: top; text-align: center; font-weight: bold;">Distrib</td>
       <td style="vertical-align: top;text-align: center; font-weight: bold;">Uscan Errors processing Watch File</td>
     </tr>
-<?         
+<?
         	while ($res_array=pg_fetch_array($rsql)) {
 ?>
     <tr>
@@ -71,7 +71,7 @@
 	   		<a href="<? print "wwiz_detail.php?id=$res_array[id]&type=up_changes";?>">
 		  	<? print htmlentities($res_array["up_version"]); ?></a><br>
 		<?}
-		else print $res_array["up_version"].'<br>';?>	
+		else print $res_array["up_version"].'<br>';?>
       </td>
 	   <td style="vertical-align: top;"><? print $res_array["version"]; ?><br>
       </td>
@@ -85,10 +85,10 @@
 	  <td style="vertical-align: top;"><? print htmlentities($res_array["watch_warn"]); ?><br>
       </td>
     </tr>
-<? 
+<?
     	}
 	pg_close($db);
-?>	
+?>
   </tbody>
 </table>
 <br>




More information about the Dehs-devel mailing list