473,785 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

command line reports

Is there a module somewhere that intelligently deals with reports to the
command line? I would like to report the progress of some pretty lengthy
simulations, and currently I have the new reports written on a new line
rather rather than overwriting the previous report.

Thanks,
Darren
Aug 11 '05 #1
6 1402
Darren Dale wrote:
Is there a module somewhere that intelligently deals with reports to the
command line? I would like to report the progress of some pretty lengthy
simulations, and currently I have the new reports written on a new line
rather rather than overwriting the previous report.


I'm afraid I don't understand this. Could you please give an example?

Of course, this is c.l.p., so I'm sure *someone* will understand it.
--
Michael Hoffman
Aug 11 '05 #2
Darren Dale wrote:
Is there a module somewhere that intelligently deals with reports to the
command line? I would like to report the progress of some pretty lengthy
simulations, and currently I have the new reports written on a new line
rather rather than overwriting the previous report.


You mean you want sys.stdout.writ e(report + '\r') instead of "print
report" ?

It's not really clear what you want. What's a "report" to you?

-Peter
Aug 11 '05 #3
Peter Hansen wrote:
Darren Dale wrote:
Is there a module somewhere that intelligently deals with reports to the
command line? I would like to report the progress of some pretty lengthy
simulations, and currently I have the new reports written on a new line
rather rather than overwriting the previous report.


You mean you want sys.stdout.writ e(report + '\r') instead of "print
report" ?

It's not really clear what you want. What's a "report" to you?

-Peter


I am printing something like

trial 1 of 100
trial 2 of 100
....

so I get 100 lines by the time the code is finished. I would like to replace
the previous report with the current one, so I only use one line by the
time the code is finished.

I was also hoping that there was a set of tools out there for spinners,
meters, etc...
Aug 11 '05 #4
On Thu, 11 Aug 2005 15:43:23 -0400, Darren Dale <dd**@cornell.e du> wrote:
Peter Hansen wrote:
Darren Dale wrote:
Is there a module somewhere that intelligently deals with reports to the
command line? I would like to report the progress of some pretty lengthy
simulations, and currently I have the new reports written on a new line
rather rather than overwriting the previous report.
You mean you want sys.stdout.writ e(report + '\r') instead of "print
report" ?

It's not really clear what you want. What's a "report" to you?

-Peter


I am printing something like

trial 1 of 100
trial 2 of 100
...

Peter's suggestion will work, but it's easy to get something like
import sys, time
def test(): ... for i in xrange(5):
... sys.stdout.writ e(('trial %s of 5'%(i+1)) + '\r')
... time.sleep(.25)
... print "We're done!"
... test()

We're done!5
^--(note leftover from last "report: line)
By the same token (more or less ;-) if your "report" line shortens
during progress (e.g., changing from

'long_name_test trial 100 of 100'

to

'short_name trial 1 of 10'

you will likely see

'short_name trial n of 10 of 100'

for a while, unless you pad the report line with blanks to a constant length.

Also, I guess some platforms could require flushing stdout to be sure of
seeing the latest line as you go.

so I get 100 lines by the time the code is finished. I would like to replace
the previous report with the current one, so I only use one line by the
time the code is finished.

I was also hoping that there was a set of tools out there for spinners,
meters, etc...

The question with python for this kind of thing is usually, "Which will be
faster, googling for it, or writing it?" ;-)

Regards,
Bengt Richter
Aug 11 '05 #5
Bengt Richter wrote:
On Thu, 11 Aug 2005 15:43:23 -0400, Darren Dale <dd**@cornell.e du> wrote:
Peter Hansen wrote:
Darren Dale wrote:
Is there a module somewhere that intelligently deals with reports to
the command line? I would like to report the progress of some pretty
lengthy simulations, and currently I have the new reports written on a
new line rather rather than overwriting the previous report.

You mean you want sys.stdout.writ e(report + '\r') instead of "print
report" ?

It's not really clear what you want. What's a "report" to you?

-Peter


I am printing something like

trial 1 of 100
trial 2 of 100
...

Peter's suggestion will work, but it's easy to get something like
>>> import sys, time
>>> def test(): ... for i in xrange(5):
... sys.stdout.writ e(('trial %s of 5'%(i+1)) + '\r')
... time.sleep(.25)
... print "We're done!"
... >>> test()

We're done!


Thanks, I didnt realize that \r is different from \n.
Aug 11 '05 #6
Darren Dale wrote:
Thanks, I didnt realize that \r is different from \n.


\r has is a byte with value 13, which is the Carriage Return (CR)
control character in ASCII. \n has value 10 and is the Line Feed (LF)
character. CR is named after the old teletypewriter operation involving
moving the "carriage" back to one edge to restart typing text. It
wasn't very useful without also moving to a new line (unless you wanted
to cut your paper by repeatedly printing a line of hyphens), which is
what LF was used for -- like rotating the platen (I think that's the
word) on a typewriter up one line. Hitting the arm on a typewriter is
like a CR plus a LF together, and this is immortalized in the CR/LF
combination required still under Microsoft's most advanced operating
systems, long after it's no longer necessary to have the two distinct
characters. (<sigh>)

Most operating systems have adopted the combined behaviour (go to start
of line, move down one line) together under the LF character, since
ASCII doesn't have a single "new line" character (though VT or Vertical
Tab has been proposed for that since it has no other practical use these
days). The CR character still generally does the "go to start of line"
operation when used in the console, so it's pretty handy to "overwrite
the previous line" as you wanted to. In rare situations, such as
terminal software like Hyperterm, LF doesn't necessarily take you back
to the start of a line but merely moves you down a single line at the
same column position, much like its original/intended behaviour.

