Changeset 27687 for other-projects


Ignore:
Timestamp:
2013-06-21T17:32:41+12:00 (11 years ago)
Author:
ak19
Message:

Fixes for task.pl: html diffcol report failed to upload properly to puka from Win, so that it was 0 bytes in size once there, but htm worked. Not using blat by default, there's a flag to turn this on. Finally, task.pl works when run from run-gs2-diffcol.bat via envi.pl now that the correct perl (not strawberry perl) is prefixed to the PATH in the localised diffcol\environment.pl. (It was very hard to work out what was going wrong there.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • other-projects/nightly-tasks/diffcol/trunk/task.pl

    r27678 r27687  
    3535#my $script_ext = $isWin ? ".bat" : ".bash";
    3636my $setup_script = "setup"; # needs to become gs3-setup for GS3
     37my $use_blat = 0; # if we ever get blat to send mail/attachments on Windows working, set this to 1
    3738
    3839# TASK_HOME should be the toplevel diffcol folder
     
    4546
    4647# we'll be using BLAT to send mail attachments on Windows
    47 my $blat = &filename_concat($ENV{'BIN_DIR'}, "blat", "full", "blat.exe");
    48 if($isWin && ! -e $blat) {
    49     print STDERR "*** No blat.exe found in $blat.\n";
    50     print STDERR "*** Blat needed to send mail with attachments on Windows.\n";
    51     print STDERR "*** Extract the blat zip file found in $ENV{'BIN_DIR'}\n";
    52     print STDERR "*** for your bit architecture and name the folder 'blat'\n";
    53    
     48my $blat = $use_blat ? &filename_concat($ENV{'BIN_DIR'}, "blat", "full", "blat.exe") : 0;
     49if($isWin && $use_blat && ! -e $blat) {
     50    print STDERR "\n***********************************\n";
     51    print STDERR "No blat.exe found in $blat.\n";
     52    print STDERR "Blat needed to send mail with attachments on Windows.\n";
     53    print STDERR "Extract the blat zip file found in $ENV{'BIN_DIR'}\n";
     54    print STDERR "for your bit architecture and name the folder 'blat'\n";
     55    print STDERR "***********************************\n\n";
    5456    $blat = 0;
    5557}
     
    390392    print STDERR "$collection - Importing:\n";
    391393    print $xml_fh "<import>\n";
    392     &run_build_script("import.pl -OIDtype hash_on_full_filename $collection -removeold");
     394    &run_build_script("import.pl $collection -removeold"); #-OIDtype hash_on_full_filename
    393395    print $xml_fh "</import>\n";
    394396    print STDERR "done\n"; 
     
    450452
    451453#    chdir($greenstone_home);
    452 
    453     # we are in $greenstone_home, can directly run the build cmd on the collection
     454    # we are in $greenstone_home already, can directly run the build cmd on the collection
    454455    if(!$isWin) {
    455456    $cmd = "bash -c \"export GSDLHOME=&& source $setup_script.bash && $cmd\"";
     
    457458    } else { # Need to prefix cmd -c/-k as necessary
    458459    $cmd = "cmd /c \"set GSDLHOME=&& $setup_script.bat && perl -S $cmd\"";
    459 ##  print STDERR "@@@@ Going to call command: $cmd\n";
    460    
    461     }
     460    }
     461##     print STDERR "@@@@ Going to call command: $cmd\n";
    462462
    463463    return system($cmd);
     
    565565    opendir my($dh), $ENV{'DATA_DIR'} or die "Could not open DATA_DIR: $!";
    566566    for my $entry (readdir $dh) {
    567     next if ($entry !~ m/(\.xml|\.html)$/);
    568     # get the absolute path to the files before copying them over
    569     $entry = &filename_concat($ENV{'DATA_DIR'}, $entry);
    570     copy($entry, $ENV{'UPLOAD_DIR'});
     567    next if ($entry !~ m/(\.xml|\.html?)$/);
     568
     569    # copy the reports across with different names: with OS prefixed to them. And for the HTML file on Win, rename to HTM
     570    # html files uploaded from windows to nzdl are empty for no reason. Uploading as htm seems to work
     571    my $os = $^O;
     572    (my $os_entry = $entry) =~ s@\[email protected]@ if $isWin;
     573    $os_entry = $^O."-$os_entry";   
     574   
     575    # get the absolute path to the original files before copying them over
     576    $entry = &filename_concat($ENV{'DATA_DIR'}, $entry);       
     577
     578    # copy them over with their new names
     579##  print STDERR "@@@@ copying across $entry to $ENV{'UPLOAD_DIR'} as $os_entry\n";
     580    copy($entry, "$ENV{'UPLOAD_DIR'}$sep$os_entry"); #copy($entry, "$ENV{'UPLOAD_DIR'}");
    571581    }
    572582    closedir $dh;
     
    588598   
    589599    # the report we want to upload is actually just report-$dateid.html
    590     my $command = "cd \"$ENV{'UPLOAD_DIR'}\" && tar -c *.html | "; #&& cat *.html | "; # && tar -c * |
     600    my $command = "cd \"$ENV{'UPLOAD_DIR'}\" && tar -c *.htm* | "; #&& cat *.html | "; # && tar -c * |
    591601    $command .= ($^O eq "MSWin32" ? "plink" : "ssh");
    592602    $command .= " -T -i \"$ENV{'IDENTITY_FILE'}\" nzdl\@puka.cs.waikato.ac.nz";
     
    621631    my $attach_file = &filename_concat($ENV{'DATA_DIR'}, "report-$dateid.html");
    622632
    623     if($isWin) {
    624         if($blat && $ENV{'GSDL_SMTP'}) {
     633    if($isWin) {   
     634        if($use_blat && $blat && $ENV{'GSDL_SMTP'}) {
    625635            # http://stackoverflow.com/questions/709635/sending-mail-from-batch-file
    626636            #blat -to [email protected] -server smtp.example.com -f [email protected] -subject "subject" -body "body"
     
    631641        }
    632642        else {
    633             $result = 0;
     643            $result = 1; # status from running mail command is 0 if success, 1 if fail
    634644            print STDERR "********************************************\n";
    635             print STDERR "Need blat and SMTP set to send mail attachment\n";
     645            if ($use_blat) {
     646                print STDERR "Need blat and SMTP set to send mail attachment\n" ;
     647            } else {   
     648                print STDERR "Not set up to send mail on Windows\n";
     649            }
    636650            print STDERR "Inspect report at: $attach_file\n";
    637651            print STDERR "********************************************\n";
Note: See TracChangeset for help on using the changeset viewer.