Danek Duvall wrote:
> On Thu, Dec 18, 2008 at 11:36:51AM -0600, Shawn Walker wrote:
> 
>> Danek Duvall wrote:
>>> On Thu, Dec 18, 2008 at 11:17:31AM -0600, Shawn Walker wrote:
>>>
>>>> Whenever the program exits, it was printing a set of 80 space characters
>>>> to overwrite whatever characters had last been displayed but with a
>>>> trailing ',' to omit the newline.
>>>>
>>>> However, a newline was added anyway on program exit.
>>> Where was that newline being added?
>> By python, during exit.
> 
> Okay, but that's only the newline that wasn't printed because the output
> from verify didn't have a newline.  There's presumably a second newline
> that was being printed, leading to the blank line between the last line of
> verify output and the next shell prompt, and that's the one you're getting
> rid of.

No, there's not a second newline being printed.  See below.

>> ====
>> The reason for the newline is that, when standard output (sys.output) is
>> closed, it checks if its softspace attribute is True (meaning there is a
>> pending line not yet terminated) and if so terminates the line. In
>> turn, softspace is set by print with a trailing comma, specifically to
>> avoid erroneously-unterminated lines (and other small anomalies). So,
>> if you want something a bit out of the ordinary such as an unterminated
>> line being output, either you eschew print, which is meant to help in
>> typical ordinary cases (sys.stdout.write being there for when you need
>> fine control), or you reset that special attribute to False.
>> ====
> 
> That still doesn't tell me why adding a carriage return prevents python
> from adding the extra newline.  It says nothing about carriage returns.

The progress tracker output is the *very last line of output*.

This should clarify things.  Code snippet I'm changing from progress.py: 
ver_done():

         print "%80s" % "",
         sys.stdout.flush()

with that, this output:
swal...@zorander:~/devel/pkg-1931/src$ ./client.py verify SUNWsolnm
 

swal...@zorander:~/devel/pkg-1931/src$

without the print statement above:
./client.py verify SUNWsolnm
swal...@zorander:~/devel/pkg-1931/src$            ..... --

note the progress tracker characters leftover in the output above; with 
the print statement and the self.cr I added:
swal...@zorander:~/devel/pkg-1931/src$ ./client.py verify SUNWsolnm
swal...@zorander:~/devel/pkg-1931/src$ 


So, as you can see, the very last line of output from the program is the 
progress tracker (normally) when running verify.  By printing the cr, I 
am effectively telling python that there's nothing to terminate, so it 
doesn't add the newline.

Cheers,
-- 
Shawn Walker
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to