[Collab-qa-commits] r1167 - in buildstat/trunk: . buildstat-job-manager buildstat-job-manager/buildstat-job-manager

goneri at alioth.debian.org goneri at alioth.debian.org
Wed Aug 27 22:08:30 UTC 2008


Author: goneri
Date: 2008-08-27 22:08:29 +0000 (Wed, 27 Aug 2008)
New Revision: 1167

Added:
   buildstat/trunk/buildstat-job-manager/
   buildstat/trunk/buildstat-job-manager/buildstat-job-manager/
   buildstat/trunk/buildstat-job-manager/buildstat-job-manager/buildstat-job-manager
Removed:
   buildstat/trunk/buildstat-job-manager/buildstat-job-manager/qajob-manager
   buildstat/trunk/buildstat-job-manager/qajob-manager/
Log:
new name

Copied: buildstat/trunk/buildstat-job-manager (from rev 1141, buildstat/trunk/buildstat-qajob-manager)


Property changes on: buildstat/trunk/buildstat-job-manager
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: buildstat/trunk/buildstat-job-manager/buildstat-job-manager (from rev 1141, buildstat/trunk/buildstat-qajob-manager/qajob-manager)


Property changes on: buildstat/trunk/buildstat-job-manager/buildstat-job-manager
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: buildstat/trunk/buildstat-job-manager/buildstat-job-manager/buildstat-job-manager (from rev 1141, buildstat/trunk/buildstat-qajob-manager/qajob-manager/qajob-manager)
===================================================================
--- buildstat/trunk/buildstat-job-manager/buildstat-job-manager/buildstat-job-manager	                        (rev 0)
+++ buildstat/trunk/buildstat-job-manager/buildstat-job-manager/buildstat-job-manager	2008-08-27 22:08:29 UTC (rev 1167)
@@ -0,0 +1,199 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+#use lib "/home/sites/svnbuildstat.debian.net/svnbuildstat/lib";
+
+use Data::Dumper;
+use Net::FTP;
+use File::Glob ':glob';
+use Sys::Hostname;
+#use SvnBuildStat::Config;
+use LWP::Simple;
+use POSIX ":sys_wait_h";
+use File::Basename;
+use File::stat;
+use HTTP::Request::Common;
+use LWP::UserAgent;
+use HTTP::Response;
+use Getopt::Long;
+use File::Temp;
+
+my $hostname = hostname();
+my $server = "http://nana2:3000";
+my $admin = "Gonéri Le Bouder <goneri\@rulezlan.org>";
+
+my $params = {
+   action => undef,
+   qatool => undef,
+   jobfile => undef,
+   logfile => undef,
+   result => undef,
+   target => undef,
+   help => undef
+};
+
+sub postFiles {
+    my $files = shift;
+    
+    die "File not found" unless -f $files->{'jobfile'} || -f $files->{'resultfile'};
+    my $ua = new LWP::UserAgent;
+
+
+    my $job;
+    open JOBFILE, "<".$params->{'jobfile'} or die "Can't open Jobfile:".$!;
+    foreach (<JOBFILE>) {
+        chomp;
+
+        $job->{$1} = $2 if (/(.*)=(.*)/);
+    }
+    close JOBFILE;
+
+    die "Invalide jobfile" unless $job->{'cookie'};
+    my $timestamp = time."-".$job->{'cookie'};
+    # The 'files' is used by the server to find the related files
+    $job->{'resultfile'} = $timestamp.'.resultfile';
+    if ($job->{'logfile'}) {
+        $job->{'logfile'} = $timestamp.'.logfile';
+    }
+
+
+    my $jobfile_fh = new File::Temp();
+    foreach (keys %$job) {
+        print $jobfile_fh $_."=".$job->{$_}."\n";
+    }
+    close $jobfile_fh;
+    $files->{'jobfile'} = $jobfile_fh->filename;
+    print $jobfile_fh->filename."\n";
+
+
+    # Order is important here since the .jobfile is used at the
+    # server side to start the import task
+    foreach (qw/logfile resultfile jobfile/) {
+        next unless $files->{$_};
+        next unless -f $files->{$_};
+
+        print "upload $_...\n";
+        my $response = $ua->request(POST $server.'/controls/buildInput',
+            Content_Type => 'form-data',
+            Content => ['file' => [ $files->{$_}, $timestamp.'.'.$_ ]]) or die "Upload failed\n";
+
+        print "report sent: ".$response->as_string()."\n";
+    }
+
+}
+
+
+sub getJob {
+    die unless $params->{'qatool'} && $params->{'jobfile'} && $params->{'target'};
+
+  my $ua  = LWP::UserAgent->new();
+  my $req = POST $server."/controls/getQAJob", Content_Type => 'form-data',
+  Content      => [
+  submit => 1,
+  content => "qatool=".$params->{'qatool'}."\ntarget=".$params->{'target'},
+  ];
+  my $response = $ua->request($req);
+  die "Failed to contact server" unless $response->is_success();
+
+  open JOBFILE, ">".$params->{'jobfile'} or die "Can't open ".$params->{'jobfile'}.":$!\n";
+  print JOBFILE $response->content;
+  close JOBFILE;
+}
+
+
+sub sendJob {
+
+  my ($report, $threadbuildarea) = @_;
+
+  print "sending result\n";
+
+  $report->{'admin'} = $admin;
+  $report->{hostname} = $hostname;
+
+
+#  open (BUILDLOGTMP, "<","$threadbuildarea/build.log.tmp") or die;
+#  seek(BUILDLOGTMP, -2000000, 2); # I just keep the end of the logfile
+#  open (BUILDLOG, ">", "$threadbuildarea/".$logfile) or die;
+#  # If I'm not at the end of BUILDLOGTMP it means that seek moved me
+#  print BUILDLOG "(log file truncated) ... " if tell(BUILDLOGTMP);
+#
+#  foreach (<BUILDLOGTMP>) {
+#  # To avoid strange breakage I do some clean up in the log file
+#    s/[[:cntrl:]]//g;
+#    print BUILDLOG $_."\n";
+#  }
+#  close BUILDLOGTMP;
+#  close BUILDLOG;
+#  unlink "$threadbuildarea/build.log.tmp";
+
+#  postFile($threadbuildarea."/".$logfile);
+#  $report->{logfile} = $logfile;
+#  if (bsd_glob($threadbuildarea.'/*.changes')) {
+#    print "build is ok\n";
+#    $report->{build} = "ok";
+#    foreach (bsd_glob($threadbuildarea.'/*.deb'), bsd_glob($threadbuildarea.'/*.udeb')) {
+#      $report->{binarypackages} = basename($_).' ';
+#      postFile($_);
+#    }
+#  } else {
+#    print "build is nok\n";
+#    $report->{build} = "nok";
+#  }
+#
+#
+#  open (BUILDREPORT,">",$threadbuildarea."/".$infofile) or die "Can't open infofile";
+#  foreach (sort keys %$report) {
+#    chomp $report->{$_};
+#    print BUILDREPORT $_."=".$report->{$_}."\n";
+#  }
+#  print BUILDREPORT "-END-\n";
+#  close BUILDREPORT;
+#  postFile ($threadbuildarea."/".$infofile);
+
+postFiles({
+
+    jobfile => $params->{'jobfile'},
+    resultfile => $params->{'resultfile'},
+    logfile => $params->{'logfile'}
+    
+    });
+
+}
+
+sub usage {
+    print "usage:\n";
+    print "\tqajob-manager --action get --qatool QATOOL --jobfile jobfile --target (source|binary)\n";
+    print "\tqajob-manager --action send --jobfile jobfile --resultfile resultfile (--logfile logfile)\n";
+    exit (1);
+}
+
+
+my $verbose;
+usage unless GetOptions (
+    "help"          => \$params->{'help'},
+    "action=s"      => \$params->{'action'},
+    "qatool=s"      => \$params->{'qatool'},
+    "jobfile=s"     => \$params->{'jobfile'},
+    "logfile=s"     => \$params->{'logfile'},
+    "resultfile=s"  => \$params->{'resultfile'},
+    "target=s"      => \$params->{'target'},
+);
+
+usage () unless $params->{'action'};
+if ($params->{'action'} eq 'get') {
+    if ($params->{'qatool'} !~ /^[\w_\+-]+$/ || !$params->{'jobfile'}|| !$params->{'target'}) {
+        print "--qatool=QATOOL, --jobfile=JOBFILE and --target=TARGET are needed\n";
+        usage();
+    }
+    getJob();
+} elsif ($params->{'action'} eq 'send') {
+    if (!$params->{'jobfile'} || !$params->{'resultfile'}) {
+        print "--jobfile=JOBFILE and --resultfile=RESULTFILE are needed\n";
+    }
+    sendJob();
+} else {
+    print "action is 'get' or 'send'.\n";
+    usage();
+}
+


