Hello,

I have a certain way i want to do something but im not sure where to start, or if python can even do it.

what i want is a way to display the current action during a large data conversion program.... I want it to look like an GUI installer but have it be text based. let me demonstate......
(imaginary screen)
__________________________________
| step 1: working
| step 2: not started
| step 3: not started
| step 4: not started
| step 5: not started
|
| currently: doing sub step a of step 1
|
|
|
| queries run: 12345
-----------------------------------

then lets say 45 minutes later....

__________________________________
| step 1: done; no errors, no warnings
| step 2: done; no errors, no warnings
| step 3: done; no errors, no warnings
| step 4: working
| step 5: not started
|
| currently: doing sub step d of step 4
|
|
|
| queries run: 987654
-----------------------------------

but i want that without the screen scrolling.

in progress, thats an easy thing to do, but what about python? if not, i can just have it output to a html file every 5 seconds or so or something and just refresh my browser when i want an update.

sys.stdout.write a good place to start?

What operating system are you using? If MS Windows, you can use os.system('cls') to clear the console window before reprinting the progress display. Yes, yes, I know that clearing the screen isn't good because a) this won't work on Mac or GNU/Linux, b) it may cause users to lose any important data they had in the console before running your script, and c) it introduces security issues into your program *. This is what you're looking for though, right? So I guess we can make an exception for clearing the screen in this case...

* as "cls" is a program on Windows that does this, if someone were to put a program named "cls" into the same folder that this script was run out of, then Windows would execute that program rather than the native "cls". Hence, very large security issues. (Thanks to Siddhant Sanyam for bringing that to light.)

P.S. sys.stdout.write is only an output stream, much like the print expression. Although, sys.stdout.write will not put a newline after each call like print, and if you call print "somethinghere", with that comma after, it won't put a newline but it will put one space.

actually, i think a logging system that creates some kind of nice html output so users can see what is going on and why nothing works would be nice. i think i will go that route. thanks for the advice.

That is a better option. And this way you can achieve a nicer output without having to resort to GUI programming. Good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.