-waxing-historically-and-97-percent-accurately y'rs,
Peter
Aug 12 '05 #7

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

Similar topics

0
955
by: David Merrill | last post by:
How do I embed an rpt file into my exe using command line tools? VS.Net does this behind the scenes, however, I cannot install VS.Net 2003 on our build machine because it must be NT4. So how do I properly compile a project that has embedded crystal reports using only command line tools? Don't tell me to ask Crystal, already tried that, they sent me here.
0
1409
by: Mukesh Kumar | last post by:
hi all, I have created some independent reports through crystal reports developer edition v 10 and developed a small tool in .net framework v 1.1 to view these reports through the crystal reports viewer provided by .net. This is a stand-alone windows application and nothing to do with the server. I am using local SQL anywhere database and connection is via an ODBC DSN. Before launching the reports I am passing the login information to...
21
6017
by: Colleyville Alan | last post by:
I am now using the Execute command to run SQL for action queries. When I had them as saved queries, I would use DoCmd.SetWarnings False to allow the queries to overwrite existing tables. when I use this code: CurrentDb().Execute strMySql', dbFailOnError I still get warnings that the table already exists. Is there another command that I am supposed to use?
1
16019
by: Dennis Gaida | last post by:
Hi there, I want to upload some exported reports to a FTP Server, for this I use a command line FTP utility. My Database sits in C:\Documents and Settings\Dennis\My Documents\Database The FTP utility sits in C:\Documents and Settings\Dennis\My Documents\Database\oexport The files to be uploaded in C:\Documents and Settings\Dennis\My Documents\Database\oexport\files
1
2685
by: xtra | last post by:
Hi Folk I have written a module that allows you to type a bunch of commands in the immediate window, for quick access to information when you are creating VB code. Here it is, it may be helpful to you (I find it pretty fast and friendly).... Some of it is specific to my database (I left out many as well which were too specific), so you will have to rewrite it for yours, but you may find it useful.... Any questions, please ask. Typing...
4
3524
by: kwatch | last post by:
Hi, I have a question about os.times(). os.times() returns a tuple containing user time and system time, but it is not matched to the result of 'time' command. For example, os.times() reports that user time is 39.85 sec, but 'time' command reports that user time is 28.55sec. (machine: Python2.5, MacOS X 10.4 Tiger, MacBook 1.83GHz intel core duo)
3
18718
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however, working with complex reports is tricky Assumption: Reader of this article have basic knowledge of creating data reports. Creating a Parent-Child Command and create a DataReport Suppose we have a database called company with two tables ...
2
1910
code green
by: code green | last post by:
What is the best command line equivalent of $_SERVER. I have recently written a number of scripts to run from an intranet that generate reports written to CSV and XLS files that can be downloaded. I have extended these scripts to zip and email the reports to personnel. I am now trying to automate the scripts by calling them from Windows Scheduled Task using such CLI C:\apache\xampp\php\php.exe ...
16
2734
by: Steve | last post by:
I am working on a database that has a main menu, many sub-menus and some sub-sub-menus. They are all forms that have numerous command buttons on them to open forms and reports in the database. The database has hundreds of forms and reports. I was asked to go through all the menu forms and determine if all the buttons worked, if there were any problems when either the form or report opened and to come up with a list of the forms and reports...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9481
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10336
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9953
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8978
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7502
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.