473,467 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

screen output problem

Hi,

I have, for very long, been trying to find a consistent solution (which
could work across major python platforms - Linux, Windows, Mac OS X)
for the following problem.

I have a function which downloads files from the web. I've made the
function threaded. I'm trying to implement a progress bar for it which
could work across all the platforms.

The problem is that when the progress bar is displayed, all the threads
overwrite the progress bar.

I've thought of using curses but AFAIK curses is not available for
Windows.

Is there a generic way to accomplish the following:

progress = "[===================]\n[=======================]"
for x in range(5):
sys.stdout.write(progress + "\r")

Basically, I want a way through which I want to display data on two
lines and make sure that "\r" overwrites the two lines without putting
a newline making sure that whatever library it uses is available across
all major Python platforms.

Thanks,
Ritesh

Nov 25 '06 #1
3 1730
On 25 Nov 2006 15:27:26 -0800, Ritesh Raj Sarraf <rr*@researchut.comwrote:
Hi,

I have, for very long, been trying to find a consistent solution (which
could work across major python platforms - Linux, Windows, Mac OS X)
for the following problem.

I have a function which downloads files from the web. I've made the
function threaded. I'm trying to implement a progress bar for it which
could work across all the platforms.

The problem is that when the progress bar is displayed, all the threads
overwrite the progress bar.

I've thought of using curses but AFAIK curses is not available for
Windows.

Is there a generic way to accomplish the following:

progress = "[===================]\n[=======================]"
for x in range(5):
sys.stdout.write(progress + "\r")

Basically, I want a way through which I want to display data on two
lines and make sure that "\r" overwrites the two lines without putting
a newline making sure that whatever library it uses is available across
all major Python platforms.

Thanks,
Ritesh

--
http://mail.python.org/mailman/listinfo/python-list
Take a look at this:
http://cheeseshop.python.org/pypi/progressbar

--
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://ironfroggy-code.blogspot.com/
Nov 26 '06 #2
On Sunday 26 November 2006 13:07, Calvin Spealman wrote:
Take a look at this:
http://cheeseshop.python.org/pypi/progressbar
Hi,

Sorry for being a little late in replying.

The progressbar implementation is excellent but it has the same problems that
the current progressbar implementation I use, has.

In the above mentioned progressbar implementation also, the progressbar status
is overwritten if you're using multiple threads.

If your application is threaded, and multiple threads are downloading multiple
files, you get a progressbar which is overwritten by all the 3 threads.

I had brought this issue some time back too.
Dennis Lee Bieber had a solution which looked better but not very much. His
implementation had os.system(clear/cls) being called (to update the progress)
which made the screen flicker if your network latency was low (especially in
cases where the data is indirectly being downloaded from a Proxy or a product
like NetApp's Netcache).

If there's a way to print multiple lines of text withouth the newline ("\n")
character, we can then use carriage return ("\r") and implement a proper
progressbar with a bar for each separate progress action.

Thanks,
Ritesh
--
Ritesh Raj Sarraf
RESEARCHUT - http://www.researchut.com
"Necessity is the mother of invention."
"Stealing logic from one person is plagiarism, stealing from many is
research."
"The great are those who achieve the impossible, the petty are those who
cannot - rrs"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQBFbAU94Rhi6gTxMLwRAh5NAJ0ZAkMF+ykF5OtDOKta3M ztRKJWeACbB0LZ
cNEjxN1RqUWd4IOF+5QXHqo=
=8FBd
-----END PGP SIGNATURE-----

Nov 28 '06 #3
I'm not sure if there is a definite solution to this problem.

I've noticed that one of the applications, which I use on a daily basis
(apt from Debian) does address the progress bar issue in another way.

When apt tries to download multiple files, it displays the progress of
all the downloads on a single line. Probably the apt developers also
might have run into the same issue and hence settled down with this
workaround.
Thanks,
Ritesh
Dennis Lee Bieber wrote:
On Tue, 28 Nov 2006 15:15:28 +0530, Ritesh Raj Sarraf
<rr*@researchut.comdeclaimed the following in comp.lang.python:

If there's a way to print multiple lines of text withouth the newline ("\n")
character, we can then use carriage return ("\r") and implement a proper
progressbar with a bar for each separate progress action.
If you were running on an Amiga, or via a serial port connection to
an old VT-100 terminal, it would be child's play... Since both
understood the same terminal control codes for moving the cursor around
a text display.

The old MS-DOS "ANSI" console driver may have understood that set.
But M$, in its great and all-powerful wisdom, seems to feel that the
only need for a command line interface is for batch configuration
scripts that run with no human interaction, and hence with no need for
status. One is expected to code a GUI instead if such things as
progress-bars are needed.

A google for "windows console cursor control" brings up (a bit of a
surprise since I my search terms didn't mention Python):

http://newcenturycomputers.net/projects/wconio.html

Of course, this isn't portable to LINUX or other operating systems...

Also, looking at win32api, I find a SetCursorPos() (and matching
get...).

--
Wulfraed Dennis Lee Bieber KD6MOG
wl*****@ix.netcom.com wu******@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: we******@bestiaria.com)
HTTP://www.bestiaria.com/
Nov 29 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Anon Email | last post by:
Hi people, Another question. In the code below, why is there a screen output? This part of the code: bool status = TheCalculator.Execute(input); is merely assigning the result of the...
4
by: midday.hu | last post by:
Hi, Does someone know how to stop "the information output on screen"? Now when I run my code, it outputs a lot of message when calling other libraries, together with the info with the print...
0
by: Ian Ceicys | last post by:
I’ve been tasked with doing documentation on the project I’ve recently joined. Here’s what I’m looking for in terms of documentation. I want to generate a diagram from a huge .net 1.1...
10
by: mwt | last post by:
I'm doing some python programming for a linux terminal (just learning). When I want to completely redraw the screen, I've been using os.system("clear") This command works when using python in...
8
by: GeorgeSmiley | last post by:
Does anyone know of a way, via VBA, to set the screen position of query results to a particular top, left position? I've glanced at API techniques but cannot find exactly what will do the trick....
1
by: VBjshkian | last post by:
While programming in Pascal, you can write the following code to work with the screen shown on your monitor : SCREEN : array of word absolute $B800:0000; This makes you able to work " directly...
4
by: sophie_newbie | last post by:
Hi, in my program i need to call a couple of functions that do some stuff but they always print their output on screen. But I don't want them to print anything on the screen. Is there any way I can...
1
by: Allen | last post by:
How to force System.Windows.Forms.Screen.AllScreens to update when attaching an additional monitor? Form1 is Loaded and runs the following upon detection of additional monitor: Dim Screens()...
0
by: =?Utf-8?B?amFtZXNjaGk=?= | last post by:
I'm trying to do is to launch Powerpoint Viever 2007 in my secondary screen. I'm still having issues resizing the pptviewer.exe output when moving the window to the second monitor. Here's my code...
3
by: mrsouthg | last post by:
Hi, I am fairly new to c# .net language and have been using a set of code I was given to learn from. I have found a suitable part which I would like to change, I am however finding it a big hurdle...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.