From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: Adding extra variables to logs
   Date: Wed, 12 Aug 2009 14:46:33 -0400
Msg# 1880
View Complete Thread (4 articles) | All Threads
Last Next
Hi Craig,

	Glad you found a solution.

	Here's what I was going to reply yesterday, but forgot
	to relply, which may give you some other ideas as well:

>> I have added custom fields to the rush submit and would like to be
>> able to include the slate notes on the jobdone email to give
>> production a better idea of what's been done.

	Your jobdonecommand can invoke a script that gathers the
	info from the files left behind in the log directory, or
	from rush itself.

	When the jobdonecommand runs, environment variables such
	as RUSH_JOBID will be set, which you can use to gather
	info about the job with regular rush commands (like 'rush -ljf',
	'rush -lf', etc).

	Any info you add to the submit form you can save into a
	data file in the log directory at submit time, eg:

# SAVE '$in{MySlateInfo}' TO A FILE IN THE RUSH LOG DIRECTORY
#     This will be picked up by the jobdonecommand when the job is done.
#
if ( $in{LogDirectory} ne "-" ) {
    my $slatefile = "$in{LogDirectory}/slate-info.dat";
    open(SLATEFILE, ">$slatefile");
    print SLATEFILE "$in{MySlateInfo}\n";
    close(SLATEFILE);
}

	..then, when the job finishes and your jobdonecommand is running,
	it can use the RUSH_JOBID or RUSH_LOGFILE variables to determine
	the location of the log directory, load the 'slate-info.dat' file
	(if it exists) and use that for the emails.

>> Does anyone know a good way of adding new variables to the
>> jobdonecommand log or the job log?

	To add info to the 'jobdonecommand log', just have your
	script print the messages you want to either stdout or stderr
	and they'll appear in the jobdonecommand log.

>> I have used the jobdonecommand.log to pull in the artist's name to the
>> email from the "Owner" field.

	To send mail from the jobdonecommand script, you can use
	the various scripting techniques for sending email, such as
	perl's Net::SMTP module, eg:

---- snip
#!/usr/bin/perl -w
#
# Example of how to send emails from perl on all platforms (win/unix/osx)
#
use strict;
use Net::SMTP;
my $mailto = "foo\@bar.com";
my $relay  = "relay.bar.com";
my $smtp = Net::SMTP->new($relay);
if ( ! defined($smtp) ) {
    # ERROR OCCURRED -- TRY AGAIN W/DEBUG ENABLED
    $smtp = Net::SMTP->new($relay, Debug => 1);
    if ( !defined($smtp) ) {
        print "ERROR: Could not connect to $relay (see above)\n";
        exit(1);
    }
}
my ($errs, $expect) = (0,0);
$expect++; $errs += $smtp->mail($mailto);
$expect++; $errs += $smtp->to($mailto);
$expect++; $errs += $smtp->data();
$expect++; $errs += $smtp->datasend("From: Foo <$mailto>\n");
$expect++; $errs += $smtp->datasend("To: $mailto\n");
$expect++; $errs += $smtp->datasend("Subject: testing from SMTP/perl\n");
$expect++; $errs += $smtp->datasend("\n");
$expect++; $errs += $smtp->datasend("This is a test\n");
$expect++; $errs += $smtp->datasend("\n");
$expect++; $errs += $smtp->dataend();
$expect++; $errs += $smtp->quit;
print "EXPECT=$expect, ERRORS=$errs\n";
if ( $expect != $errs ) {
    print "SMTP_ERROR=".$smtp->cgi_error()."\n";
}
exit(0);
---- snip

Craig Allison wrote:
> I've solved the issue by getting the submit script to send an email to
> the production team containing Shot/Artist/Frames/Notes and then the
> jobdonecommand lets them know when it's complete and ready for review.
> 
> Cheers
> Craig
> 
> On 10 Aug 2009, at 15:01, Craig Allison wrote:
> 
>> Hello there
>>
>> Does anyone know a good way of adding new variables to the
>> jobdonecommand log or the job log?
>>
>> I have added custom fields to the rush submit and would like to be
>> able to include the slate notes on the jobdone email to give
>> production a better idea of what's been done.
>>
>> I have used the jobdonecommand.log to pull in the artist's name to the
>> email from the "Owner" field.


-- 
Greg Ercolano, erco@(email surpressed)
Seriss Corporation
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)

Last Next