[Bio] / FigWebServices / show_log.cgi Repository:
ViewVC logotype

Diff of /FigWebServices/show_log.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Fri May 5 16:43:09 2006 UTC revision 1.2, Sat May 6 19:25:15 2006 UTC
# Line 75  Line 75 
75          if ($_ =~ /^(\d+)\t(\S.*\S)/)          if ($_ =~ /^(\d+)\t(\S.*\S)/)
76          {          {
77              my($i,$gs) = ($1,$2);              my($i,$gs) = ($1,$2);
78              my $link = $cgi->url(-relative => 1) . "?request=show_log&which=$i&gs=$gs";              my $gsE = $cgi->escape($gs);
79                my $link = $cgi->url(-relative => 1) . "?request=show_log&which=$i&gs=$gsE";
80              my $url  = "<a href=$link>$gs</a>";              my $url  = "<a href=$link>$gs</a>";
81    
82              push(@tmp,[$gs,$url]);              push(@tmp,[$gs,$url]);
# Line 100  Line 101 
101    
102      if (($request eq "show_log") &&      if (($request eq "show_log") &&
103          ($which = $cgi->param('which')) &&          ($which = $cgi->param('which')) &&
104          ($gs = $cgi->param('gs')) &&          ($gs = $cgi->unescape($cgi->param('gs'))) &&
105          open(LOG,"<$FIG_Config::data/Logs/GenomeLog/Entries/$which/log"))          open(LOG,"<$FIG_Config::data/Logs/GenomeLog/Entries/$which/log"))
106      {      {
107          $/ = "\n//\n";          $/ = "\n//\n";
# Line 108  Line 109 
109          {          {
110              chomp $log_entry;              chomp $log_entry;
111              my($ts,$who,$genome,@msg) = split(/\n/,$log_entry);              my($ts,$who,$genome,@msg) = split(/\n/,$log_entry);
112              push(@$tab,[$fig->epoch_to_readable($ts),$who,$genome,join("<br>",@msg)]);              push(@$tab,[$fig->epoch_to_readable($ts),$who,$genome,&make_readable_extra($fig,$cgi,\@msg)]);
113          }          }
114          $/ = "\n";          $/ = "\n";
115          push(@$html,&HTML::make_table(["When","Who","Genome","What"],$tab,"Events: $gs"));          push(@$html,&HTML::make_table(["When","Who","Genome","What"],$tab,"Events: $gs"));
116      }      }
117        elsif (($request eq "display_map") && ($map = $cgi->param('map')) && (-s $map))
118        {
119            &show_map($fig,$cgi,$html,$map);
120        }
121      else      else
122      {      {
123          push(@$html,$cgi->h2("Invalid request"));          push(@$html,$cgi->h2("Invalid request"));
# Line 120  Line 125 
125      &HTML::show_page($cgi,$html);      &HTML::show_page($cgi,$html);
126  }  }
127    
128    sub make_readable_extra {
129        my($fig,$cgi,$msg) = @_;
130        my($hdr,$genomeF,$map);
131    
132        if (($msg->[0] =~ /^(Replaced genome \d+\.\d+ with \d+\.\d+)/) && ($hdr = $1) &&
133            ($msg->[2] =~ /^(\S[^,]+),(\S[^,]+)/) && ($genomeF = $1) && ($map = $2))
134        {
135            my $mapE = $cgi->escape($map);
136            my $link = $cgi->url(-relative => 1) . "?request=display_map&map=$mapE";
137            my $url  = "<a href=$link>map</a>";
138            return join("<br>",($hdr,$msg->[1],"Tarred Organism=$genomeF",$url));
139        }
140        return join("<br>",@$msg);
141    }
142    
143    sub show_map {
144        my($fig,$cgi,$html,$map) = @_;
145    
146        my $tmpD = "untar$$";
147        if (-d $tmpD) { system "/bin/rm -r $tmpD" }
148        mkdir($tmpD,0777) || die "could not make $tmpD";
149        system "cd $tmpD; tar xzf $map";
150        opendir(DIR,$tmpD);
151        my @expanded = grep { $_ !~ /^\./ } readdir(DIR);
152        closedir(DIR);
153        if ((@expanded == 1) && (-s "$tmpD/$expanded[0]"))
154        {
155            my($x,$y);
156            my @entries = sort { $a =~ /^fig\|\d+\.\d+\.[^\.]+\.(\d+)/; $x = $1;
157                                 $b =~ /^fig\|\d+\.\d+\.[^\.]+\.(\d+)/; $y = $1;
158                                 $x <=> $y
159                               }
160                          `cat $tmpD/$expanded[0]`;
161    
162            push(@$html,"<pre>\n",@entries,"</pre>\n");
163        }
164        system "rm -r $tmpD";
165    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3