Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 24-04-2009
Member
 
Join Date: May 2008
Posts: 859
Permission denied in Python when copying files

I start in Python and I'm pretty bad in the program in general. Here is my situation:

Here is the tree:
C:\MySoft\MyFolder
C:\Shift

In MyFolder:
AppliCommon
ObjectMetier
Main

In Shift:
AppliCommon
Main

The purpose of the script is to update an application that is done by replacing files. Therefore, I must first save and then replace MyFolder by MyFolder files by folders and files in SHIFT. Note that all files contain several sub-folders and files.

I've done this:
Code:
src = r'C:\Shift' 
dst = r'C:\MySoft\\MyFolder ' 
for f in os.listdir (src): 
shutil.copy (os.path.join (src, f), os.path.join (dst, f))
But I have this error:
Quote:
C:\Python26> python.exe "C:\Documents and Settings\Dje\Desktop\depl.py"
Traceback (most recent call last):
File "C:\Documents and Settings\Dje\Desktop\depl.py", line 12, in <module>
shutil.copy (os.path.join (src, f), os.path.join (dst, f))
File "C:\Python26\lib\shutil.py", line 88, in copy
CopyFile (src, dst)
File "C:\Python26\lib\shutil.py", line 52, in CopyFile
fsrc = open (src, 'rb')
IOError: [Err no 13] Permission denied: 'C:\\Update\\Main'
Reply With Quote
  #2  
Old 24-04-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: Permission denied in Python when copying files

You do not have rights to c:\shift\main.

Incidentally, shutil has a copytree making a recursive copy alone as a great, no need to make a combo & listdir copy.
Reply With Quote
  #3  
Old 24-04-2009
Member
 
Join Date: May 2008
Posts: 859
Re: Permission denied in Python when copying files

The problem is that I see no reason why I would have no rights. I am in my local post office, admin, I'm not in a domain, I am owner of the file. For the copytree it seems to me the need for the remote folder does not exist. However, there is, I just updated or I'm wrong?
Reply With Quote
  #4  
Old 24-04-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: Permission denied in Python when copying files

Quote:
Originally Posted by Elijah View Post
For the copytree it seems to me the need for the remote folder does not exist. However, there is, I just updated or I'm wrong?
Oh no, actually you're right.

But if you want "just" sync two folders, you can not use rsync in external process? (or if the files are not too big, you delete the destination and you copytree)
Reply With Quote
  #5  
Old 24-04-2009
Member
 
Join Date: May 2008
Posts: 859
Re: Permission denied in Python when copying files

These are large files containing several thousand files. I took only 3 files to simplify the example. Basically what I need is get the update file in to replace the files in MyFolder. But I did not update the full records in myaccount only record to be updated.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Permission denied in Python when copying files"
Thread Thread Starter Forum Replies Last Post
Ubuntu, Unable to move files, error: Permission Denied PhanA Operating Systems 5 10-09-2011 07:55 AM
Permission denied when opening gamespot thortheviking Software Development 9 21-05-2010 12:13 AM
Denied permission to access folders Jack K Vista Help 16 27-02-2010 07:18 PM
Access is Denied When Copying NTLDR neuro Hardware Peripherals 2 19-08-2009 08:23 PM
Vista and Permission Denied Hamsa! Vista Help 1 23-02-2008 10:52 PM


All times are GMT +5.5. The time now is 09:40 PM.