On 24/06/15 20:25, Nirav Patel via Tutor wrote:
> ... research using a program called VisIt.

One simple thing I am trying to do is using python
to call a command that processes all the files that
> exist within the directory by having visit access the files.

I have started to code below, but every time the code
> is executed, I get an error that says,
"u-name command not found"
along with an error that says,
"VisIt is not supported by platform."

Can you post the actual print out from your console in full?
Also can you tell us what 'platform' you are using
 - OS, and VisIT and Python versions

import osos.environ["PATH"]= 
'/Applications/VisIt.app/Contents/Resources/bin/'files = 
os.listdir('/Users/niravpatel/Desktop/Visit /plotfiles')print filesfor file in files:    
if '.py' in file:        import subprocess        subprocess.call(['visit', '-nowin', 
'-cli'])

Please post code in plain text, this is all in one line making it very hard to read. I'll try to unscramble it...

> import os
> os.environ["PATH"]= '/Applications/VisIt.app/Contents/Resources/bin/'
> files = os.listdir('/Users/niravpatel/Desktop/Visit /plotfiles')
> print files

Looks like Python v2?
I'm not sure why you are setting the PATH environment variable unless VisIT reads it? If so you do realize that setting it like this will wipe out all the existing entries?
Finally is there supposed to be a space in the last folder name?

> for file in files:
>     if '.py' in file:

You are looping over the python files? Is that really what you want?

>         import subprocess

Its usual to put all imports at the top of the file in one place.
Not necessary but conventional.

>         subprocess.call(['visit', '-nowin', '-cli'])

You are not specifying any input files/paths to visit so you
just repeat the same command over and over.

Do the commands

PATH='/Applications/VisIt.app/Contents/Resources/bin/'
visit -nowin -cli

work at the command line?
Or do you get different error messages?

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to