[interchange-cvs] interchange - racke modified 3 files

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Thu Aug 9 07:08:38 EDT 2007


User:      racke
Date:      2007-08-09 11:08:37 GMT
Modified:  .        WHATSNEW-5.5
Modified:  lib/Vend Dispatch.pm Server.pm
Log:
Allow parameters passed to jobs, acknowledges --email commandline option
now (#103).

Revision  Changes    Path
1.45      +3 -0      interchange/WHATSNEW-5.5


rev 1.45, prev_rev 1.44
Index: WHATSNEW-5.5
===================================================================
RCS file: /var/cvs/interchange/WHATSNEW-5.5,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- WHATSNEW-5.5	7 Aug 2007 10:55:56 -0000	1.44
+++ WHATSNEW-5.5	9 Aug 2007 11:08:35 -0000	1.45
@@ -140,6 +140,9 @@
 
 * Avoid cluttering global log file with job run messages.
 
+* Allow parameters passed to jobs, acknowledges --email commandline option
+  now (#103).
+ 
 UI
 --
 



1.84      +7 -5      interchange/lib/Vend/Dispatch.pm


rev 1.84, prev_rev 1.83
Index: Dispatch.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Dispatch.pm,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -r1.83 -r1.84
--- Dispatch.pm	2 Aug 2007 15:15:52 -0000	1.83
+++ Dispatch.pm	9 Aug 2007 11:08:36 -0000	1.84
@@ -1,8 +1,8 @@
 # Vend::Dispatch - Handle Interchange page requests
 #
-# $Id: Dispatch.pm,v 1.83 2007/08/02 15:15:52 mheins Exp $
+# $Id: Dispatch.pm,v 1.84 2007/08/09 11:08:36 racke Exp $
 #
-# Copyright (C) 2002-2006 Interchange Development Group
+# Copyright (C) 2002-2007 Interchange Development Group
 # Copyright (C) 2002 Mike Heins <mike at perusion.net>
 #
 # This program was originally based on Vend 0.2 and 0.3
@@ -26,7 +26,7 @@
 package Vend::Dispatch;
 
 use vars qw($VERSION);
-$VERSION = substr(q$Revision: 1.83 $, 10);
+$VERSION = substr(q$Revision: 1.84 $, 10);
 
 use POSIX qw(strftime);
 use Vend::Util;
@@ -705,10 +705,12 @@
 }
 
 sub run_in_catalog {
-	my ($cat, $job, $itl) = @_;
+	my ($cat, $job, $itl, $parms) = @_;
 	my ($g,$c);
 
 #::logGlobal("running job in cat=$cat");
+	$parms ||= {};
+	
 	$g = $Global::Catalog{$cat};
 	unless (defined $g) {
 		logGlobal( "Can't find catalog '%s'" , $cat );
@@ -840,7 +842,7 @@
 	# no output (in spirit of the cron daemon)
 	return unless $out;
 	
-	if(my $addr = $Vend::JobsEmail || $jobscfg->{email}) {
+	if(my $addr = $parms->{email} || $jobscfg->{email}) {
 		my $subject = $jobscfg->{subject} || 'Interchange results for job: %s';
 		$subject = errmsg($subject, $job);
 		my $from = $jobscfg->{from} || $Vend::Cfg->{MailOrderTo};



2.75      +17 -6     interchange/lib/Vend/Server.pm


rev 2.75, prev_rev 2.74
Index: Server.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Server.pm,v
retrieving revision 2.74
retrieving revision 2.75
diff -u -r2.74 -r2.75
--- Server.pm	30 Mar 2007 11:39:45 -0000	2.74
+++ Server.pm	9 Aug 2007 11:08:36 -0000	2.75
@@ -1,6 +1,6 @@
 # Vend::Server - Listen for Interchange CGI requests as a background server
 #
-# $Id: Server.pm,v 2.74 2007/03/30 11:39:45 pajamian Exp $
+# $Id: Server.pm,v 2.75 2007/08/09 11:08:36 racke Exp $
 #
 # Copyright (C) 2002-2007 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -26,7 +26,7 @@
 package Vend::Server;
 
 use vars qw($VERSION);
-$VERSION = substr(q$Revision: 2.74 $, 10);
+$VERSION = substr(q$Revision: 2.75 $, 10);
 
 use Cwd;
 use POSIX qw(setsid strftime);
@@ -1236,7 +1236,7 @@
 			while(<Vend::Server::JOBS>) {
 				chomp;
 				my ($directive,$value) = split /\s+/, $_, 2;
-				my ($cat, $delay, @jobs) = grep /\S/, split /[\s,\0]+/, $value;
+				my ($cat, $delay, $jobname, @params) = grep /\S/, split /[\s,\0]+/, $value;
 				if ($delay && $delay < time()) {
 					# job expired
 #::logDebug ("Jobs @jobs expired ($delay vs $now)\n");
@@ -1247,7 +1247,12 @@
                         push(@queued_jobs, "$directive $value");
                 } else {
 #::logDebug ("Scheduled job @jobs for running");
-					push (@scheduled_jobs, [$cat, @jobs]);
+					my %p;
+					for (@params) {
+					    my ($name, $value) = split /\=/, $_, 2;
+						$p{$name} = $value;
+					}
+					push (@scheduled_jobs, [$cat, $jobname, \%p]);
 				}
                 if (@queued_jobs > 20) {
 					::logGlobal({ level => 'notice' }, "Excessive size of job queue, stopping");
@@ -2504,8 +2509,14 @@
 
 sub jobs_job {
 	my ($cat, @jobs) = @_;
+	my $parms;
+
+	if (ref($jobs[$#jobs]) eq 'HASH') {
+		$parms = pop(@jobs);
+	}
+	
 	for my $job (@jobs) {
-		Vend::Dispatch::run_in_catalog($cat, $job);
+		Vend::Dispatch::run_in_catalog($cat, $job, '', $parms);
 	}
 }
 
@@ -2570,7 +2581,7 @@
 sub run_jobs {
 	my ($cat, @jobs) = @_;
 
-#::logGlobal("Vend::Server::run_jobs: run jobs cat=cat jobs=@jobs");
+#::logGlobal("Vend::Server::run_jobs: run jobs cat=$cat job=@jobs");
 	my $pid;
 	if($Global::Foreground) {
 		$::Instance = {};








More information about the interchange-cvs mailing list