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

View of /FigWebServices/show_log.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (annotate)
Fri May 5 16:43:09 2006 UTC (14 years, 1 month ago) by overbeek
Branch: MAIN
crude version of show_log.cgi

# -*- perl -*-
#
# Copyright (c) 2003-2006 University of Chicago and Fellowship
# for Interpretations of Genomes. All Rights Reserved.
#
# This file is part of the SEED Toolkit.
# 
# The SEED Toolkit is free software. You can redistribute
# it and/or modify it under the terms of the SEED Toolkit
# Public License. 
#
# You should have received a copy of the SEED Toolkit Public License
# along with this program; if not write to the University of Chicago
# at info@ci.uchicago.edu or the Fellowship for Interpretation of
# Genomes at veronika@thefig.info or download a copy from
# http://www.theseed.org/LICENSE.TXT.
#


use FIG;
my $fig = new FIG;

use URI::Escape;  # uri_escape
use HTML;

use CGI;
use Tracer;

my $cgi = new CGI;

use Carp;

if (0) {
    my $VAR1;
    eval(join("",`cat /tmp/log_parms`));
    $cgi = $VAR1;
#   print STDERR &Dumper($cgi);
}

if (0) {
    print $cgi->header;
    my @params = $cgi->param;
    print "<pre>\n";
    foreach $_ (@params) {
		print "$_\t:",join(",",$cgi->param($_)),":\n";
    }

    if (0) {
        if (open(TMP,">/tmp/log_parms")) {
	    	print TMP &Dumper($cgi);
	    	close(TMP);
		}
    }
    exit;
}

my $html = [];



if ($request = $cgi->param('request'))
{
    &process_request($fig,$cgi,$html,$request);
    exit;
}
####  no request, show initial form ####A

push(@$html,$cgi->h1("Genome Log"));
if (open(INDEX,"<$FIG_Config::data/Logs/GenomeLog/index"))
{
    my @tmp;
    my $col_hdrs = ["Genome"];
    while (defined($_ = <INDEX>))
    {
	if ($_ =~ /^(\d+)\t(\S.*\S)/)
	{
	    my($i,$gs) = ($1,$2);
	    my $link = $cgi->url(-relative => 1) . "?request=show_log&which=$i&gs=$gs";
	    my $url  = "<a href=$link>$gs</a>";

	    push(@tmp,[$gs,$url]);
	}
    }
    close(INDEX);
    @tmp = sort { $a->[0] cmp $b->[0] } @tmp;
    $tab = [ map { [$_->[1]] } @tmp];

    push(@$html,&HTML::make_table($col_hdrs,$tab,"Genomes For Which Logs Exist"));
}
else
{
    push(@$html,$cgi->h2("No log exists"));
}

&HTML::show_page($cgi,$html);

sub process_request {
    my($fig,$cgi,$html,$request) = @_;
    my($which,$gs);

    if (($request eq "show_log") && 
	($which = $cgi->param('which')) &&
	($gs = $cgi->param('gs')) &&
	open(LOG,"<$FIG_Config::data/Logs/GenomeLog/Entries/$which/log"))
    {
	$/ = "\n//\n";
	while (defined($log_entry = <LOG>))
	{
	    chomp $log_entry;
	    my($ts,$who,$genome,@msg) = split(/\n/,$log_entry);
	    push(@$tab,[$fig->epoch_to_readable($ts),$who,$genome,join("<br>",@msg)]);
	}
	$/ = "\n";
	push(@$html,&HTML::make_table(["When","Who","Genome","What"],$tab,"Events: $gs"));
    }
    else
    {
	push(@$html,$cgi->h2("Invalid request"));
    }
    &HTML::show_page($cgi,$html);
}


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3