line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task; |
2
|
|
|
|
|
|
|
|
3
|
15
|
|
|
15
|
|
1473147
|
use strict; |
|
15
|
|
|
|
|
19
|
|
|
15
|
|
|
|
|
364
|
|
4
|
15
|
|
|
15
|
|
50
|
use warnings; |
|
15
|
|
|
|
|
18
|
|
|
15
|
|
|
|
|
386
|
|
5
|
|
|
|
|
|
|
|
6
|
15
|
|
|
15
|
|
430
|
use English qw(-no_match_vars); |
|
15
|
|
|
|
|
2475
|
|
|
15
|
|
|
|
|
156
|
|
7
|
15
|
|
|
15
|
|
6187
|
use File::Find; |
|
15
|
|
|
|
|
21
|
|
|
15
|
|
|
|
|
902
|
|
8
|
|
|
|
|
|
|
|
9
|
15
|
|
|
15
|
|
4711
|
use FusionInventory::Agent::Tools; |
|
15
|
|
|
|
|
26
|
|
|
15
|
|
|
|
|
1798
|
|
10
|
15
|
|
|
15
|
|
3641
|
use FusionInventory::Agent::Logger; |
|
15
|
|
|
|
|
26
|
|
|
15
|
|
|
|
|
3919
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
4
|
|
|
4
|
1
|
1365
|
my ($class, %params) = @_; |
14
|
|
|
|
|
|
|
|
15
|
4
|
100
|
|
|
|
22
|
die 'no target parameter' unless $params{target}; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $self = { |
18
|
|
|
|
|
|
|
logger => $params{logger} || |
19
|
|
|
|
|
|
|
FusionInventory::Agent::Logger->new(), |
20
|
|
|
|
|
|
|
config => $params{config}, |
21
|
|
|
|
|
|
|
confdir => $params{confdir}, |
22
|
|
|
|
|
|
|
datadir => $params{datadir}, |
23
|
|
|
|
|
|
|
target => $params{target}, |
24
|
|
|
|
|
|
|
deviceid => $params{deviceid}, |
25
|
3
|
|
66
|
|
|
23
|
}; |
26
|
3
|
|
|
|
|
6
|
bless $self, $class; |
27
|
|
|
|
|
|
|
|
28
|
3
|
|
|
|
|
13
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub abort { |
32
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
33
|
0
|
|
|
|
|
0
|
$self->{logger}->info("aborting task"); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub getModules { |
37
|
1
|
|
|
1
|
1
|
424
|
my ($class, $prefix) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# allow to be called as an instance method |
40
|
1
|
50
|
|
|
|
4
|
$class = ref $class ? ref $class : $class; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# use %INC to retrieve the root directory for this task |
43
|
1
|
|
|
|
|
5
|
my $file = module2file($class); |
44
|
1
|
|
|
|
|
4
|
my $rootdir = $INC{$file}; |
45
|
1
|
|
|
|
|
4
|
$rootdir =~ s/.pm$//; |
46
|
1
|
50
|
|
|
|
23
|
return unless -d $rootdir; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# find a list of modules from files in this directory |
49
|
1
|
|
|
|
|
2
|
my $root = $file; |
50
|
1
|
|
|
|
|
2
|
$root =~ s/.pm$//; |
51
|
1
|
50
|
|
|
|
3
|
$root .= "/$prefix" if $prefix; |
52
|
1
|
|
|
|
|
2
|
my @modules; |
53
|
|
|
|
|
|
|
my $wanted = sub { |
54
|
200
|
100
|
|
200
|
|
2273
|
return unless -f $_; |
55
|
174
|
50
|
|
|
|
676
|
return unless $File::Find::name =~ m{($root/\S+\.pm)$}; |
56
|
174
|
|
|
|
|
277
|
my $module = file2module($1); |
57
|
174
|
|
|
|
|
1412
|
push(@modules, $module); |
58
|
1
|
|
|
|
|
4
|
}; |
59
|
1
|
|
|
|
|
122
|
File::Find::find($wanted, $rootdir); |
60
|
|
|
|
|
|
|
return @modules |
61
|
1
|
|
|
|
|
46
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
__END__ |