[otrs-cvs] CVS: otrs/bin GenericAgent.pl,1.36,1.37
cvs-log at otrs.org
cvs-log at otrs.org
Wed Jul 5 11:53:18 CEST 2006
Update of /home/cvs/otrs/bin
In directory lancelot:/tmp/cvs-serv4382/bin
Modified Files:
GenericAgent.pl
Log Message:
reworked design
Index: GenericAgent.pl
===================================================================
RCS file: /home/cvs/otrs/bin/GenericAgent.pl,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -r1.36 -r1.37
*** GenericAgent.pl 7 May 2005 15:26:56 -0000 1.36
--- GenericAgent.pl 5 Jul 2006 08:53:16 -0000 1.37
***************
*** 2,6 ****
# --
# bin/GenericAgent.pl - a generic agent -=> e. g. close ale emails in a specific queue
! # Copyright (C) 2001-2005 Martin Edenhofer <martin+code at otrs.org>
# --
# $Id$
--- 2,6 ----
# --
# bin/GenericAgent.pl - a generic agent -=> e. g. close ale emails in a specific queue
! # Copyright (C) 2001-2006 Martin Edenhofer <martin+code at otrs.org>
# --
# $Id$
***************
*** 35,39 ****
use strict;
! use vars qw($VERSION $Debug $Limit %Opts %Jobs);
use Getopt::Std;
--- 35,41 ----
use strict;
! use vars qw($VERSION %Jobs @ISA);
! $VERSION = '$Revision$';
! $VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;
use Getopt::Std;
***************
*** 42,45 ****
--- 44,48 ----
use Kernel::System::DB;
use Kernel::System::PID;
+ use Kernel::System::Main;
use Kernel::System::Time;
use Kernel::System::Ticket;
***************
*** 47,96 ****
use Kernel::System::GenericAgent;
! # import %jobs
! #use Kernel::Config::GenericAgent qw(%Jobs);
!
! BEGIN {
! # get file version
! $VERSION = '$Revision$';
! $VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;
! # get options
! getopt('fhcdl', \%Opts);
! if ($Opts{'h'}) {
! print "GenericAgent.pl <Revision $VERSION> - OTRS generic agent\n";
! print "Copyright (c) 2001-2005 Martin Edenhofer <martin\@otrs.org>\n";
! print "usage: GenericAgent.pl [-c 'Kernel::Config::GenericAgentJobModule'] [-d 1] [-l <limit>] [-f force]\n";
! exit 1;
! }
! # set debug
! if (!$Opts{'d'}) {
! $Debug = 0;
! }
! else {
! $Debug = $Opts{'d'};
! }
! # set limit
! if (!$Opts{'l'}) {
! $Limit = 3000;
! }
! else {
! $Limit = $Opts{'l'};
! }
! # get generic agent config (job file)
! if (!$Opts{'c'}) {
! $Opts{'c'} = 'Kernel::Config::GenericAgent';
! }
! if ($Opts{'c'} eq 'db') {
! %Jobs = ();
! }
! # load jobs file
! elsif (!eval "require $Opts{'c'};") {
! print STDERR "Can't load agent job file '$Opts{'c'}': $!\n";
! exit 1;
! }
! else {
! # import %Jobs
! eval "import $Opts{'c'}";
! }
}
# set generic agent uid
my $UserIDOfGenericAgent = 1;
--- 50,71 ----
use Kernel::System::GenericAgent;
! # get options
! my %Opts = ();
! getopt('fhcdl', \%Opts);
! if ($Opts{'h'}) {
! print "GenericAgent.pl <Revision $VERSION> - OTRS generic agent\n";
! print "Copyright (c) 2001-2005 Martin Edenhofer <martin\@otrs.org>\n";
! print "usage: GenericAgent.pl [-c 'Kernel::Config::GenericAgentJobModule'] [-d 1] [-l <limit>] [-f force]\n";
! exit 1;
}
+ # set debug
+ if (!$Opts{'d'}) {
+ $Opts{'d'} = 0;
+ }
+ # set limit
+ if (!$Opts{'l'}) {
+ $Opts{'l'} = 3000;
+ }
+
# set generic agent uid
my $UserIDOfGenericAgent = 1;
***************
*** 103,106 ****
--- 78,82 ----
%CommonObject,
);
+ $CommonObject{MainObject} = Kernel::System::Main->new(%CommonObject);
$CommonObject{DBObject} = Kernel::System::DB->new(%CommonObject);
$CommonObject{PIDObject} = Kernel::System::PID->new(%CommonObject);
***************
*** 108,119 ****
$CommonObject{TicketObject} = Kernel::System::Ticket->new(
%CommonObject,
! Debug => $Debug,
);
$CommonObject{QueueObject} = Kernel::System::Queue->new(%CommonObject);
$CommonObject{GenericAgentObject} = Kernel::System::GenericAgent->new(
%CommonObject,
! Debug => $Debug,
NoticeSTDOUT => 1,
);
# --
# process all jobs
--- 84,114 ----
$CommonObject{TicketObject} = Kernel::System::Ticket->new(
%CommonObject,
! Debug => $Opts{'d'},
);
$CommonObject{QueueObject} = Kernel::System::Queue->new(%CommonObject);
$CommonObject{GenericAgentObject} = Kernel::System::GenericAgent->new(
%CommonObject,
! Debug => $Opts{'d'},
NoticeSTDOUT => 1,
);
+
+ # get generic agent config (job file)
+ if (!$Opts{'c'}) {
+ $Opts{'c'} = 'Kernel::Config::GenericAgent';
+ }
+ if ($Opts{'c'} eq 'db') {
+ %Jobs = ();
+ }
+ else {
+ if (!$CommonObject{MainObject}->Require($Opts{'c'})) {
+ print STDERR "Can't load agent job file '$Opts{'c'}': $!\n";
+ exit 1;
+ }
+ else {
+ # import %Jobs
+ eval "import $Opts{'c'}";
+ }
+ }
+
# --
# process all jobs
***************
*** 200,203 ****
--- 195,199 ----
$CommonObject{GenericAgentObject}->JobRun(
Job => $DBJob,
+ Limit => $Opts{'l'},
UserID => $UserIDOfGenericAgent,
);
***************
*** 215,218 ****
--- 211,215 ----
$CommonObject{GenericAgentObject}->JobRun(
Job => $Job,
+ Limit => $Opts{'l'},
Config => $Jobs{$Job},
UserID => $UserIDOfGenericAgent,
More information about the cvs-log
mailing list