Ignore:
Timestamp:
2013-06-17T22:05:58+12:00 (11 years ago)
Author:
ak19
Message:

Added section which does uploading to nzdl (though that will only work on the VM installations with the correct .ssh files), bugfix to checking upload_dir exists and added some error handling for sending attachments by mail

File:
1 edited

Legend:

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

    r27630 r27637  
    504504    # ensure the upload directory exists before trying to transfer the xml and html files across
    505505    # if it already existed, clear it of contents
    506     if (-d $ENV{'UPLOAD_DIR'}) {
     506    if (!-d $ENV{'UPLOAD_DIR'}) {
    507507    &File::Path::make_path($ENV{'UPLOAD_DIR'});
    508508    } # else rm $UPLOAD_DIR/*   
     
    515515    }
    516516    closedir $dh;
     517
     518
     519    # Upload the html file to puka
     520    #default identity dir
     521    if ( ! exists $ENV{'IDENTITY_DIR'} ) {
     522    $ENV{'IDENTITY_DIR'} = "$ENV{'HOME'}${sep}.ssh";
     523    }
     524    if (! exists $ENV{'SNAPSHOT_MODE'} ) {
     525    $ENV{'SNAPSHOT_MODE'} = "caveat";
     526    }
     527
     528    #use the  correct key for uploading
     529    $ENV{'IDENTITY_FILE'} = "$ENV{'IDENTITY_DIR'}${sep}upload-" . $ENV{'SNAPSHOT_MODE'} . ($^O eq "MSWin32" ? ".ppk" : "");
     530    if(-f $ENV{'IDENTITY_FILE'}) {
     531    my $command = "cd \"$ENV{'UPLOAD_DIR'}\" && tar -c *.html | "; #&& cat *.html | "; # && tar -c * |
     532    $command .= ($^O eq "MSWin32" ? "plink" : "ssh");
     533    $command .= " -T -i \"$ENV{'IDENTITY_FILE'}\" nzdl\@puka.cs.waikato.ac.nz";
     534    #print "$command\n";
     535    my $status = system("$command");
     536    if($status != 0) {
     537        print STDERR "*** Failed to upload test report to nzdl\n";
     538    }
     539    } else {
     540    print STDERR "*** Cannot upload the test report to nzdl from this machine\n";
     541    }
    517542
    518543    print STDERR "Finished uploading\n";
     
    560585
    561586    # run the mail command
    562     system($cmd); # &run_and_print_cmd($cmd);
    563 
    564     print STDERR "Sent mail with report attached.\n";
     587    $result = system($cmd); #&run_and_print_cmd($cmd);
     588    if($result != 0) {
     589        print STDERR "*** Unable to send email: $?\n";
     590    }
     591    else {
     592        print STDERR "Sent mail with report attached.\n";
     593    }
    565594    } else {
    566595    print STDERR "********************************************\n";
Note: See TracChangeset for help on using the changeset viewer.