Changeset 1692 for trunk/gsdl


Ignore:
Timestamp:
2000-11-22T16:40:38+13:00 (24 years ago)
Author:
jrm21
Message:

pdftohtml can't handle encrypted pdfs, but doesn't return an error code,
so check if it made the .html file - if not, return 0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/gsConvert.pl

    r1687 r1692  
    4949sub print_usage
    5050{
    51     print STDERR "Usage: $0 [-type doc|pdf] [-output html|text] filename\n";
     51    print STDERR "Usage: $0 [options] filename\n";
     52    print STDERR "Options are:\n\t-type\tdoc|pdf\n\t-output\thtml|text\n";
     53    print STDERR "\t-timeout\t<max cpu seconds>\n";
    5254    exit(1);
    5355}
     
    5759{
    5860    my (@ARGV) = @_;
    59     my ($input_type,$output_type,$verbose);
    60 
     61    my ($input_type,$output_type,$verbose,$timeout);
     62
     63    $timeout = 0;
    6164    # read command-line arguments
    6265    if (!parsargv::parse(\@ARGV,
    6366             'type/(doc|pdf)/', \$input_type,
    6467             'output/(html|text)/', \$output_type,
     68             'timeout/\d+/0',\$timeout,
    6569             'verbose/\d+/0',   \$verbose))
    6670    {
     
    323327    my $wvWare = &util::filename_cat($wv_home, "bin", "wvWare");
    324328    return 0 unless (-e "$wvWare");
    325     $cmd = "ulimit -t 40;";
     329    $cmd = "";
     330    if ($timeout) {$cmd = "ulimit -t $timeout;";}
    326331    $cmd .= "$wvWare --charset utf-8 --config $wv_conf";
    327332    $cmd .= " \"$input_filename\" > \"$output_filestem.html\" 2>\"$output_filestem.err\"";
     
    365370    $r_cmd = "rtf2html" unless (-e "$r_cmd");
    366371    return 0 unless (-e "$r_cmd");
    367     $cmd = "ulimit -t 40;";
     372    $cmd = "";
     373    if ($timeout) {$cmd = "ulimit -t $timeout;";}
    368374    $cmd .= "$r_cmd";
    369375    $cmd .= " \"$input_filename\" > \"$output_filestem.html\" 2>\"$output_filestem.err\"";
     
    403409    return 0 unless (-e "$pdftohtml");
    404410
    405     $cmd = "ulimit -t 40;";
     411    $cmd = "";
     412    if ($timeout) {$cmd = "ulimit -t $timeout;";}
    406413    $cmd .= "$pdftohtml -noframes";
    407414    $cmd .= " \"$input_filename\" \"$output_filestem.html\"";
     
    416423    }
    417424
     425    # make sure the converter made something
     426    if (! -e "$output_filestem.html")
     427    {
     428    &util::rm("$output_filestem.out") if (-e "$output_filestem.out");
     429    # print out the converters std err, if any
     430    if (-e "$output_filestem.err") {
     431        open (ERRLOG, "$output_filestem.err") || die "$!";
     432        print STDERR "pdftohtml:\n";
     433        while (<ERRLOG>) {
     434        print STDERR "$_";
     435        }
     436        close ERRLOG;
     437    }
     438    return 0;
     439    }
     440
    418441    &util::rm("$output_filestem.out") if (-e "$output_filestem.out");
    419442    return 1;
     
    434457    &util::rm("$output_filestem.text") if (-e "$output_filestem.text");
    435458    &util::rm("$output_filestem.err") if (-e "$output_filestem.err");
     459    return 0;
     460    }
     461
     462    # make sure the converter made something
     463    if (! -e "$output_filestem.html")
     464    {
     465    &util::rm("$output_filestem.out") if (-e "$output_filestem.out");
     466    # print out the converters std err, if any
     467    if (-e "$output_filestem.err") {
     468        open (ERRLOG, "$output_filestem.err") || die "$!";
     469        print STDERR "pdftotext:\n";
     470        while (<ERRLOG>) {
     471        print STDERR "$_";
     472        }
     473        close ERRLOG;
     474    }
    436475    return 0;
    437476    }
Note: See TracChangeset for help on using the changeset viewer.