From e91ad8e6d5256b654e54530540e70663ec6a0f25 Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Fri, 6 Sep 2002 20:09:30 +0000 Subject: [PATCH] added some Perl scripts that do the trick git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@857 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd-web/src/processor.pl | 17 +++++++++++++ pmd-web/src/webpmd.pl | 54 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 pmd-web/src/processor.pl create mode 100644 pmd-web/src/webpmd.pl diff --git a/pmd-web/src/processor.pl b/pmd-web/src/processor.pl new file mode 100644 index 0000000000..e7c03de55f --- /dev/null +++ b/pmd-web/src/processor.pl @@ -0,0 +1,17 @@ +#!/usr/bin/perl + +chdir("/home/groups/p/pm/pmd/cgi-bin"); + +if (-e "runthis.txt") { + open(FILE,"runthis.txt"); + $data=; + close(FILE); + `rm -f runthis.txt`; + my ($project,$srcdir,$zilch) = split(":",$data); + `cvs -d:pserver:anonymous\@cvs.${project}.sourceforge.net:/cvsroot/${project} co ${project}`; + $cmd="java -jar pmd-0.9.jar ${project}/${srcdir} html rulesets/unusedcode.xml"; + `${cmd} > results.html`; + `rm -rf ${project}`; +} else { + print "nothing to run"; +} diff --git a/pmd-web/src/webpmd.pl b/pmd-web/src/webpmd.pl new file mode 100644 index 0000000000..049dadd22c --- /dev/null +++ b/pmd-web/src/webpmd.pl @@ -0,0 +1,54 @@ +#!/usr/bin/perl + +use CGI qw(:standard escapeHTML); +use CGI::Carp qw(fatalsToBrowser); + +$query = new CGI(); +print $query->header(); + +sub nopage() { + print $query->p("How'd we get here?"); +} + +sub printGreeting() { + print start_html("Run PMD on your Sourceforge project"); + print p("Want to run PMD on your Sourceforge project? Fill in the blanks and hit go"); + print start_form(); + print p(), "Project name (i.e., pmd): ", textfield('project'); + print p(), "Source directory (i.e., src): ", textfield('srcdir'); + my $cachebuster=`date`; + print $query->hidden(-name=>'cachebuster', -value=>${cachebuster}); + print p(), submit(-name=>'state',-value=>'writedata'); + print end_form(); +} + +sub writeData() { + my $project = $query->param('project'); + my $srcdir = $query->param('srcdir'); + `echo "${project}:${srcdir}:" > runthis.txt`; + print start_html(-title=>'PMD Results', -head=>meta({-http_equiv=>'Refresh',-content=>'0;URL=http://pmd.sf.net/cgi-bin/webpmd.pl?state=refreshreport'})); +} + +sub refreshReport() { + print start_html(-title=>'PMD Results', -head=>meta({-http_equiv=>'Refresh',-content=>'10;URL=http://pmd.sf.net/cgi-bin/webpmd.pl?state=refreshreport'})); + $query->p("This page will refresh with more information every 10 seconds or so"); + open(FILE,"results.html"); + print $query->p(); +} + +$page=param("state") || "default"; + +%states = ( + 'default' => \&printGreeting, + 'writedata' => \&writeData, + 'refreshreport'=> \&refreshReport, +); + +if ($states{$page}) { + $states{$page}->(); +} else { + nopage(); +} + +print $query->end_html(); +