Ignore:
Timestamp:
2014-06-12T12:18:42+12:00 (10 years ago)
Author:
kjdon
Message:

new argument to print_txt_usage. Pass 1 if you don't want the output paged. We use this when there has been an error and we are outputing the options before quitting the import/build. If the output is paged, then the die doesn't end up getting through to the top level program. So for full-rebuild, if the import died because of a parsing error, if the output had been paged, then the import was stopped but the system return value was 0, and then it would go on to the next stage, trying to build. So now, if we are stopping because of an error, then don't page the output. Also added a few more (hopefully) helpful error messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/inexport.pm

    r29013 r29096  
    195195    if ($intArgLeftinAfterParsing == -1)
    196196    {
    197     &PrintUsage::print_txt_usage($options, "{import.params}");
     197    &PrintUsage::print_txt_usage($options, "{import.params}",1);
     198    print STDERR "Something went wrong during parsing the arguments. Scroll up for details.\n";
    198199    die "\n";
    199200    }
    200    
     201
    201202    my $language = $self->{'language'};
    202203    # If $language has been specified, load the appropriate resource bundle
     
    217218    }
    218219
    219 
    220220    if ($self->{'xml'}) {
    221221        &PrintUsage::print_xml_usage($options);
     
    227227    &gsprintf::output_strings_in_UTF8;
    228228    }
    229    
     229
     230    # If the user specified -h, then we output the usage
     231    if (@$argv && $argv->[0] =~ /^\-+h/) {
     232    &PrintUsage::print_txt_usage($options, "{import.params}");
     233    die "\n";
     234    }
    230235    # now check that we had exactly one leftover arg, which should be
    231236    # the collection name. We don't want to do this earlier, cos
    232237    # -xml arg doesn't need a collection name
    233     # Or if the user specified -h, then we output the usage also
    234 
    235     if ($intArgLeftinAfterParsing != 1 || (@$argv && $argv->[0] =~ /^\-+h/))
     238
     239    if ($intArgLeftinAfterParsing != 1 )
    236240    {
    237     ## TODO if we had invalid arg, can we signal that to user???
    238     &PrintUsage::print_txt_usage($options, "{import.params}");
     241    &PrintUsage::print_txt_usage($options, "{import.params}", 1);
     242    print STDERR "There should be one argument left after parsing the script args: the collection name.\n";
    239243    die "\n";
    240244    }
     
    306310     
    307311    if (($collection = &colcfg::use_collection($site, $collection, $collectdir)) eq "") {
    308     &PrintUsage::print_txt_usage($options, "{import.params}");
     312    #&PrintUsage::print_txt_usage($options, "{import.params}", 1);
    309313    die "\n";
    310314    }
     
    13841388        $doc_source_file = &util::placeholders_to_abspath($doc_source_file);
    13851389
    1386         if (!&util::filename_is_absolute($doc_source_file)) {
     1390        if (!&FileUtils::isFilenameAbsolute($doc_source_file)) {
    13871391        $doc_source_file = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'},$doc_source_file);
    13881392        }
Note: See TracChangeset for help on using the changeset viewer.