I built a progress bar for a python application I developed. It is expected to look something like below:
[██████████████ ] 70%
This works fine when run in local terminal and in docker containers built from my machine. It however, doesn't display as expected when run in gitlab shared runner. Instead of getting a single line that shows progress so far, it displays multiple lines. Something like below
[█████████████ ] 68%
[█████████████ ] 68%
[█████████████ ] 68%
[█████████████ ] 68%
[█████████████ ] 69%
[█████████████ ] 69%
[█████████████ ] 69%
[█████████████ ] 69%
[█████████████ ] 69%
[██████████████ ] 70%
[██████████████ ] 70%
In order to understand the possible reasons, I tried to find out terminal properties of shared runner containers. So I executed below commands, all of which returned errors. So need help fixing the problem.
$ stty size
stty: 'standard input': Inappropriate ioctl for device
$ tput cols
tput: No value for $TERM and no -T specified
My gitlab-ci.yml file looks like below
run-project:
image: python:3.6
script:
- stty size
- python3 Test.py
Below is sample code I am using to show progress bar:
import sys
i = 1
sys.stdout.write('Start')
for k in range(100000):
i += 1
sys.stdout.write('\r')
j = (i/100000)
sys.stdout.write("[%-20s] %d%%" % ('█'*int(20*j), int(100*j)))
What I want is to see a single line that displays progress of task instead of terminal displaying hundreds of line each displaying progress so far (Which is my intent for using carriage return operator)