question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extra newlines on prints for non interactive terminals (Jenkins)

See original GitHub issue

We want to add alive-progress to scripts that we run as part of our pipelines. So far it seems to work well but any print we do while in the alive-progress context is getting an empty newline first. This is probably required for the interactive terminals but is distracting in the CI logs.

I wrote this snippet based on your examples:

import time
from alive_progress import alive_bar

print('Pure progress:')
with alive_bar(1000) as bar:
    for i in range(1000):
        time.sleep(0.01)
        bar()

print('With extra output:')
with alive_bar(1000) as bar:
    for i in range(1000):
        if i% 300 == 0:
            print('found')
        time.sleep(0.01)
        bar()

This is the output on our CI system (Jenkins with timestamps enabled):

01:07:58  + python alive.py
01:07:58  Pure progress:
01:08:08  |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1000/1000 [100%] in 10.1s (99.39/s)
01:08:08  With extra output:
01:08:08  
on 0: found
01:08:12  
on 300: found
01:08:15  
on 600: found
01:08:17  
on 900: found
01:08:18  |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1000/1000 [100%] in 10.1s (99.38/s)

Ideally it should be:

01:07:58  + python alive.py
01:07:58  Pure progress:
01:08:08  |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1000/1000 [100%] in 10.1s (99.39/s)
01:08:08  With extra output:
01:08:08  on 0: found
01:08:12  on 300: found
01:08:15  on 600: found
01:08:17  on 900: found
01:08:18  |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1000/1000 [100%] in 10.1s (99.38/s)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rsalmeicommented, May 28, 2021

Great! Thank you for the report. So 2.0 will already ship with this! Don’t forget to check often this repo, to switch to the oficial 2.0 version as soon as it is released! I’m just writing the new README now πŸ‘

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add new lines when using echo - Unix Stack Exchange
When executing echo -e "package main\nversion = \"0.0.16\"" > version.go in a Makefile on Alpine 3.12 and make 4.3, it will write -e...
Read more >
jenkins pipeline sh adding new line - groovy - Stack Overflow
This lets you insert newlines to format a long command. Wrap variables with double quotes (valid within triple double quotes,Β ...
Read more >
docker outputs to standard out with added carriage return ...
I am not seeing the extra carriage returns described. Is there a simple repro other than docker run --rm busybox echo "Hello World"...
Read more >
Running Multi-Line Shell Code at Once From Single Prompt
There are many ways to run multi-line shell commands in Linux at once. Let's explore and compare them.
Read more >
Jenkins User Handbook
configure Docker so it can be managed as a non-root user. Read more about this ... Open up a terminal/command prompt window to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found