From: Tim Golden on
On 09/08/2010 17:08, Alban Nona wrote:
> Hi,
>
> I have some problem with my actual code.
> In fact, the script is done to work within nuke from the foundry which is a
> compositing software.
> Homever, I have some code difficulties as I quite new in the area.
>
> Here the deal:
> Im using subprocess command to copy some files into local directory, like
> this:
>
> cmd = ['xcopy', '/E', '/I', '/Q', '/Y', '%s' % _folder.replace('/',
> '\\'), '%s' % _temp.replace('/', '\\')]
> subprocess.Popen(cmd, shell=True)
>
> Its copying quite well. I have no problem with that. But, after the copy I
> would like to continue my code, but ONLY if the copy is done.
> If Im using a WAIT, its freezing the main program (nuke) until the copy in
> done. I want to avoid that. I also try "call" but same thing. Its
> freezing...
> I though about something like:
>
> while subprocess not finished:
> Do nothing
> else:
> Continue Program

Have a look at the .poll method of subprocess.Popen

>
> Like this its checking if the files is copying and do nothing until its
> done. I also tough:
>
> while os.listdir(src) != os.listdir(dst):
> Do nothing
> Else:
> Continue program

That's unlikely to work because Windows will create the directory
entry first (and at the complete size) and will then fill it in
as it copies.

TJG