Changeset 21305

Show
Ignore:
Timestamp:
09.12.2009 13:15:20 (10 years ago)
Author:
kjdon
Message:

added back in proper chacking for pharos, removeold renamed to remove_all, added remove_one

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gs3-extensions/pharos-imageis/trunk/perllib/plugins/PharosImageIndexer.pm

    r21296 r21305  
    7474    # Check that Pharos is installed and available on the path  
    7575    my $pharos_available = 1; 
    76     ## change for windows! 
    77     #my $result = `phraros-imageis-identify 2>&1`; 
    78     #my $return_value = $?; 
    79     #if ( ($ENV{'GSDLOS'} eq "windows" && $return_value == 256) || $return_value == -1) {  # Linux and Windows return different values for "program not found" 
    80     #    $pharos_available = 0; 
    81     #} 
     76    my $result = `pharos-imageis-identify.pl 2>&1`; 
     77    my $return_value = $?; 
     78    if ( ($ENV{'GSDLOS'} eq "windows" && $return_value == 256) || $return_value == -1) {  # Linux and Windows return different values for "program not found" 
     79        $pharos_available = 0; 
     80    } 
    8281     
    83     $self->{'pharos_available'} = 1; #$pharos_available; 
     82    $self->{'pharos_available'} = $pharos_available; 
    8483     
    8584    if ($self->{'pharos_available'} == 0) { 
     
    9493} 
    9594 
    96 sub removeold { 
     95sub remove_one { 
     96    my $self = shift (@_); 
     97     
     98    my ($file, $oids) = @_; 
     99    print STDERR "in pharos remove_one, $file, $oids\n"; 
     100    return if ($self->{'disable_pharos_imageis'}); 
     101 
     102    if (!$self->{'pharos_available'}) { 
     103    print STDERR "pharos not available, can't remove\n"; 
     104    return; 
     105    } 
     106 
     107    my $doc_id = @$oids[0]; 
     108    return unless defined $doc_id; 
     109    my $collection = &util::get_current_collection_name(); 
     110    my $cmd = "perl -S pharos-imageis-delete.pl $collection $doc_id.jpg 2>&1"; 
     111    print STDERR "Running command $cmd\n"; 
     112    my $result = `$cmd`; 
     113    my $return_value = $?; 
     114    my $outhandle = $self->{'outhandle'}; 
     115    if ($return_value != 0) { 
     116    print $outhandle "Pharos Indexing failed to delete $doc_id from database for collection $collection\n"; 
     117    } 
     118    print $outhandle "$result\n"; 
     119 
     120 } 
     121sub remove_all { 
    97122    my $self = shift (@_); 
    98123    my ($pluginfo, $base_dir, $processor, $maxdocs) = @_; 
     
    101126 
    102127    if (!$self->{'pharos_available'}) { 
    103     print STDERR "pharos not available, not doing a removeold\n"; 
     128    print STDERR "pharos not available, not doing a remove_all\n"; 
    104129    return; 
    105130    } 
    106131    # need to delete everything from the derby database. 
    107132    my $collection = &util::get_current_collection_name(); 
    108     my $cmd = "perl -S pharos-imageis-delete.pl $collection *.jpg 2>&1"; 
     133    my $cmd = "perl -S pharos-imageis-delete.pl $collection '*.jpg' 2>&1"; 
    109134    print STDERR "Running command $cmd\n"; 
    110135    my $result = `$cmd`;