Beispiel #1
0
 def init_progressive(self, leaf_values, bd_defaults, test_d):
     for p in self.process.p_id:
         leaf_value = self.process.service_time[p] - self.process.remain_time[p]
         leaf_values[p] = (Value(leaf_value))
     for p in self.process.p_id:
         bd_defaults[p] = dict(type=Bar, kwargs=dict(max_value=self.process.service_time[p]))
         test_d[p] = BarDescriptor(value=leaf_values[p], **bd_defaults[p])
Beispiel #2
0
 def __init__(self,worker_num=__DEFAULT_NUM__):
     self.workers=[]
     self.leaf_values=[Value(0) for i in range(worker_num)]
             #创建进度条显示对象
     self.taskGraphics=TaskGraphics(self.leaf_values,worker_num)
     for i in range(0,worker_num):
         self.workers.append(Worker(i,self.taskGraphics))
Beispiel #3
0
 def __init__(self,max_epoch):
     self.leaf_values = [Value(0) for i in range(1)]
     self.max_epoch = max_epoch
     self.epoch = 0
     self.test_d = {
             'Training Processing:': BarDescriptor(value=self.leaf_values[0],
                                                   type=Bar, 
                                                   kwargs=dict(max_value=self.max_epoch))
             }
     self.t = Terminal()
     self.n = ProgressTree(term=self.t)
     self.n.make_room(self.test_d)
Beispiel #4
0
 def __init__(self,data,num=__DEFAULT_NUM__):
     self.bind_data=[Value(0) for i in range(num)]
     #self.bind_data=data
     self.terminal=False
     self.bd_defaults=dict(type=Bar,kwargs=dict(max_value=100))
     self.indicator={}
     self.graph_data={}
     for i in range(0,num):
         task_name='task_%d'%i
         self.indicator[i]=task_name
         self.graph_data[task_name]=BarDescriptor(value=self.bind_data[i],**self.bd_defaults)
     self.__init_tree__()
     threading.Thread(target=self.invalidate,args=()).start()
Beispiel #5
0
def build_progress(f2l_mat, n_img_feat, img_times):
    # Setup Progress Bar Garbage
    leaf_values = [Value(0)
                   for i in range(f2l_mat.shape[0] * n_img_feat.shape[0])]
    max_val = img_times.size
    leaf_dict = {}
    bd_defaults = dict(type=Bar, kwargs=dict(max_value=max_val))

    ii = 0
    for f2l in f2l_mat:
        out_dict = {}
        for n_img in n_img_feat:
            out_dict[repr(n_img)] = BarDescriptor(
                value=leaf_values[ii], **bd_defaults)
            ii += 1
        leaf_dict[repr(f2l)] = out_dict

    test_d = {'Graduate': leaf_dict}
    return leaf_values, test_d
Beispiel #6
0
def tree():
    """Example showing tree progress view"""

    #############
    # Test data #
    #############

    # For this example, we're obviously going to be feeding fictitious data
    #   to ProgressTree, so here it is
    leaf_values = [Value(0) for i in range(6)]
    bd_defaults = dict(type=Bar, kwargs=dict(max_value=10))

    test_d = {
        "Warp Jump": {
            "1) Prepare fuel": {
                "Load Tanks": {
                    "Tank 1": BarDescriptor(value=leaf_values[0],
                                            **bd_defaults),
                    "Tank 2": BarDescriptor(value=leaf_values[1],
                                            **bd_defaults),
                },
                "Refine tylium ore":
                BarDescriptor(value=leaf_values[2], **bd_defaults),
            },
            "2) Calculate jump co-ordinates": {
                "Resolve common name to co-ordinates": {
                    "Querying resolution from baseship":
                    BarDescriptor(value=leaf_values[3], **bd_defaults),
                },
            },
            "3) Perform jump": {
                "Check FTL drive readiness":
                BarDescriptor(value=leaf_values[4], **bd_defaults),
                "Juuuuuump!":
                BarDescriptor(value=leaf_values[5], **bd_defaults)
            }
        }
    }

    # We'll use this function to bump up the leaf values
    def incr_value(obj):
        for val in leaf_values:
            if val.value < 10:
                val.value += 1
                break

    # And this to check if we're to stop drawing
    def are_we_done(obj):
        return all(val.value == 10 for val in leaf_values)

    ###################
    # The actual code #
    ###################

    # Create blessings.Terminal instance
    t = Terminal()
    # Initialize a ProgressTree instance
    n = ProgressTree(term=t)
    # We'll use the make_room method to make sure the terminal
    #   is filled out with all the room we need
    n.make_room(test_d)

    while not are_we_done(test_d):
        sleep(0.2 * random.random())
        # After the cursor position is first saved (in the first draw call)
        #   this will restore the cursor back to the top so we can draw again
        n.cursor.restore()
        # We use our incr_value method to bump the fake numbers
        incr_value(test_d)
        # Actually draw out the bars
        n.draw(test_d, BarDescriptor(bd_defaults))
