rsalmei / alive-progress

A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
MIT License
5.53k stars 206 forks source link

Looping of Progress Bar [Always @ 41%?] #30

Closed InfernalPlank closed 4 years ago

InfernalPlank commented 4 years ago

See my Code Here:

            items = range(low, hi)

            barVal = 0
            with alive_bar(len(items), manual=True, enrich_print=False, force_tty=False, spinner="classic", bar="classic", title="SCAN COMPLETE!") as bar:
                for i in range(low, hi):
                    isOpen = makeDo(host, i, delay)
                    if isOpen:
                        # bar(text="\n" + getFmtTime() + "[*] %s is Open!\n" % str(i))
                        print("\n" + getFmtTime() + "[*] %s is Open!\n" % str(i))
                        opened.append(i)
                        barVal += .01
                        bar(barVal)
                    else:
                        barVal += .01
                        bar(barVal, text="%s %s is not open!" % (getFmtTime(), str(i)))
                        pass

See my Problem Here: image

I genuinely have no idea why this is happening or what is causing it; any assistance would be highly appreciated.

Cheers.

InfernalPlank commented 4 years ago

@rsalmei

rsalmei commented 4 years ago

Hello @RHQ-Rusty, I will help you.

But I fail to see any problem in your image, what do you think is it happening? You say in the title of the issue that alive-bar is "always at 41%", but in the image I can clearly see the percentage is increasing, from 48% to 59%.

You shouldn't put a \n in the bar(text=...), as the bar will get replicated in the screen. Maybe I should even filter text, to not allow any CR in there...

InfernalPlank commented 4 years ago

@rsalmei So I need to remove that? The problem I am having is that the progress bar is duplicating and running down the screen; to fix that all I need to do is remove the '\n'? If so, I fail to see how this would fix it, as the first "positive" scan (the one returning '\n' into the bar) is at 80; the error begins occuring @ 40 ish.

rsalmei commented 4 years ago

Yeah, you should remove it anyway. The text param is specific to display what you're doing in that iteration, something transient, like "Searching abc". When you find what you need, just print any way you want, including \n.

Well, if it starts at 40%, it probably is hitting the end of screen, when the shell itself makes the cursor go down. Please try to increase the screen width, or sending to alive_bar: length=30.

InfernalPlank commented 4 years ago

@rsalmei changing length= worked; I didn't even have one set initially, but 30 works wonderfully! Is there another workaround for this that dynamically scales to terminal size?

rsalmei commented 4 years ago

Great, I'm glad it worked! Not yet, there's even an issue open for that (#19), but I didn't have time to take that yet. I was very busy with another open-source project of mine: https://github.com/rsalmei/clearly, and I work on them all alone...

InfernalPlank commented 4 years ago

All good man, take your time! Your contributions to the open-source community are duly noted and highly regarded; thanks for taking some time to reply! I believe Issue #19 is indeed what I am experiencing. The comments OP on that issue provided may work as a temporary fix. Thank you!

rsalmei commented 4 years ago

Thanks man! You're welcome 👍

rsalmei commented 4 years ago

Hey @RHQ-Rusty, I've just protected against that \n in text! 😜