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

Annotation of /FigWebServices/show_log.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download)

1 : overbeek 1.1 # -*- perl -*-
2 :     #
3 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
4 :     # for Interpretations of Genomes. All Rights Reserved.
5 :     #
6 :     # This file is part of the SEED Toolkit.
7 :     #
8 :     # The SEED Toolkit is free software. You can redistribute
9 :     # it and/or modify it under the terms of the SEED Toolkit
10 :     # Public License.
11 :     #
12 :     # You should have received a copy of the SEED Toolkit Public License
13 :     # along with this program; if not write to the University of Chicago
14 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
15 :     # Genomes at veronika@thefig.info or download a copy from
16 :     # http://www.theseed.org/LICENSE.TXT.
17 :     #
18 :    
19 :    
20 :     use FIG;
21 :     my $fig = new FIG;
22 :    
23 :     use URI::Escape; # uri_escape
24 :     use HTML;
25 :    
26 :     use CGI;
27 :     use Tracer;
28 :    
29 :     my $cgi = new CGI;
30 :    
31 :     use Carp;
32 :    
33 :     if (0) {
34 :     my $VAR1;
35 :     eval(join("",`cat /tmp/log_parms`));
36 :     $cgi = $VAR1;
37 :     # print STDERR &Dumper($cgi);
38 :     }
39 :    
40 :     if (0) {
41 :     print $cgi->header;
42 :     my @params = $cgi->param;
43 :     print "<pre>\n";
44 :     foreach $_ (@params) {
45 :     print "$_\t:",join(",",$cgi->param($_)),":\n";
46 :     }
47 :    
48 :     if (0) {
49 :     if (open(TMP,">/tmp/log_parms")) {
50 :     print TMP &Dumper($cgi);
51 :     close(TMP);
52 :     }
53 :     }
54 :     exit;
55 :     }
56 :    
57 :     my $html = [];
58 :    
59 :    
60 :    
61 :     if ($request = $cgi->param('request'))
62 :     {
63 :     &process_request($fig,$cgi,$html,$request);
64 :     exit;
65 :     }
66 :     #### no request, show initial form ####A
67 :    
68 :     push(@$html,$cgi->h1("Genome Log"));
69 :     if (open(INDEX,"<$FIG_Config::data/Logs/GenomeLog/index"))
70 :     {
71 :     my @tmp;
72 :     my $col_hdrs = ["Genome"];
73 :     while (defined($_ = <INDEX>))
74 :     {
75 :     if ($_ =~ /^(\d+)\t(\S.*\S)/)
76 :     {
77 :     my($i,$gs) = ($1,$2);
78 :     my $link = $cgi->url(-relative => 1) . "?request=show_log&which=$i&gs=$gs";
79 :     my $url = "<a href=$link>$gs</a>";
80 :    
81 :     push(@tmp,[$gs,$url]);
82 :     }
83 :     }
84 :     close(INDEX);
85 :     @tmp = sort { $a->[0] cmp $b->[0] } @tmp;
86 :     $tab = [ map { [$_->[1]] } @tmp];
87 :    
88 :     push(@$html,&HTML::make_table($col_hdrs,$tab,"Genomes For Which Logs Exist"));
89 :     }
90 :     else
91 :     {
92 :     push(@$html,$cgi->h2("No log exists"));
93 :     }
94 :    
95 :     &HTML::show_page($cgi,$html);
96 :    
97 :     sub process_request {
98 :     my($fig,$cgi,$html,$request) = @_;
99 :     my($which,$gs);
100 :    
101 :     if (($request eq "show_log") &&
102 :     ($which = $cgi->param('which')) &&
103 :     ($gs = $cgi->param('gs')) &&
104 :     open(LOG,"<$FIG_Config::data/Logs/GenomeLog/Entries/$which/log"))
105 :     {
106 :     $/ = "\n//\n";
107 :     while (defined($log_entry = <LOG>))
108 :     {
109 :     chomp $log_entry;
110 :     my($ts,$who,$genome,@msg) = split(/\n/,$log_entry);
111 :     push(@$tab,[$fig->epoch_to_readable($ts),$who,$genome,join("<br>",@msg)]);
112 :     }
113 :     $/ = "\n";
114 :     push(@$html,&HTML::make_table(["When","Who","Genome","What"],$tab,"Events: $gs"));
115 :     }
116 :     else
117 :     {
118 :     push(@$html,$cgi->h2("Invalid request"));
119 :     }
120 :     &HTML::show_page($cgi,$html);
121 :     }
122 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3