Property changes on: buildstat/trunk/buildstat-job-manager/buildstat-job-manager/buildstat-job-manager
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mergeinfo
   + 

Deleted: buildstat/trunk/buildstat-job-manager/buildstat-job-manager/qajob-manager
===================================================================
--- buildstat/trunk/buildstat-qajob-manager/qajob-manager/qajob-manager	2008-08-25 21:58:46 UTC (rev 1141)
+++ buildstat/trunk/buildstat-job-manager/buildstat-job-manager/qajob-manager	2008-08-27 22:08:29 UTC (rev 1167)
@@ -1,199 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-
-#use lib "/home/sites/svnbuildstat.debian.net/svnbuildstat/lib";
-
-use Data::Dumper;
-use Net::FTP;
-use File::Glob ':glob';
-use Sys::Hostname;
-#use SvnBuildStat::Config;
-use LWP::Simple;
-use POSIX ":sys_wait_h";
-use File::Basename;
-use File::stat;
-use HTTP::Request::Common;
-use LWP::UserAgent;
-use HTTP::Response;
-use Getopt::Long;
-use File::Temp;
-
-my $hostname = hostname();
-my $server = "http://nana2:3000";
-my $admin = "Gonéri Le Bouder <goneri\@rulezlan.org>";
-
-my $params = {
-   action => undef,
-   qatool => undef,
-   jobfile => undef,
-   logfile => undef,
-   result => undef,
-   target => undef,
-   help => undef
-};
-
-sub postFiles {
-    my $files = shift;
-    
-    die "File not found" unless -f $files->{'jobfile'} || -f $files->{'resultfile'};
-    my $ua = new LWP::UserAgent;
-
-
-    my $job;
-    open JOBFILE, "<".$params->{'jobfile'} or die "Can't open Jobfile:".$!;
-    foreach (<JOBFILE>) {
-        chomp;
-
-        $job->{$1} = $2 if (/(.*)=(.*)/);
-    }
-    close JOBFILE;
-
-    die "Invalide jobfile" unless $job->{'cookie'};
-    my $timestamp = time."-".$job->{'cookie'};
-    # The 'files' is used by the server to find the related files
-    $job->{'resultfile'} = $timestamp.'.resultfile';
-    if ($job->{'logfile'}) {
-        $job->{'logfile'} = $timestamp.'.logfile';
-    }
-
-
-    my $jobfile_fh = new File::Temp();
-    foreach (keys %$job) {
-        print $jobfile_fh $_."=".$job->{$_}."\n";
-    }
-    close $jobfile_fh;
-    $files->{'jobfile'} = $jobfile_fh->filename;
-    print $jobfile_fh->filename."\n";
-
-
-    # Order is important here since the .jobfile is used at the
-    # server side to start the import task
-    foreach (qw/logfile resultfile jobfile/) {
-        next unless $files->{$_};
-        next unless -f $files->{$_};
-
-        print "upload $_...\n";
-        my $response = $ua->request(POST $server.'/controls/buildInput',
-            Content_Type => 'form-data',
-            Content => ['file' => [ $files->{$_}, $timestamp.'.'.$_ ]]) or die "Upload failed\n";
-
-        print "report sent: ".$response->as_string()."\n";
-    }
-
-}
-
-
-sub getJob {
-    die unless $params->{'qatool'} && $params->{'jobfile'} && $params->{'target'};
-
-  my $ua  = LWP::UserAgent->new();
-  my $req = POST $server."/controls/getQAJob", Content_Type => 'form-data',
-  Content      => [
-  submit => 1,
-  content => "qatool=".$params->{'qatool'}."\ntarget=".$params->{'target'},
-  ];
-  my $response = $ua->request($req);
-  die "Failed to contact server" unless $response->is_success();
-
-  open JOBFILE, ">".$params->{'jobfile'} or die "Can't open ".$params->{'jobfile'}.":$!\n";
-  print JOBFILE $response->content;
-  close JOBFILE;
-}
-
-
-sub sendJob {
-
-  my ($report, $threadbuildarea) = @_;
-
-  print "sending result\n";
-
-  $report->{'admin'} = $admin;
-  $report->{hostname} = $hostname;
-
-
-#  open (BUILDLOGTMP, "<","$threadbuildarea/build.log.tmp") or die;
-#  seek(BUILDLOGTMP, -2000000, 2); # I just keep the end of the logfile
-#  open (BUILDLOG, ">", "$threadbuildarea/".$logfile) or die;
-#  # If I'm not at the end of BUILDLOGTMP it means that seek moved me
-#  print BUILDLOG "(log file truncated) ... " if tell(BUILDLOGTMP);
-#
-#  foreach (<BUILDLOGTMP>) {
-#  # To avoid strange breakage I do some clean up in the log file
-#    s/[[:cntrl:]]//g;
-#    print BUILDLOG $_."\n";
-#  }
-#  close BUILDLOGTMP;
-#  close BUILDLOG;
-#  unlink "$threadbuildarea/build.log.tmp";
-
-#  postFile($threadbuildarea."/".$logfile);
-#  $report->{logfile} = $logfile;
-#  if (bsd_glob($threadbuildarea.'/*.changes')) {
-#    print "build is ok\n";
-#    $report->{build} = "ok";
-#    foreach (bsd_glob($threadbuildarea.'/*.deb'), bsd_glob($threadbuildarea.'/*.udeb')) {
-#      $report->{binarypackages} = basename($_).' ';
-#      postFile($_);
-#    }
-#  } else {
-#    print "build is nok\n";
-#    $report->{build} = "nok";
-#  }
-#
-#
-#  open (BUILDREPORT,">",$threadbuildarea."/".$infofile) or die "Can't open infofile";
-#  foreach (sort keys %$report) {
-#    chomp $report->{$_};
-#    print BUILDREPORT $_."=".$report->{$_}."\n";
-#  }
-#  print BUILDREPORT "-END-\n";
-#  close BUILDREPORT;
-#  postFile ($threadbuildarea."/".$infofile);
-
-postFiles({
-
-    jobfile => $params->{'jobfile'},
-    resultfile => $params->{'resultfile'},
-    logfile => $params->{'logfile'}
-    
-    });
-
-}
-
-sub usage {
-    print "usage:\n";
-    print "\tqajob-manager --action get --qatool QATOOL --jobfile jobfile --target (source|binary)\n";
-    print "\tqajob-manager --action send --jobfile jobfile --resultfile resultfile (--logfile logfile)\n";
-    exit (1);
-}
-
-
-my $verbose;
-usage unless GetOptions (
-    "help"          => \$params->{'help'},
-    "action=s"      => \$params->{'action'},
-    "qatool=s"      => \$params->{'qatool'},
-    "jobfile=s"     => \$params->{'jobfile'},
-    "logfile=s"     => \$params->{'logfile'},
-    "resultfile=s"  => \$params->{'resultfile'},
-    "target=s"      => \$params->{'target'},
-);
-
-usage () unless $params->{'action'};
-if ($params->{'action'} eq 'get') {
-    if ($params->{'qatool'} !~ /^[\w_\+-]+$/ || !$params->{'jobfile'}|| !$params->{'target'}) {
-        print "--qatool=QATOOL, --jobfile=JOBFILE and --target=TARGET are needed\n";
-        usage();
-    }
-    getJob();
-} elsif ($params->{'action'} eq 'send') {
-    if (!$params->{'jobfile'} || !$params->{'resultfile'}) {
-        print "--jobfile=JOBFILE and --resultfile=RESULTFILE are needed\n";
-    }
-    sendJob();
-} else {
-    print "action is 'get' or 'send'.\n";
-    usage();
-}
-




More information about the Collab-qa-commits mailing list