how to show current what is happening

This is the place for queries that don't fit in any of the other categories.

how to show current what is happening

Postby eakDev » Sat Sep 07, 2013 1:58 pm

how do you show what is being copied/deleted during an operation?
for example below is a code that simply deletes empty folder. What i want is for it to show/print what is currently being deleted.
I want a similar scenraio like when you install something on terminal and it lists it's current activities.

Code: Select all
#deleting empty folders
def delemptydir():
        for root, dirs, files in os.walk(src, topdown=False):
                for file in dirs:
                        path = os.path.join(root, file)
                        if not os.listdir(path):
                                os.removedirs(path)


This is very helpfull when deleting or copying big files because you know that it is doing something.
eakDev
 
Posts: 3
Joined: Sat Mar 09, 2013 12:45 pm

Re: how to show current what is happening

Postby metulburr » Sat Sep 07, 2013 2:04 pm

before deleting, you would just print the path
New Users, Read This
version Python 3.3.2 and 2.7.5, tkinter 8.5, pyqt 4.8.4, pygame 1.9.2 pre
OS Ubuntu 13.04, Mint 11, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
User avatar
metulburr
 
Posts: 1096
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: how to show current what is happening

Postby eakDev » Sat Sep 07, 2013 2:26 pm

hello,

Would it still work even after using py2exe to convert my .py to .exe file? I mean would it still show it on terminal?
eakDev
 
Posts: 3
Joined: Sat Mar 09, 2013 12:45 pm

Re: how to show current what is happening

Postby metulburr » Sat Sep 07, 2013 2:55 pm

if in windows, i might put a single input() at the end of the script to make sure the person can read the output before closing. But whatever happens when invoking the interpreter will still happen when you invoke the .exe.
New Users, Read This
version Python 3.3.2 and 2.7.5, tkinter 8.5, pyqt 4.8.4, pygame 1.9.2 pre
OS Ubuntu 13.04, Mint 11, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
User avatar
metulburr
 
Posts: 1096
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 1 guest