From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: Using Rush in a slightly different way [for Framecycler]
   Date: Tue, 20 Sep 2005 13:20:56 -0700
Msg# 1040
View Complete Thread (3 articles) | All Threads
Last Next
Mark Smith wrote:
Interesting to see your views on Python. I haven't spent all that much
time with 'real' scripting languages. I can see from your examples how
many tasks can be made simpler with them. I think I'll have a look at
csh real soon....any good books you can recommend?

	CSH is good for simple things.. but runs out of steam quickly
	when you want to do complex text manipulations or subroutines
	as I do in my gui submit scripts.

	But csh is great for making simple command line oriented submit
	scripts, though you often end up having to use external programs
	like sed(1) to do text manipulations, and awk(1) to do things
	like padded zeroes. Or even perl(1) which can do all of those things.

	CSH/TCSH is good to know just for bopping around on the command line..
	my favorite book on learning CSH is this one:
	http://www.amazon.com/exec/obidos/tg/detail/-/013937468X/qid=1127247128/sr=1-2/ref=sr_1_2/002-8701294-1017638?v=glance&s=books

Maybe it's about getting the right mix of things. At my last place much
of the core pipeline code was Python....this could be the reason the
submission scripts were in Python too.

	Python is fine; if you know it, use it.

	The items I cited are not show stoppers at all.. they're just
	nits from an old scripting hound who's picky.

	If all the scripts were already in python, I probably wouldn't
	port them to perl just to make them a little easier to read for me. ;)

I see from the Rush documentation that you can source render
environments in csh but I'm not too sure it would be too easy to do if
you were creating your render environments by sucking things out of a
database. Or maybe I'm wrong?

	You should be able to do anything.

	For instance, to load a csh environment into perl, this simple
	bit of magic spawns a csh to load the settings, then prints them
	out in a format that perl can read back and load into its own environment:

# LOAD A CSH SCRIPT'S ENVIRONMENT SETTINGS INTO PERL ENVIRONMENT
#    $1 = csh script to be 'sourced'
#    Returns: $ENV{} modified as per csh script's settings.
#
sub LoadEnvFromCsh()
{
    my ($rcfile) = @_;
    my $vars = `csh -fc 'source $rcfile; printenv'`;
    foreach ( split(/\n/, $vars) )
        { if ( /(^[^=]*)=(.*)/ ) { $ENV{$1} = $2; } }
}

	And here's a function for loading Bourne Shell (sh, bash)
	style settings from e.g. /etc/profile or /etc/bashrc files:

# LOAD A BASH SCRIPT'S ENVIRONMENT SETTINGS INTO PERL ENVIRONMENT
#    $1 = bash profile to be 'sourced'
#    Returns: $ENV{} modified as per bash profile's settings.
#
sub LoadEnvFromBash($)
{
      my ($rcfile) = $_[0];
      my $vars = `bash -c '. $rcfile; printenv'`;
      foreach ( split(/\n/, $vars) )
          { if ( /(^[^=]*)=(.*)/ ) { $ENV{$1} = $2; } }
}

	I'm sure a similar technique can be done in python.


	Even if the csh is getting settings from a 'database',
	it wouldn't matter. Once they're in the environment,
	they can be accessed with the above technique.

	But I recommend against having render scripts source in
	user .cshrc files. Global .cshrc files are ok, but user .cshrcs
	tend to have errors in them, and are inconsistent from user to user,
	machine to machine.

	Better to have the sysadmin (you?) configure the environment settings
	in the submit script, so that the script works the same for everyone,
	no matter how broken their .cshrc files are ;)



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

Last Next