Пример #1
0
    def hrn(self):

        leaf_values = {}
        bd_defaults = {}
        test_d = {}
        self.init_progressive(leaf_values, bd_defaults, test_d)
        n.make_room(test_d)
        n.draw(test_d, BarDescriptor(bd_defaults['A']))

        while len(self.process.p_id):
            identifier = "p_id"
            rr = 0
            for p in self.process.p_id:
                p_rr = (self.current_time - self.process.arrive_time[p] + self.process.remain_time[p]) /\
                       self.process.service_time[p]
                if p_rr > rr:
                    identifier = p
                    rr = p_rr

            if self.current_time < self.process.arrive_time[identifier]:
                sleep(1)
                self.current_time += 1
                print('\r current time: %d' % self.current_time, end='')
                continue

            process_finish_time = self.run_process(identifier, 1, self.current_time, leaf_values)
            sleep(1)
            n.cursor.restore()
            n.draw(test_d, BarDescriptor(bd_defaults[identifier]))
            print('\r current time: %d' % self.current_time)

            if process_finish_time != 0:
                self.process.process_run_info(identifier, process_finish_time, self.result)
                self.process.process_exit(identifier)
Пример #2
0
    def fcfs(self):

        leaf_values = {}
        bd_defaults = {}
        test_d = {}
        self.init_progressive(leaf_values, bd_defaults, test_d)
        n.make_room(test_d)
        latest_p = 'A'
        n.draw(test_d, BarDescriptor(bd_defaults[latest_p]))
        for p in self.process.p_id:
            if self.process.arrive_time[p] >= self.process.arrive_time[latest_p]:
                latest_p = p

        while len(self.process.p_id):
            pid = latest_p
            for p in self.process.p_id:
                if self.process.arrive_time[p] < self.process.arrive_time[pid]:
                    pid = p
            if self.current_time < self.process.arrive_time[pid]:
                sleep(1)
                self.current_time += 1
                print('\r current time: %d' % self.current_time, end='')
                continue
            process_finish_time = self.run_process(pid, 1, self.current_time, leaf_values)
            sleep(1)
            n.cursor.restore()
            n.draw(test_d, BarDescriptor(bd_defaults[pid]))
            print('\r current time: %d' % self.current_time)

            if process_finish_time != 0:
                self.process.process_run_info(pid, process_finish_time, self.result)
                self.process.process_exit(pid)
Пример #3
0
    def rr(self):

        leaf_values = {}
        bd_defaults = {}
        test_d = {}
        self.init_progressive(leaf_values, bd_defaults, test_d)
        n.make_room(test_d)
        n.draw(test_d, BarDescriptor(bd_defaults['A']))

        while len(self.process.p_id):
            pop_list = []
            need_sleep = True
            for p in self.process.p_id:
                if self.process.arrive_time[p] <= self.current_time:
                    need_sleep = False
                    n.cursor.restore()
                    process_finish_time = self.run_process(p, 1, self.current_time, leaf_values)
                    sleep(1)
                    n.draw(test_d, BarDescriptor(bd_defaults[p]))
                    print('\r current time: %d' % self.current_time)
                    if process_finish_time != 0:
                        self.process.process_run_info(p, process_finish_time, self.result)
                        pop_list.append(p)

            if need_sleep:
                sleep(1)
                self.current_time += 1
                print('\r current time: %d' % self.current_time, end='')
            for q in pop_list:
                self.process.process_exit(q)
Пример #4
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])
Пример #5
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)
Пример #6
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()
Пример #7
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
Пример #8
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))
Пример #9
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()
n = ProgressTree(term=t)
n.make_room(test_d)


def are_we_done():
    return files_analyzed == file_count


while not are_we_done():
    for root, dirs, files in os.walk(scan_dir, followlinks=False,
Пример #10
0
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
Пример #11
0
 def invalidate(self):
     while not self.terminal:
         time.sleep(0.1)
         self.n.cursor.restore()
         self.n.draw(self.graph_data,BarDescriptor(self.bd_defaults))
Пример #12
0
hx1.reset()
hx2.reset()
hx3.reset()
hx4.reset()

hx1.tare()
hx2.tare()
hx3.tare()
hx4.tare()

leaf_values = [Value(0) for i in range(4)]
bd_defaults = dict(type=Bar, kwargs=dict(max_value=MAX_BAR_VALUE, width=BAR_WID$

test_d = {
"Carb 1": BarDescriptor(value=leaf_values[0], **bd_defaults),
"Carb 2": BarDescriptor(value=leaf_values[1], **bd_defaults),
"Carb 3": BarDescriptor(value=leaf_values[2], **bd_defaults),
"Carb 4": BarDescriptor(value=leaf_values[3], **bd_defaults),
}

# 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
os.system('clear')
n.make_room(test_d)
#n.cursor.save()
while True: