Re: Help Needed. Removing a Folder Problem(Problem Solved)

2006-07-20 Thread Kilicaslan Fatih


--- 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
> '' 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' 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 run(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 = ' 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 run
> > 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  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 

Dear All,

I changed the mode of the files before copying them.
So the problem is solved as follows:

SOLUTION:

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

Thank you very much for your help,
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


Re: Help Needed. Removing a Folder Problem(Problem Solved)

2006-07-20 Thread Kilicaslan Fatih


--- 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
> '' 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' 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 run(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 = ' 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 run
> > 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  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 

Dear All,

I changed the mode of the files before copying them.
So the problem is solved as follows:

SOLUTION:

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

Thank you very much for your help,
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


Re: Help Needed. Removing a Folder Problem(Problem Solved)

2006-07-20 Thread Kilicaslan Fatih


--- 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
> '' 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' 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 run(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 = ' 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 run
> > 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  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 

Dear All,

I changed the mode of the files before copying them.
So the problem is solved as follows:

SOLUTION:

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

Thank you very much for your help,
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


Re: Help Needed. Removing a Folder Problem

2006-07-20 Thread Kilicaslan Fatih


--- 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
> '' 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' 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 run(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 = ' 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 run
> > 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  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 
3. changed the files' permissions in the folder
4. Then try to remove the folder 

