Copy / Update - Paste a directory.

Alban Nona python.koda at gmail.com
Mon Jun 28 09:49:28 EDT 2010


 Hello everybody !

wow my first time on this mailing list :)

Well, here the deal.
Im doing a script that basically copy and past into the local drive a
specified directory with all this files.
Im doing the copy with a copytree which is working well.
But, (and I know it will not work as copytree dont update directory) Im,
like, stuck when I have to update the directory.

For a better understanding here what the tree look like:

G:/prod/actual/project/xxx/shot/shot_EN_006/render/v001

and sometime as we have to rerender, we update the "render" folder with a
v002:

G:/prod/actual/project/xxx/shot/shot_EN_006/render/v002


So, actually my script can copy my
*G:/*prod/actual/project/xxx/shot/shot_EN_006/render/v001
directory to *C:/*prod/actual/project/xxx/shot/shot_EN_006/render/v001
but I dont know how to proceed to update this folder when asked.

Here the actual script, as you can see the update part will not work.



------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------


# -*- coding: utf-8 -*-
import os
import sys
import threading
import shutil
def checkRead():
    networkMount = 'D:/'
    localMount = 'C:/'

    for item in sys.argv:
        project = (sys.argv[2])
        path = (sys.argv[3])
    workPath = '/Prod//Projects/' + '/' + project + '/' +  '/shots/' + '/' +
path + '/' + '/render/' + '/REN/'

    localPath = localMount + workPath
    networkPath = networkMount + workPath
    if sys.argv[1] == 'update':
        if os.listdir(networkPath) != os.listdir(localPath):
            copyfile = shutil.copyfile(networkPath, localPath)

    elif sys.argv[1] == 'copy':
        if os.path.exists(localPath) == 0:
            copytree = shutil.copytree(networkPath, localPath,
symlinks=True, ignore=None)
    if sys.argv[1] not in  ('update', 'copy'):
        print 'Error, please enter the command: "update" or "copy"'

if __name__ == "__main__":
    checkRead()



------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------


Anyone can help me to figure out a solution please ?.

Thank you and have a good day !
 PS: Im not sure that the first mail worked so I resend it, sorry for the
flood.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100628/49e47ec7/attachment-0001.html>


More information about the Python-list mailing list