Hello everybody !
wow my first time on danyweb ! ;p
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 !