def run(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 = ' 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 run
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


Help Needed. Removing a Folder Problem

2006-07-20 Thread Kilicaslan Fatih
When I push a button to trigger the code:

def run(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 = ' 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 run
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  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 
-- 
http://mail.python.org/mailman/listinfo/python-list


Help Needed !!! Browsing and Selecting More Than One File(Problem Solved)

2006-07-10 Thread Kilicaslan Fatih
Special Thanks to Diez B. Roggisch and Eric Brunel.

Last week on Friday I solved the problems I
encountered thanks to your helpful indications. 

I think I covered all the ambiguity in my code. Here's
the code:

# executing  with Python

from Tkinter import *
from tkFileDialog import *
import tkMessageBox
import os

# Creating App Class
class App:

b_file = ""

# Function to browse files, the files selected
will be the items of 
a tuple
# This tuple is assigned to the instance of App
class
# browseFile Function is triggered by a label in
Menu
def browseFile(self):
App.b_file
App.b_file = askopenfilename(filetypes = [("C
Source Code", 
"*.c"), ("C Header Files", "*.h"), ("All Files",
"*.*")], multiple=1)
   
# Function to Run  Code Analyzer
def run(self, event):

# Controls if a file is browsed and selected
# If a selection is done the code continues
from here
if App.b_file != "":
cmd_tup = ""
for i in range(len(App.b_file)):
cmd_tup += App.b_file[i]+' '# The
type of the a 
tuple's items are all strings, here parameter for 
are arranged
cmd = ' ' + cmd_tup
#according to the 
#command prompt syntax, command is created
return os.system(cmd)   
# command is executed
else:
tkMessageBox.showinfo("Window Text",
"Please Firstly Browse 
and Select A File")
# if no file is selected a warning pop-ups


 
def __init__(self, master):

frame = Frame(master)
frame.pack(fill="both")   

self.menubar = Menu(master)
self.menubar.add_command(label="Browse File", 
command=self.browseFile)
master.config(menu=self.menubar)

self.Run = Button(frame, text="Run ",
fg="red")
self.Run.bind("", self.run)
self.Run.pack(side=LEFT, padx=10, pady=20)

self.close = Button(frame, text="QUIT",
fg="red", command=frame.quit)
self.close.pack(side=LEFT, padx=10, pady=20)

 
root = Tk()
app=App(root)
root.mainloop()


__
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


Help Needed !!! Browsing and Selecting More Than One File

2006-07-07 Thread Kilicaslan Fatih

Thank you very much for your indications. I've just
subscribed for the group and even I don't know how to
reply directly through mailing list. I will try to
answer some of the questions you have asked about my
program.

Question:
What has it to do with running your program with
several file names as arguments? Is it two different
ways to select several files in your application? Or
do you want one or the other?

Answer:
I want to browse, and want to select all of the "*.c"
files in a folder and than run  code analyzer
program for all of these files. The syntax to run 
on multiple files on DOS is:

 file1.c file2.c file3.c

I want to have 2 options on my GUI, one for only to
select one file, the other is to select multiple files
in a project(folder). 

I didn't yet change the code according to your
indications, there are still basic mistakes but I will
send the whole code, to be more clear. When I run this
code: 
I can browse a file and 
than open a file through the browser, 
assign it to "" as parameter
and able to analyse one C file through a GUI

I can't select more than one file. I want to do this
because I will need to analyze the total project which
is composed of 8-15 "*.c" files.  

Source Code:

from Tkinter import *
from tkFileDialog import *
import tkMessageBox
import os


class App:

#Function for browsing a file
def browseFile(self):
global file
file = askopenfilename(filetypes = [("C source
code", "*.c"), ("All Files", "*.*")])
   
#Function for running  
def run(self, event):
if type(file)==str:
dosya = file
cmd = ' ' + dosya
print cmd
return os.system(cmd)
else:
message = tkMessageBox.showinfo("Window
Text", "Please Browse a File Firstly")
  
def __init__(self, master):

frame = Frame(master)
frame.pack(fill="both")   

self.menubar = Menu(master)
self.menubar.add_command(label="Browse File",
command=self.browseFile)
master.config(menu=self.menubar)

self.Run = Button(frame, text="Run ",
fg="red")
self.Run.bind("", self.run)
self.Run.pack(side=LEFT, padx=10, pady=20)

self.close = Button(frame, text="QUIT",
fg="red", command=frame.quit)
self.close.pack(side=LEFT, padx=10, pady=20)

 
root = Tk()
app=App(root)
root.mainloop()

Best Regards,
Fatih K.




__
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


Help Needed !!! Browsing and Selecting More Than One File

2006-07-06 Thread Kilicaslan Fatih
Dear Diez B. Roggisch,

After clicking a button on the GUI the user can browse
and than select a ".c" file to assign to the other
program I have mentioned.

But in this way I can only select one file. I don't
know how to implement this application for all of the
"*.c" files in a folder. Do I need to write a for loop
for this? Or maybe I can create a list after
sequentially browsing files and than assign this list
as a parameter to the function I am executing. 

Here is a part of the code, I am new to Python and
OOP. Sorry for the ambiguity in my question.

class App:

#Browsing the file, this is triggered
#through a menu
def browseFile(self):
global file
file = askopenfilename(filetypes = [("C source
code", "*.c"), ("All Files", "*.*")])

#Running the CC program
#This is triggered by a button push   

def runCC(self, event):

if type(file)==str:
dosya = file
cmd = 'cc ' + dosya
return os.system(cmd)
else:
message = tkMessageBox.showinfo("Window
Text", "Please Browse a File Firstly")
print message

Regards,
Fatih K.

__
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


Help Needed !!! Browsing and Selecting More Than One File

2006-07-06 Thread Kilicaslan Fatih
Dear All,

I am trying to create a GUI, using Tkinter on Windows
2000/XP using Python 2.2. Through buttons this GUI
interacts with another program and assigns argument to
that program.

I managed to browse a ".c" file and assign this file
as an argument to the other program written in C/C++
Programming Language. On DOS, to run this program the
following can be written:

1) program file1.c
2) program file1.c file2.c file3.c .

So briefly I managed to execute this program for one
file(program file1.c), but I failed to run for more
than one file(program file1.c file2.c file3.c ..).

After browsing for files, is there a way to select
more than one file and assign those as arguments to
the program that I want to execute?

If my explanations are not clear enough I can send you
the code I have written, or try to explain further.

Best Regards,
Fatih K.


__
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