Commit 50e9693d authored by sikeda's avatar sikeda
Browse files

[dev] Suppress use of global %main::options.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@12536 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent fb10124c
......@@ -33,6 +33,7 @@ use Sympa::Log;
my %options;
GetOptions(\%main::options, 'debug|d', 'log_level=s', 'config|f=s');
$Conf::sympa_config = $main::options{config};
my $log = Sympa::Log->instance;
......
......@@ -361,10 +361,10 @@ built-in default
=cut
our $sympa_config;
sub get_sympa_conf {
return $main::options{'config'}
if %main::options and defined $main::options{'config'};
return $ENV{'SYMPA_CONFIG'} || Sympa::Constants::CONFIG;
return $sympa_config || $ENV{'SYMPA_CONFIG'} || Sympa::Constants::CONFIG;
}
=over 4
......
......@@ -804,7 +804,8 @@ sub close_family {
=pod
=head2 sub instantiate(FILEHANDLE $fh, BOOLEAN $close_unknown)
=head2 sub instantiate(FILEHANDLE $fh,
[ close_unknown =E<gt> 1 ], [ quiet =E<gt> 1 ] )
Creates family lists or updates them if they exist already.
......@@ -839,15 +840,17 @@ Creates family lists or updates them if they exist already.
#
# IN : -$self
# -$xml_fh : file handle on the xml file
# -$close_unknown : true if must close old lists undefined in new
# instantiation
# -%options
# - close_unknown : true if must close old lists undefined in new
# instantiation
# - quiet :
# OUT : -1 or undef
#########################################
sub instantiate {
my $self = shift;
my $xml_file = shift;
my $close_unknown = shift;
$log->syslog('debug2', '(%s)', $self->{'name'});
$log->syslog('debug2', '(%s, %s, ...)', @_);
my $self = shift;
my $xml_file = shift;
my %options = @_;
## all the description variables are emptied.
$self->_initialize_instantiation();
......@@ -1039,7 +1042,7 @@ sub instantiate {
$progress->update($total) if $progress;
if ($output && !$main::options{'quiet'}) {
if ($output and !$options{quiet}) {
print STDOUT
"There is unread output from the instantiation proccess (aliasmanager messages ...), do you want to see it ? (y or n)";
my $answer = <STDIN>;
......@@ -1065,8 +1068,8 @@ sub instantiate {
}
my $answer;
unless ($close_unknown) {
#while (($answer ne 'y') && ($answer ne 'n')) {
unless ($options{close_unknown}) {
#while ($answer ne 'y' and $answer ne 'n') {
print STDOUT
"The list $l isn't defined in the new instantiation family, do you want to close it ? (y or n)";
$answer = <STDIN>;
......@@ -1075,8 +1078,7 @@ sub instantiate {
$answer ||= 'y';
#}
}
if ($close_unknown || $answer eq 'y') {
if ($options{close_unknown} or $answer eq 'y') {
unless (
$list->set_status_family_closed(
'close_list', $self->{'name'}
......
......@@ -2679,8 +2679,9 @@ sub _as_singlepart {
# Note: this would be moved to incoming pipeline package.
# Old names: tools::virus_infected(), Sympa::Tools::Message::virus_infected().
sub check_virus_infection {
$log->syslog('debug2', '%s)', @_);
my $self = shift;
$log->syslog('debug2', '(%s, ...)', @_);
my $self = shift;
my %options = @_;
my $robot_id;
if (ref $self->{context} eq 'Sympa::List') {
......@@ -2933,8 +2934,8 @@ sub check_virus_infection {
);
}
## if debug mode is active, the working directory is kept
unless ($main::options{'debug'}) {
# if debug mode is active, the working directory is kept
unless ($options{debug}) { #FIXME: Is this condition required?
opendir DIR, $work_dir;
my @list = readdir DIR;
closedir DIR;
......@@ -4248,11 +4249,15 @@ Gets decoded content of text/plain part.
The text will be converted to UTF-8.
Flowed text (see RFC 3676) will be conjuncted.
=item check_virus_infection ()
=item check_virus_infection ( [ debug =E<gt> 1 ] )
I<Instance method>.
Checks the message using anti-virus plugin, if configuration requests it.
Parameter:
TBD.
Returns:
The name of malware the message contains, if any;
......
......@@ -319,7 +319,8 @@ sub _twist {
}
# Anti-virus
my $rc = $message->check_virus_infection;
my $rc =
$message->check_virus_infection(debug => $self->{debug_virus_check});
if ($rc) {
my $antivirus_notify =
Conf::get_robot_conf($robot, 'antivirus_notify') || 'none';
......
......@@ -60,6 +60,7 @@ if ($main::options{'help'}) {
printf "Sympa %s\n", Sympa::Constants::VERSION;
exit 0;
}
$Conf::sympa_config = $main::options{config};
if ($main::options{'debug'}) {
$main::options{'log_level'} = 2 unless $main::options{'log_level'};
......
......@@ -65,6 +65,7 @@ if ($main::options{'help'}) {
printf "Sympa %s\n", Sympa::Constants::VERSION;
exit 0;
}
$Conf::sympa_config = $main::options{config};
if ($main::options{'debug'}) {
$main::options{'log_level'} = 2 unless $main::options{'log_level'};
......
......@@ -63,6 +63,7 @@ if ($main::options{'help'}) {
printf "Sympa %s\n", Sympa::Constants::VERSION;
exit 0;
}
$Conf::sympa_config = $main::options{config};
if ($main::options{'debug'}) {
$main::options{'log_level'} = 2 unless $main::options{'log_level'};
......
......@@ -92,6 +92,7 @@ if ($main::options{'help'}) {
printf "Sympa %s\n", Sympa::Constants::VERSION;
exit 0;
}
$Conf::sympa_config = $main::options{config};
if ($main::options{'debug'}) {
$main::options{'log_level'} = 2 unless $main::options{'log_level'};
......@@ -689,7 +690,8 @@ if ($main::options{'dump'}) {
unless (
$family->instantiate(
$main::options{'input_file'},
$main::options{'close_unknown'}
close_unknown => $main::options{'close_unknown'},
quiet => $main::options{quiet},
)
) {
print STDERR "\nImpossible family instantiation : action stopped \n";
......
......@@ -65,6 +65,7 @@ if ($main::options{'help'}) {
printf "Sympa %s\n", Sympa::Constants::VERSION;
exit 0;
}
$Conf::sympa_config = $main::options{config};
if ($main::options{'debug'}) {
$main::options{'log_level'} = 2 unless $main::options{'log_level'};
......
......@@ -71,6 +71,7 @@ if ($main::options{'help'}) {
printf "Sympa %s\n", Sympa::Constants::VERSION;
exit 0;
}
$Conf::sympa_config = $main::options{config};
if ($main::options{'debug'}) {
$main::options{'log_level'} = 2 unless $main::options{'log_level'};
......@@ -212,6 +213,8 @@ my $spindle = Sympa::Spindle::ProcessIncoming->new(
lang => $main::options{lang},
log_level => $main::options{log_level},
log_smtp => $main::options{mail},
#FIXME: Is it required?
debug_virus_check => $main::options{debug},
);
# Catch signals, in order to exit cleanly, whenever possible.
......@@ -248,6 +251,8 @@ while (not $spindle->{finish} or $spindle->{finish} ne 'term') {
lang => $main::options{lang},
log_level => $main::options{log_level},
log_smtp => $main::options{mail},
#FIXME: Is it required?
debug_virus_check => $main::options{debug},
);
next;
} elsif ($spindle->{finish}) {
......
......@@ -55,6 +55,7 @@ if ($options{'help'}) {
printf "Sympa %s\n", Sympa::Constants::VERSION;
exit 0;
}
$Conf::sympa_config = $main::options{config};
if ($main::options{'debug'}) {
$main::options{'log_level'} = 2 unless $main::options{'log_level'};
......
......@@ -71,6 +71,7 @@ if ($main::options{'help'}) {
printf "Sympa %s\n", Sympa::Constants::VERSION;
exit 0;
}
$Conf::sympa_config = $main::options{config};
if ($main::options{'debug'}) {
$main::options{'log_level'} = 2 unless $main::options{'log_level'};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment