[python-win32] Permission denied erro while copying file from remote machine to local using win32wnet.WnetAddConnection
siddhartha veedaluru
siddhartha.veedaluru at gmail.com
Tue Jun 30 10:05:22 CEST 2009
Hi,
I have used the following code snippet to copy files or folder from remote
machine to local machine.
I have used the same method to copy files to remote machine.
Can some one point me to solve this?
Or
Help needed to copy files or folders from remote machne ot lcoal one and
also remote to remote copy if possible.
thanks
Siddhartha
--------------------------------------------------------------------
def netToLocalCopy(hostName, userName, password, source, destPath,
move=False):
"Copies files or directories from a remote computer to local machine."
#Establish the connection to remote machine
wnet_connect(hostName, userName, password)
# Get the UNC Path of the Destination Path
src_dir = convert_unc(hostName, source)
# Pad a backslash to the destination directory if not provided.
if not destPath[len(destPath) - 1] == '\\':
destPath = ''.join([destPath, '\\'])
mesg = "Copying %s to %s Destination Directory on local host" %
(src_dir, destPath)
print mesg
# Create the destination dir if its not there.
if not os.path.exists(destPath):
os.makedirs(destPath)
else:
# Create a directory anyway if file exists so as to raise an error.
if not os.path.isdir(destPath):
os.makedirs(destPath)
print os.listdir(src_dir)
try:
if move:
shutil.move(src_dir, destPath)
else:
shutil.copy(src_dir, destPath)
except OSError, erno:
print erno
print sys.exc_info()
return 1
return 0
-------------------------------------------------------------------------------------------------------
shutil.copy(src_dir, destPath)
File "C:\Python25\lib\shutil.py", line 80, in copy
copyfile(src, dst)
File "C:\Python25\lib\shutil.py", line 46, in copyfile
fsrc = open(src, 'rb')
IOError: [Errno 13] Permission denied: '\\\\test7\\G$\\Test Lib'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20090630/1d506453/attachment.htm>
More information about the python-win32
mailing list