Copying files using Python

Hello,

we are trying to run a python script from Deadline Monitor ( Right click on a job -> Scripts).
What the script is doing is copying some renders from a folder A to a folder B, and it works fine.

The issue we have is that while it’s copying the files we can’t do anything else with Deadline Monitor. We tried to run it with multiprocessing or multithreading but they don’t work properly (for example multiprocessing opens another instance of Deadline Monitor and it freezes).

Any advices on how to solve this issue? Thanks in advance

You probably want something like what I’m using to launch a couple of external apps:

def launchAppExternal(filename):
    '''Launch external app

    Args:
        filename (str): Full path to executable
    '''

    if not os.path.isfile(filename):
        console.log('File path {} does not exist'.format(filename))
        return False

    try:
        subprocess.call([filename.replace('/', '\\')])
    except Exception as e:
        console.log('Error opening file {}: {}'.format(filename, e))
        return False

    return True

Keyword being subprocess.call(<args>).

In your particular case though, that means you need to rely on a built-in OS method for the file-copy. Or make your own standalone app to handle the copying with whatever parameters you feed it.

Thanks for the reply Daniel, this is a really great suggestion.
So we are going to try this route and then eventually send back informations to Deadline Monitor once the process is finished.