1

Im using 'enlighten' status bars for multithreads solution. And my problem is, that after printed lines comes to terminal offset, they are gone and can not be seeing any more. And I don't want it. It is possible to switch off this "clean-offsett" behaviour in 'enlighten'?

Below you can see a smal example of the code, where you can see this behaviour. It would be great, if somebody can help me with that=))))

Sunny day

import threading
import sys
import enlighten
import time
import Queue

class StatusBar(object):

    def __init__(self):

    # Example configuration object
        self.config_status_bar = {'stream': sys.stdout,
                  'useCounter': True, 
                  "set_scroll": True,
                  "resize_lock": False,
                  "scroll_offset":1000,
                  "height":40}

        #global self.manager
        self.enableCounter = self.config_status_bar['useCounter'] and self.config_status_bar['stream'].isatty()
        self.manager = enlighten.Manager(stream=self.config_status_bar['stream'], enabled=self.enableCounter,
                    set_scroll=self.config_status_bar['set_scroll'],
                    resize_lock=self.config_status_bar['resize_lock'],
                    scroll_offset=self.config_status_bar['scroll_offset'],
                    height=self.config_status_bar['height'])
        self.threads_success_counter = 0
        self.threads_unsuccess_counter = 0
        self.threads_status_bucket = Queue.Queue()
        self.counter1 = self.manager.counter(total=100, desc="Thread1", unit="files")
        self.counter2 = self.manager.counter(total=100, desc="Thread2", unit="files")


    def update(self, counter, time_to_sleep, name):
        #counter = self.manager.counter(total=30, desc=name, unit="files")
        for i in xrange(100):
            time.sleep(time_to_sleep)
            print i 
            counter.update(incr=1)
            # if i==20:
            #   self.manager.remove(counter)
            #   self.manager.term.clear_cache()
            #   self.manager.term.reset()
            #   self.manager.term.reset()
                #self.self.manager.remove
        counter.close()
        self.threads_status_bucket.put({"name":name, "status":"quit"})
        print name, "- finished."



    def threads(self):
        name1 = "Thread1"
        processThread1 = threading.Thread(target=self.update, args=(self.counter1, 0.1, name1), name="mainThr1")
        processThread1.setDaemon(True)
        processThread1.start()
        print "Threads1 was started"
        #processThread1.join()

        name2 = "Thread2"
        processThread2 = threading.Thread(target=self.update, args=(self.counter2,0.3, name2), name="mainThr2")
        processThread2.setDaemon(True)
        processThread2.start()
        print "Threads2 was started"
        self.threads_status_bucket

if __name__ == "__main__":
    print "ghjkl"
    s = StatusBar()
    s.threads()

    #print self.threads_status_bucket

    while (s.threads_success_counter+s.threads_unsuccess_counter) != 2:
        if not s.threads_status_bucket.empty():
            e = s.threads_status_bucket.get()
            #s.logger.error("InsertionError(in_thread_error_bucket): '{}'-Thread throw following Exception: '{}'. ".format(e[0], e[1]))
            status = True
            s.threads_success_counter += 1
        time.sleep(1)
Egor Savin
  • 39
  • 7
  • Are you saying you can't scroll back in the terminal? I ran your code in Gnome terminal on Fedora. The numbers feed off the top and I can scroll back to see them. If that's the issue, it might have to do with your terminal or terminal settings. – aviso Aug 10 '18 at 04:05
  • i can, but what i mean, that if printed STDOUT (from one execution) goes out into the off-set area ( in the terminal) than they are gone and will be deleted. But it still to be possible to scroll to other old executed statements. Which was done befor. Did you get, what i mean?=) – Egor Savin Aug 19 '18 at 15:26
  • So you are saying the terminal scrollback is deleted for anything printed to STDOUT after the progress bar begins? Enlighten does not delete anything. Have you been able to reproduce this behavior on other terminals? You might want to provide a gif or video showing this as well as what platform and terminal you are using. – aviso Aug 20 '18 at 03:25

0 Answers0