]> pere.pagekite.me Git - homepage.git/blobdiff - blog/archive/2009/02/index.html
Generated.
[homepage.git] / blog / archive / 2009 / 02 / index.html
index 1175b02540b00565738c4013dc974c053c445fa7..57a3795dc670f63c24111ca80ad8ef31c49846e4 100644 (file)
@@ -364,7 +364,7 @@ scraping was written by me based on the Dell code.  I know the HTML
 parsing could be done using nice libraries, but did not want to
 introduce more dependencies.  This is the current incarnation:</p>
 
-<p><pre>
+<pre>
 use LWP::Simple;
 use POSIX;
 use WWW::Mechanize;
@@ -376,7 +376,7 @@ sub get_support_info {
 
     if ( $model =~ m/^Dell / ) {
         # fetch website from Dell support
-        my $url = "http://support.euro.dell.com/support/topics/topic.aspx/emea/shared/support/my_systems_info/no/details?c=no&cs=nodhs1&l=no&s=dhs&ServiceTag=$serial";
+        my $url = "http://support.euro.dell.com/support/topics/topic.aspx/emea/shared/support/my_systems_info/no/details?c=no&amp;cs=nodhs1&amp;l=no&amp;s=dhs&amp;ServiceTag=$serial";
         my $webpage = get($url);
         return undef unless ($webpage);
 
@@ -384,14 +384,26 @@ sub get_support_info {
         my @lines = split(/\n/, $webpage);
         foreach my $line (@lines) {
             next unless ($line =~ m/Beskrivelse/);
-            $line =~ s/<[^>]+?>/;/gm;
-            $line =~ m%;(\d{2})/(\d{2})/(\d{4});+(\d{2})/(\d{2})/(\d{4});%g;
-            my $start = "$3-$1-$2";
-            my $end = "$6-$4-$5";
-            $str = "$start -> $end";
+            $line =~ s/&lt;[^>]+?>/;/gm;
+            $line =~ s/^.+?;(Beskrivelse;)/$1/;
+
+            my @f = split(/\;/, $line);
+            @f = @f[13 .. $#f];
+            my $lastend = "";
+            while ($f[3] eq "DELL") {
+                my ($type, $startstr, $endstr, $days) = @f[0, 5, 7, 10];
+
+                my $start = POSIX::strftime("%Y-%m-%d",
+                                            localtime(str2time($startstr)));
+                my $end = POSIX::strftime("%Y-%m-%d",
+                                          localtime(str2time($endstr)));
+                $str .= "$type $start -> $end ";
+                @f = @f[14 .. $#f];
+                $lastend = $end if ($end gt $lastend);
+            }
             my $today = POSIX::strftime("%Y-%m-%d", localtime(time));
             tag_machine_unsupported($machine)
-                if ($end lt $today);
+                if ($lastend lt $today);
         }
     } elsif ( $model =~ m/^HP / ) {
         my $mech = WWW::Mechanize->new();
@@ -410,7 +422,7 @@ sub get_support_info {
         # Next step is screen scraping
         my $content = $mech->content();
 
-        $content =~ s/<[^>]+?>/;/gm;
+        $content =~ s/&lt;[^>]+?>/;/gm;
         $content =~ s/\s+/ /gm;
         $content =~ s/;\s*;/;;/gm;
         $content =~ s/;[\s;]+/;/gm;
@@ -432,12 +444,13 @@ sub get_support_info {
                 if ($end lt $today);
         }
     } elsif ( $model =~ m/^IBM / ) {
+        # This code ignore extended support contracts.
         my ($producttype) = $model =~ m/.*-\[(.{4}).+\]-/;
-        if ($producttype && $serial) {
+        if ($producttype &amp;&amp; $serial) {
             my $content =
-                get("http://www-947.ibm.com/systems/support/supportsite.wss/warranty?action=warranty&brandind=5000008&Submit=Submit&type=$producttype&serial=$serial");
+                get("http://www-947.ibm.com/systems/support/supportsite.wss/warranty?action=warranty&amp;brandind=5000008&amp;Submit=Submit&amp;type=$producttype&amp;serial=$serial");
             if ($content) {
-                $content =~ s/<[^>]+?>/;/gm;
+                $content =~ s/&lt;[^>]+?>/;/gm;
                 $content =~ s/\s+/ /gm;
                 $content =~ s/;\s*;/;;/gm;
                 $content =~ s/;[\s;]+/;/gm;
@@ -455,22 +468,27 @@ sub get_support_info {
     }
     return $str;
 }
-</pre></p>
+</pre>
 
 <p>Here are some examples on how to use the function, using fake
 serial numbers.  The information passed in as arguments are fetched
 from dmidecode.</p>
 
-<p><pre>
+<pre>
 print get_support_info("hp.host", "HP ProLiant BL460c G1", "1234567890"
                        "447707-B21");
 print get_support_info("dell.host", "Dell Inc. PowerEdge 2950", "1234567");
 print get_support_info("ibm.host", "IBM eserver xSeries 345 -[867061X]-",
                        "1234567");
-</pre></p>
+</pre>
 
 <p>I would recommend this approach for tracking support contracts for
-everyone with more than a new computers to administer. :)</p>
+everyone with more than a few computers to administer. :)</p>
+
+<p>Update 2009-03-06: The IBM page do not include extended support
+contracts, so it is useless in that case.  The original Dell code do
+not handle extended support contracts either, but has been updated to
+do so.</p>
 
  </div>
  <div class="tags">
@@ -492,6 +510,17 @@ everyone with more than a new computers to administer. :)</p>
 <h2>Archive</h2>
 <ul>
 
+<li>2010
+<ul>
+
+<li><a href="../../../archive/2010/01/">January (2)</a></li>
+
+<li><a href="../../../archive/2010/02/">February (1)</a></li>
+
+<li><a href="../../../archive/2010/03/">March (3)</a></li>
+
+</ul></li>
+
 <li>2009
 <ul>
 
@@ -499,6 +528,26 @@ everyone with more than a new computers to administer. :)</p>
 
 <li><a href="../../../archive/2009/02/">February (8)</a></li>
 
+<li><a href="../../../archive/2009/03/">March (12)</a></li>
+
+<li><a href="../../../archive/2009/04/">April (10)</a></li>
+
+<li><a href="../../../archive/2009/05/">May (9)</a></li>
+
+<li><a href="../../../archive/2009/06/">June (3)</a></li>
+
+<li><a href="../../../archive/2009/07/">July (4)</a></li>
+
+<li><a href="../../../archive/2009/08/">August (3)</a></li>
+
+<li><a href="../../../archive/2009/09/">September (1)</a></li>
+
+<li><a href="../../../archive/2009/10/">October (2)</a></li>
+
+<li><a href="../../../archive/2009/11/">November (3)</a></li>
+
+<li><a href="../../../archive/2009/12/">December (3)</a></li>
+
 </ul></li>
 
 <li>2008
@@ -517,39 +566,53 @@ everyone with more than a new computers to administer. :)</p>
 <h2>Tags</h2>
 <ul>
 
- <li><a href="../../../tags/3d-printer">3d-printer (7)</a></li>
+ <li><a href="../../../tags/3d-printer">3d-printer (11)</a></li>
 
  <li><a href="../../../tags/amiga">amiga (1)</a></li>
 
  <li><a href="../../../tags/aros">aros (1)</a></li>
 
- <li><a href="../../../tags/debian">debian (3)</a></li>
+ <li><a href="../../../tags/debian">debian (14)</a></li>
 
- <li><a href="../../../tags/debian edu">debian edu (4)</a></li>
+ <li><a href="../../../tags/debian edu">debian edu (12)</a></li>
 
- <li><a href="../../../tags/english">english (6)</a></li>
+ <li><a href="../../../tags/english">english (20)</a></li>
 
  <li><a href="../../../tags/fiksgatami">fiksgatami (1)</a></li>
 
+ <li><a href="../../../tags/fildeling">fildeling (5)</a></li>
+
+ <li><a href="../../../tags/kart">kart (2)</a></li>
+
+ <li><a href="../../../tags/lenker">lenker (1)</a></li>
+
  <li><a href="../../../tags/ltsp">ltsp (1)</a></li>
 
- <li><a href="../../../tags/multimedia">multimedia (2)</a></li>
+ <li><a href="../../../tags/multimedia">multimedia (5)</a></li>
+
+ <li><a href="../../../tags/norsk">norsk (64)</a></li>
 
- <li><a href="../../../tags/norsk">norsk (22)</a></li>
+ <li><a href="../../../tags/nuug">nuug (67)</a></li>
 
- <li><a href="../../../tags/nuug">nuug (20)</a></li>
+ <li><a href="../../../tags/opphavsrett">opphavsrett (11)</a></li>
 
- <li><a href="../../../tags/personvern">personvern (3)</a></li>
+ <li><a href="../../../tags/personvern">personvern (10)</a></li>
 
- <li><a href="../../../tags/reprap">reprap (7)</a></li>
+ <li><a href="../../../tags/reprap">reprap (10)</a></li>
 
  <li><a href="../../../tags/rss">rss (1)</a></li>
 
+ <li><a href="../../../tags/sikkerhet">sikkerhet (5)</a></li>
+
+ <li><a href="../../../tags/standard">standard (11)</a></li>
+
  <li><a href="../../../tags/stavekontroll">stavekontroll (1)</a></li>
 
- <li><a href="../../../tags/video">video (3)</a></li>
+ <li><a href="../../../tags/video">video (10)</a></li>
+
+ <li><a href="../../../tags/vitenskap">vitenskap (1)</a></li>
 
- <li><a href="../../../tags/web">web (2)</a></li>
+ <li><a href="../../../tags/web">web (5)</a></li>
 
 </ul>