Changeset 141


Ignore:
Timestamp:
12/13/05 23:26:06 (19 years ago)
Author:
thauvin
Message:
  • add --dry-run
Location:
trunk/soft/ObsData
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/soft/ObsData/ObsData.pm

    • Property cvs2svn:cvs-rev changed from 1.46 to 1.47
    r134 r141  
    5151        logcallback => $options{logcallback}, 
    5252        logfile => $options{logfile} || "obsdata.log", 
     53        dry_run => $options{dry_run}, 
    5354    }; 
    5455 
     
    367368            obs => $obs, 
    368369            datatype => $datatype, 
     370            dry_run => $self->{dry_run}, # FIXME does this have a better place ? 
    369371            patern => $self->getvalue( 
    370372                $obs, 
  • trunk/soft/ObsData/ObsData/Repository.pm

    • Property cvs2svn:cvs-rev changed from 1.48 to 1.49
    r139 r141  
    132132    ); 
    133133    
    134     $self->{status}->WriteConfig($self->{statusfile}); 
     134    $self->{status}->WriteConfig($self->{statusfile}) if(!$self->{dry_run}); 
    135135} 
    136136 
     
    622622    if ($dirname && ! -d $dirname) { 
    623623        $self->logging(0, "Creating directory %s", $dirname); 
    624         if( ! File::Path::mkpath($dirname)) {  
    625             $self->logging( 
    626                 4, "Can't create directory %s",  
     624        if ($self->{dry_run}) { 
     625            if( ! File::Path::mkpath($dirname)) {  
     626                $self->logging( 
     627                    4, "Can't create directory %s",  
     628                    $dirname 
     629                ); 
     630                return 0; 
     631            } 
     632        } else { 
     633            $self->logging(0, 
     634                "Testing mode, assume %s was correctly created", 
    627635                $dirname 
    628636            ); 
    629             return 0; 
    630         } 
    631     } 
    632  
    633     if ($self->{Oarchive}->extract($datafile, $destfile)) { 
    634         $self->set_data_value($datafile, 'dest', $destfile); 
    635         $self->logging( 
    636             1, "Extraction of %s/%s done as %s", 
     637        } 
     638    } 
     639 
     640    if ($self->{dry_run}) { 
     641        $self->logging(1, 
     642            "Testing mode, %s/%s would be extracted as %s", 
    637643            $self->{archivefile}, 
    638644            $datafile, 
    639645            $destfile, 
    640646        ); 
    641              
    642647    } else { 
    643         $self->logging( 
    644             4, "Can't extract %s/%s to %s: %s", 
    645             $self->{archivefile}, $datafile, $destfile, 
    646             $self->{Oarchive}->error, 
    647         ); 
    648         return 0; 
    649     } 
    650  
     648        if ($self->{Oarchive}->extract($datafile, $destfile)) { 
     649            $self->set_data_value($datafile, 'dest', $destfile); 
     650            $self->logging( 
     651                1, "Extraction of %s/%s done as %s", 
     652                $self->{archivefile}, 
     653                $datafile, 
     654                $destfile, 
     655            ); 
     656        } else { 
     657            $self->logging( 
     658                4, "Can't extract %s/%s to %s: %s", 
     659                $self->{archivefile}, $datafile, $destfile, 
     660                $self->{Oarchive}->error, 
     661            ); 
     662            return 0; 
     663        } 
     664    } 
     665     
    651666    return 1; 
    652667} 
  • trunk/soft/ObsData/bin/obsdata

    • Property cvs2svn:cvs-rev changed from 1.12 to 1.13
    r125 r141  
    2424    'c|config=s' => \my $configfile, 
    2525    'check' => \my $check_only, 
     26    'dry-run' => \my $dryrun, 
    2627    'l|logfile=s' => \my $log, 
    2728    'debug' => sub { $verbose = 0 }, 
     
    5556Increase verbosity (this does not affect log output) 
    5657 
     58=item --dry-run 
     59 
     60Does everything except write on disk, log are filled anyway 
     61 
    5762=item --debug 
    5863 
     
    7176    logfile => $log, 
    7277    verbose => 0, 
     78    dry_run => $dryrun, 
    7379    logcallback => sub { 
    7480        return if($_[0] < $verbose); 
Note: See TracChangeset for help on using the changeset viewer.