Changeset 27678

Show
Ignore:
Timestamp:
20.06.2013 21:31:07 (6 years ago)
Author:
ak19
Message:

Uploading report to caveat-emptor page now works on windows

Files:
1 modified

Legend:

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

    r27677 r27678  
    4242 
    4343 
     44$ENV{'BIN_DIR'} = &filename_concat($ENV{'TASK_HOME'}, "bin"); 
     45 
     46# we'll be using BLAT to send mail attachments on Windows 
     47my $blat = &filename_concat($ENV{'BIN_DIR'}, "blat", "full", "blat.exe"); 
     48if($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     
     54    $blat = 0; 
     55} 
     56 
     57 
    4458$ENV{'DATA_DIR'} = &filename_concat($ENV{'TASK_HOME'}, "diffcol-data"); 
    4559$ENV{'UPLOAD_DIR'} = &filename_concat($ENV{'TASK_HOME'}, "diffcol-reports"); 
    4660$ENV{'MONITOR_EMAIL'} = "greenstone_team\@cs.waikato.ac.nz"; # need to escape @ sign 
    47 $ENV{'GSDL_SMTP'} = ""; 
     61$ENV{'GSDL_SMTP'} = ""; #"smtp.gmail.com"; 
    4862##print STDERR "@@@ email: ".$ENV{'MONITOR_EMAIL'}."\n"; 
    4963 
     
    568582    } 
    569583 
    570     #use the  correct key for uploading 
     584    #use the correct key for uploading 
    571585    $ENV{'IDENTITY_FILE'} = "$ENV{'IDENTITY_DIR'}${sep}upload-" . $ENV{'SNAPSHOT_MODE'} . ($^O eq "MSWin32" ? ".ppk" : ""); 
    572586    if(-f $ENV{'IDENTITY_FILE'}) { 
     587    # if you need to touch the file on windows: http://stackoverflow.com/questions/51435/windows-version-of-the-unix-touch-command 
     588     
    573589    # the report we want to upload is actually just report-$dateid.html 
    574590    my $command = "cd \"$ENV{'UPLOAD_DIR'}\" && tar -c *.html | "; #&& cat *.html | "; # && tar -c * | 
     
    578594    my $status = system("$command"); 
    579595    if($status != 0) { 
    580         print STDERR "*** Failed to upload test report to nzdl\n"; 
     596        print STDERR "*** Failed to upload test report to nzdl $status\n"; 
    581597    } 
    582598    } else { 
     
    605621    my $attach_file = &filename_concat($ENV{'DATA_DIR'}, "report-$dateid.html"); 
    606622 
    607     if($isWin) {         
    608         # http://stackoverflow.com/questions/709635/sending-mail-from-batch-file 
    609         #blat -to user@example.com -server smtp.example.com -f batch_script@example.com -subject "subject" -body "body" 
    610  
    611         $cmd = "blat -to $ENV{'MONITOR_EMAIL'} -server $ENV{'GSDL_SMTP'} -f $attach_file -subject $subject -body $msg"; # need to install blat on windows 
    612  
    613     } else { 
     623    if($isWin) { 
     624        if($blat && $ENV{'GSDL_SMTP'}) { 
     625            # http://stackoverflow.com/questions/709635/sending-mail-from-batch-file 
     626            #blat -to user@example.com -server smtp.example.com -f batch_script@example.com -subject "subject" -body "body" 
     627 
     628            # need to install blat on windows 
     629            $cmd = "$blat -to $ENV{'MONITOR_EMAIL'} -server $ENV{'GSDL_SMTP'} -f $ENV{'MONITOR_EMAIL'} -attach $attach_file -subject \"$subject\" -body \"$msg\"";           
     630            $result = system($cmd);  
     631        } 
     632        else { 
     633            $result = 0; 
     634            print STDERR "********************************************\n"; 
     635            print STDERR "Need blat and SMTP set to send mail attachment\n"; 
     636            print STDERR "Inspect report at: $attach_file\n"; 
     637            print STDERR "********************************************\n"; 
     638        } 
     639    } else { # linux 
    614640        my $status = system("command -v mutt > /dev/null 2>&1;"); #better way of doing "which mutt" 
    615641         
     
    625651        $cmd = "echo '$gsdl regression test for $dateid failed' | mutt -a $attach_file -s 'Regression Test Failed' -- $ENV{'MONITOR_EMAIL'}"; 
    626652        } 
    627     } 
    628  
    629     # run the mail command 
    630     $result = system($cmd); #&run_and_print_cmd($cmd); 
     653         
     654        # run the mail command 
     655        $result = system($cmd); #&run_and_print_cmd($cmd); 
     656    } 
     657 
     658     
    631659    if($result != 0) { 
    632660        print STDERR "*** Unable to send email: $?\n";