Changeset 29096

Show
Ignore:
Timestamp:
12.06.2014 12:18:42 (5 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

Location:
main/trunk/greenstone2/perllib
Files:
2 modified

Legend:

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

    r29079 r29096  
    8383  if ($intArgLeftinAfterParsing == -1) 
    8484  { 
    85     &PrintUsage::print_txt_usage($options, "{buildcol.params}"); 
     85    &PrintUsage::print_txt_usage($options, "{buildcol.params}",1); 
     86    print STDERR "Something went wrong during parsing the arguments. Scroll up for details.\n"; 
    8687    die "\n"; 
    8788  } 
     
    110111    &gsprintf::output_strings_in_UTF8; 
    111112  } 
    112  
     113   
     114  # If the user specified -h, then we output the usage 
     115  if (@$argv && $argv->[0] =~ /^\-+h/) { 
     116      &PrintUsage::print_txt_usage($options, "{buildcol.params}"); 
     117      die "\n"; 
     118  } 
     119   
    113120  # now check that we had exactly one leftover arg, which should be 
    114121  # the collection name. We don't want to do this earlier, cos 
    115122  # -xml arg doesn't need a collection name 
    116   # Or if the user specified -h, then we output the usage also 
    117   if ($intArgLeftinAfterParsing != 1 || (@ARGV && $ARGV[0] =~ /^\-+h/)) 
    118   { 
    119     &PrintUsage::print_txt_usage($options, "{buildcol.params}"); 
     123  if ($intArgLeftinAfterParsing != 1) 
     124  { 
     125    &PrintUsage::print_txt_usage($options, "{buildcol.params}", 1); 
     126    print STDERR "There should be one argument left after parsing the script args: the collection name.\n"; 
    120127    die "\n"; 
    121128  } 
     
    163170  if (($collection = &colcfg::use_collection($site, $collection, $collectdir)) eq "") 
    164171  { 
    165     &PrintUsage::print_txt_usage($options, "{buildcol.params}"); 
     172    #&PrintUsage::print_txt_usage($options, "{buildcol.params}", 1); 
    166173    die "\n"; 
    167174  } 
  • 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        }