Magpie/Action/BSWait.pm

filter: Statementstmt 56.6% 17 / 30 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 50.0% 23 / 46 CC 4 SCAR 22.5
CC
4
Cov
46%
run
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 9.4
« Magpie/Action/Update.pm ↑ Summary Magpie/Role/RunningCommand.pm »
1 #
2 # This file is part of App-Magpie
3 #
4 # This software is copyright (c) 2011 by Jerome Quelin.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 1 ▶use 5.012;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 package App::Magpie::Action::BSWait;
14 # ABSTRACT: bswait command implementation
15 1 $App::Magpie::Action::BSWait::VERSION = '2.010';
16 1 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 with 'App::Magpie::Role::Logging';
20  
21  
22  
23 0 ▶sub run {
Subroutine run: not called CC=4 SCAR=30.0
Pod documented
24 0 my ($self, $opts) = @_;
25 0 $self->log( "checking bs wait hint" );
26  
27 0 my $ua = LWP::UserAgent->new;
28 0 $ua->timeout(10);
29 0 $ua->env_proxy;
30  
31 0 my $response = $ua->head('http://pkgsubmit.mageia.org/');
32 0 ▶ $self->log_fatal( $response->status_line ) unless $response->is_success;
Branch: 1 branch
BranchTrueFalseTotal
unless $response->is_success 0 0 0
33  
34 0 my $sleep = $response->header( "x-bs-throttle" );
35 0 $self->log( "bs recommends to sleep $sleep seconds" );
36  
37 0 ▶ if ( !$opts->{nosleep} && $sleep ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $opts->{"nosleep"} and $sleep) 0 0 0
Condition0%0/3
not $opts->{"nosleep"} and $sleep
!ll&&!rl&&r
000
MC/DC0%0/2
not $opts->{"nosleep"} and $sleep
not $opts->{"nosleep"} $sleep
Truth table0%0/3
not(A) and B
A= not $opts->{"nosleep"}B= $sleep
ABresult
0X0
100
111
38 0 $self->log_debug( "sleeping $sleep seconds" );
39 0 sleep($sleep);
40 }
41  
42 0 return $sleep;
43 }
44  
45  
46  
47 1 1;
48  
49 __END__
« Magpie/Action/Update.pm ↑ Summary Magpie/Role/RunningCommand.pm »