~ubuntu-branches/ubuntu/oneiric/wmfrog/oneiric

« back to all changes in this revision

Viewing changes to debian/patches/20-weather.pl.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Jari Aalto
  • Date: 2008-11-07 09:57:30 UTC
  • Revision ID: james.westby@ubuntu.com-20081107095730-u4r34q323hjw5w6m
Tags: 0.2.0-1
Initial release (RFP/ITP; Closes: #504786).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh /usr/share/dpatch/dpatch-run
 
2
## /tmp/weather.pl.patch.dpatch by  <jari.aalto@cante.net>
 
3
##
 
4
## All lines beginning with `## DP:' are a description of the patch.
 
5
## DP: Fix Perl warnings, array subscript, test directory
 
6
 
 
7
@DPATCH@
 
8
 
 
9
diff --git a/Src/weather.pl b/Src/weather.pl
 
10
index 27a4f88..247e02c 100755
 
11
--- a/Src/weather.pl
 
12
+++ b/Src/weather.pl
 
13
@@ -2,18 +2,15 @@
 
14
 #Thibaut Colar: http://www.colar.net/ 
 
15
 #2002/05
 
16
 
 
17
-#The Weather data can be retrieved through http of ftp.
 
18
-#Http is faster, however this might get broken if NOAA change their webpage layout
 
19
+#The Weather data can be retrived through http of ftp.
 
20
+#Http is faster, however this might get broken if NOAA change theyr webpage layout
 
21
 #in wich case you should choose ftp.
 
22
 $mode="http"; # html || ftp
 
23
 
 
24
-
 
25
 ########################################
 
26
 # Start:
 
27
 ########################################
 
28
-($station,$tmpfolder)=@ARGV;
 
29
-
 
30
-mkdir($tmpfolder); 
 
31
+($station,$tmpfolder, $debug)=@ARGV;
 
32
 
 
33
 $html="http://weather.noaa.gov/cgi-bin/mgetmetar.pl?cccc=${station}";
 
34
 $ftp="ftp://weather.noaa.gov/data/observations/metar/stations/${station}.TXT";
 
35
@@ -28,7 +25,7 @@ if($mode eq "ftp")
 
36
 $line="";
 
37
 $file="${tmpfolder}/${station}_dat";
 
38
 open(DATA,"<$file");
 
39
-$allGood=0;
 
40
+# $allGood=0;
 
41
 if($mode eq "http")
 
42
 {
 
43
     while((! ($line=~m/START BODY OF TEXT HERE/)) && !eof(DATA))
 
44
@@ -51,7 +48,7 @@ exit(0);
 
45
 }
 
46
 $line=<DATA>;
 
47
 chomp $line;
 
48
-($crap,$time)=split(/\ /,$line);
 
49
+(undef,$time)=split(/\ /,$line);
 
50
 ($hour,$minute)=split(/:/,$time);
 
51
 $line="";
 
52
 if($mode eq "http")
 
53
@@ -72,45 +69,45 @@ close DATA;
 
54
 chomp $line;
 
55
 @args=split(/\ /,$line);
 
56
 
 
57
-if(debug)
 
58
+if ($debug)
 
59
 {
 
60
-       #print "@args\n";
 
61
+       print "@args\n";
 
62
 }
 
63
 
 
64
 $i=0;
 
65
-$station=@args[$i];
 
66
+$station=$args[$i];
 
67
 if(($station eq 'METAR') or ($station eq 'SPECI'))
 
68
 {
 
69
-       $station=@args[$i+1];
 
70
+       $station=$args[$i+1];
 
71
        $i++;
 
72
 }
 
73
 $i++;
 
74
 $i++;#time
 
75
-$wind=@args[$i];
 
76
+$wind=$args[$i];
 
77
 if($wind eq 'AUTO')
 
78
 {
 
79
-       $wind=@args[$i+1];
 
80
+       $wind=$args[$i+1];
 
81
        $i++;
 
82
 }
 
83
 $i++;
 
84
-$visibility=@args[$i];
 
85
+$visibility=$args[$i];
 
86
 $i++;#Visibility
 
87
 if( ! ($visibility=~m/SM/ || ($visibility eq "CAVOK")) )
 
88
 {
 
89
        #print "Visibility fraction\n";
 
90
        $i++; # visibility with fractions, ignoring
 
91
 }
 
92
-$next=@args[$i];
 
93
+$next=$args[$i];
 
94
 if($next=~m/FT/)
 
95
 {
 
96
        #print "Visibility feet\n";
 
97
        $i++; # visibility in feet, ignoring
 
98
 }
 
99
 
 
100
-$tmp="";
 
101
+# $tmp="";
 
102
 $weather="";
 
103
 $clouds="";
 
104
-while((! (@args[$i]=~/\//)) && ($i<@args))
 
105
+while((! ($args[$i]=~/\//)) && ($i<@args))
 
106
 {
 
107
 
 
108
     $intensity="";
 
109
@@ -119,7 +116,7 @@ while((! (@args[$i]=~/\//)) && ($i<@args))
 
110
     $obsc="";
 
111
     $misc="";
 
112
     $j=0;
 
113
-    $curent=@args[$i];
 
114
+    $curent=$args[$i];
 
115
     $wasCloud="no";
 
116
 
 
117
     if($curent=~/^CAVOK/)
 
118
@@ -130,7 +127,7 @@ while((! (@args[$i]=~/\//)) && ($i<@args))
 
119
     if($curent=~/^VV/)
 
120
     {
 
121
        $clouds.="VV,".substr($curent,2,3).";";
 
122
-       $wasNotCloud="yes";
 
123
+       # $wasNotCloud="yes";
 
124
     }
 
125
     if(($curent=~/^CLR/) or ($curent=~/^SCK/) or ($curent=~/^FEW/) or ($curent=~/^SCT/)  or ($curent=~/^BKN/)   or ($curent=~/^OVC/))
 
126
        {
 
127
@@ -183,7 +180,7 @@ if(($wasCloud ne "yes"))
 
128
 }    
 
129
     $i++;
 
130
 }
 
131
-($temp,$dew)=split(/\//,@args[$i]);
 
132
+($temp,$dew)=split(/\//,$args[$i]);
 
133
 
 
134
 
 
135
 $dir=substr($wind,0,3);
 
136
@@ -242,32 +239,37 @@ if($dew eq "")
 
137
 }
 
138
 
 
139
 #check for ok temperature
 
140
-open(GREP, "grep Temp $tmpfolder/${station} | ");
 
141
-$templine=<GREP>;
 
142
-$templine=~m/^Temp:(.*)$/;
 
143
+
 
144
+if ( -d "$tmpfolder/$station" )
 
145
 {
 
146
-       $lattemp=$1;
 
147
-       if($temp>-50 && $temp<150)
 
148
-       {
 
149
-               if($lasttemp>-50 && $lasttemp<150)
 
150
-               {
 
151
-                       if($temp>-2 && $temp<2)
 
152
-                       {
 
153
-                               if($lasttemp>7 || $lasttemp<-7)
 
154
-                               {
 
155
-                                       #probably invalid
 
156
-                                       $station="";
 
157
-                               }
 
158
-                       }
 
159
-               }
 
160
-       }
 
161
-       else
 
162
-       {
 
163
-       #invalid
 
164
-       $station="";
 
165
-       }
 
166
+    open(GREP, "grep Temp $tmpfolder/${station} | ");
 
167
+    $templine=<GREP>;
 
168
+
 
169
+    $templine=~m/^Temp:(.*)$/;
 
170
+    {
 
171
+           # $lattemp=$1;
 
172
+           if($temp>-50 && $temp<150)
 
173
+           {
 
174
+                   if($lasttemp>-50 && $lasttemp<150)
 
175
+                   {
 
176
+                           if($temp>-2 && $temp<2)
 
177
+                           {
 
178
+                                   if($lasttemp>7 || $lasttemp<-7)
 
179
+                                   {
 
180
+                                           #probably invalid
 
181
+                                           $station="";
 
182
+                                   }
 
183
+                           }
 
184
+                   }
 
185
+           }
 
186
+           else
 
187
+           {
 
188
+           #invalid
 
189
+           $station="";
 
190
+           }
 
191
+    }
 
192
+    close GREP;
 
193
 }
 
194
-close GREP;
 
195
 
 
196
 #print "$$station\n";
 
197
 if(length($station)==4)