scan_dir = os.path.abspath('.')
print('Finding files to process in %s' % scan_dir)

exclude = {'dev', 'run', 'sys', 'proc', 'btrfs', 'tmp'}

dir_count = 0
dirs_analyzed = 0
file_count = 0
files_analyzed = 0

for root, dirs, files in os.walk(scan_dir, followlinks=False, topdown=True):
    dirs[:] = [d for d in dirs if d not in exclude]
    dir_count += len(dirs)
    file_count += len(files)

leaf_values = [Value(0) for i in range(2)]
bd_directories = dict(type=Bar, kwargs=dict(max_value=dir_count, width='50%'))
bd_files = dict(type=Bar, kwargs=dict(max_value=file_count, width='50%'))
bd_defaults = dict(type=Bar,
                   kwargs=dict(max_value=100,
                               width='50%',
                               num_rep='percentage'))

test_d = {
    'Analyze files in %s' % scan_dir: {
        "Directories": BarDescriptor(value=leaf_values[0], **bd_directories),
        "Files": BarDescriptor(value=leaf_values[1], **bd_files)
    }
}

t = Terminal()
def pretty(delete=False):
    import random
    from time import sleep

    from blessings import Terminal

    from progressive.bar import Bar
    from progressive.tree import ProgressTree, Value, BarDescriptor

    leaf_values = [Value(0) for i in range(1)]
    bd_defaults = dict(type=Bar, kwargs=dict(max_value=900))

    test_d = {
        "Verifying [kubeflow]": BarDescriptor(value=leaf_values[0],
                                              **bd_defaults),
        "Verifying [dkube]": BarDescriptor(value=leaf_values[0],
                                           **bd_defaults),
        "Verifying [dkube-ui]": BarDescriptor(value=leaf_values[0],
                                              **bd_defaults),
        "Verifying [argo]": BarDescriptor(value=leaf_values[0], **bd_defaults),
        "Verifying [minio]": BarDescriptor(value=leaf_values[0],
                                           **bd_defaults),
        "Verifying [efk]": BarDescriptor(value=leaf_values[0], **bd_defaults)
    }

    # We'll use this function to bump up the leaf values
    def incr_value(obj):
        for val in leaf_values:
            if val.value < 900:
                val.value += 10
                break

    # And this to check if we're to stop drawing
    def are_we_done(obj):
        return all(val.value == 900 for val in leaf_values)

    ###################
    # The actual code #
    ###################

    # Create blessings.Terminal instance
    t = Terminal()
    # Initialize a ProgressTree instance
    n = ProgressTree(term=t)
    # We'll use the make_room method to make sure the terminal
    #   is filled out with all the room we need
    n.make_room(test_d)

    monitor_freq = 0
    status = False
    while not status and not are_we_done(test_d):
        if monitor_freq >= 60:
            if not delete:
                status = monitorOnCreation()
            else:
                status = monitorOnDeletion()
            monitor_freq = 0
        # After the cursor position is first saved (in the first draw call)
        #   this will restore the cursor back to the top so we can draw again
        n.cursor.restore()
        # We use our incr_value method to bump the fake numbers
        incr_value(test_d)
        # Actually draw out the bars
        n.draw(test_d, BarDescriptor(bd_defaults))
        sleep(10)
        monitor_freq += 10
    return status
Beispiel #9
0
    def __init__(self, worker_num=__DEFAULT_NUM__):
        self.workers = []
        self.leaf_values = [Value(0) for i in range(worker_num)]

        for i in range(0, worker_num):
            self.workers.append(Worker(i))