--- Larry Bates <[EMAIL PROTECTED]> wrote:

> Note the error is permission denied.  I would guess
> that
> either the file has read-only flag set or perhaps
> the
> 'cccc' program is still running and has the file
> open
> in a separate thread so you can't delete the
> directory
> until it has completed.  You should take a look at
> the
> subprocess module and use something like (not
> tested):
> 
> retcode = call([r'cccc C:\copiedfiles\*.*',
> cmd_out])
> 
> This will wait for execution of cccc to complete
> prior
> to returning.
> 
> -Larry Bates
> 
> 
> Kilicaslan Fatih wrote:
> > When I push a button to trigger the code:
> > 
> > def runCCCC(self, event):
> >         cmd_out = self.A_com()
> >         if App.runF != "":
> >             os.mkdir('C:\copiedFiles')            
>    
> >       
> >             for item in App.runF:
> >                 App.beCopied = str(item)
> >                 shutil.copy(App.beCopied,         
> 
> > 'C:\copiedFiles')
> >             cmd = 'cccc C:\copiedFiles\*.*' +
> cmd_out
> >             os.system(cmd)
> >             shutil.rmtree('C:\copiedFiles')
> >         else:
> >             tkMessageBox.showinfo("Window Text",
> > "Please Firstly Browse and Insert A File")        
> > 
> > 
> > I encountered this error:
> > 
> > Traceback (most recent call last):
> >   File "C:\Python24\lib\lib-tk\Tkinter.py", line
> 1345,
> > in __call__
> >     return self.func(*args)
> >   File "C:\Python24\TkScripts\RCFolder.py", line
> 61,
> > in runCCCC
> >     shutil.rmtree('C:\copiedFiles',
> > ignore_errors=False)# OLMADI!!!
> >   File "C:\Python24\lib\shutil.py", line 168, in
> > rmtree
> >     onerror(os.remove, fullname, sys.exc_info())
> >   File "C:\Python24\lib\shutil.py", line 166, in
> > rmtree
> >     os.remove(fullname)
> > OSError: [Errno 13] Permission denied:
> > 'C:\\copiedFiles\\Analog.c'
> > 
> > 1. What I want to do is to get the list of files I
> > inserted to a Listbox,
> > 2. Creating a folder,(C:\copiedFiles)
> > 3. Copying all of these files to this folder with
> the
> > same names,
> > 4. Running CCCC for all of the files in this
> folder,
> > 5. Than removing this folder.
> > 
> > Can anyone enlighten me on this Error I have got
> and
> > how to solve it?
> > 
> > Regards
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> > http://mail.yahoo.com 

Thank you very much for your reply, during my wait for
an answer I changed the code. 

1. First created the folder
2. Then copied all the files in the listbox to the
folder
3. Run CCCC
3. changed the files' permissions in the folder
4. Then try to remove the folder 

def runCCCC(self, event):
        cmd_out = self.A_com()
        if App.runF != "":
            print len(App.runF)
            os.mkdir('C:\copiedFiles')                
      
            for item in App.runF:
              
                shutil.copy(item, 'C:\copiedFiles')   
          
            cmd = 'cccc C:\copiedFiles\*.*' + cmd_out
            os.system(cmd)
            for root,dir,files in
os.walk("C:\copiedFiles"):
                print len(files)
                for j in files:
                    fille = os.path.join(root,j)      
       
                    os.chmod(fille, 0700)
            shutil.rmtree('C:\copiedFiles')
        else:
            tkMessageBox.showinfo("Window Text",
"Please Firstly Browse and Insert A File")       
                              




I got another error this time:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345,
in __call__
    return self.func(*args)
  File "C:\Python24\TkScripts\RCFolder.py", line 56,
in runCCCC
    shutil.copy(item, 'C:\copiedFiles')
  File "C:\Python24\lib\shutil.py", line 81, in copy
    copyfile(src, dst)
  File "C:\Python24\lib\shutil.py", line 48, in
copyfile
    fdst = open(dst, 'wb')
IOError: [Errno 13] Permission denied:
'C:\\copiedFiles\\Generic_IO.h'

I have more than 200 files in the folder. I will have
nearly 1000 files in each execution. I don't know why
I encountered this error. I am still searching the
reason, and I will check the subprocess module in
anyway.

Regards


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to