Need help with shutils.copytree

I have a 'master' directory and a collection of 'slave' dirs. I want the master to collect all of the stuff in the slave dirs.

The slaves all look like this,

|-- slaveX
| `-- archI
| | `-- distJ
| | | ` -- FILE

Where the different slaveX dirs may contain multiple occurrences of archI and distJ, but across all slaveX dirs, there will only be one *unique* instance of FILE in archI and distJ.

Here's an example: Given slave[1234], arch1 and arch2, and dist1 and dist2, I want master to end up looking like this:

|-- master
| `-- arch1
| | ` -- dist1
| | | ` -- FILE
| `-- arch1
| | ` -- dist2
| | | ` -- FILE
| `-- arch2
| | ` -- dist1
| | | ` -- FILE
| `-- arch2
| | ` -- dist2
| | | ` -- FILE


In bash, I might use cpio passthrough mode and say something like:

for slave in ${slaves}
pushd $slave
find . -print | cpio -pdum $master

but I'm having a hard time trying to get this functionality in python. (I'm trying to avoid writing a subprocess.)

I tried using shutil.copytree with a try / except that does a pass on OSError (which is what gets raised when trying to create a dir that already exists). No joy there. I also tried an ignore function that always returns ().

Someone must have done this before. Any suggestions / pointers are much appreciated.

(I hope this was clear to read.)


Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at

Relevant Pages

  • Re: Replikations Frage
    ... vom Master auf den Slave kopiert hast und dabei die Permissions auf ... Die Datenbanken auf den Slave Server laufen ohne Probleme. ... # If you want to know which options a program support, ...
  • Re: When caveman Uhg invented fire
    ... be a business owner. ... But even the smallest "ownership" makes one a slave. ... Any "slave" can become the master. ...
  • Re: One-sided authentication for small micros?
    ... The master has a lookup table of all 'known' slave id's. ... This would reset all the slave keys to their lookup values. ... decides that it is a valid slave and starts to communicate with the slave. ...
  • Re: FIXMBR redux
    ... William, I did the best I could for you under the circumstances and I did ... >> "To remove the recovery console, delete the cmdcons folder from the root ... > drive as Master and formatted it anew, as Active and Primary, ... I then jumpered it as Slave, ...
    ... >that is the master table with the name of the different School levels ... >That is the slave table with all the books used in each specifique level ... Select * from Items where OrderNumber =:OrderNumber. ... Set the Datasource property of the TadoDataset for Items to a datasource hooked ...