Exemplo n.º 1
0
def show_custom_animation():
    total = 50
    fill_char = "|"
    empty_char = "_"
    head = None
    left_limit = ""
    right_limit = ""
    scale_start = 0
    scale_end = 1000
    bar = CustomProgressBar(
        length=total,
        left_limit=left_limit,
        right_limit=right_limit,
        head_repr=head,
        empty_repr=empty_char,
        filled_repr=fill_char,
        start=0,
        scale_start=scale_start,
        scale_end=scale_end,
    )
    bar.show_progress_bar()
    while not bar.completed():
        time.sleep(0.03)
        bar.increase(10)
        bar.show_progress_bar()
Exemplo n.º 2
0
def download_file():
    big_file_url = "http://www.python.org/ftp/python/3.3.2/Python-3.3.2.tgz"

    # Download the file
    if sys.version_info[0] == 3:
        f = urllib.request.urlopen(big_file_url)
    else:
        f = urllib.urlopen(big_file_url)

    # Get the total length of the file
    scale = int(f.headers["content-length"])
    chunk_size = 500

    bar = CustomProgressBar(
        length=50,
        left_limit="[",
        right_limit="]",
        head_repr=None,
        empty_repr=" ",
        filled_repr="|",
        start=0,
        scale_start=0,
        scale_end=scale,
    )

    print("Downloading a big txt file: ")

    print_flag = 0
    # Load all the data chunk by chunk
    while not bar.completed():
        f.read(chunk_size)
        bar.increase(chunk_size)

        # Don't print always
        if print_flag == 100:
            bar.show_progress_bar()
            print_flag = 0
        else:
            print_flag += 1

    bar.show_progress_bar()
    print("")
    print("Finished :)")
Exemplo n.º 3
0
def download_file():
    big_file_url = "http://www.python.org/ftp/python/3.3.2/Python-3.3.2.tgz"

    # Download the file
    if sys.version_info[0] == 3:
        f = urllib.request.urlopen(big_file_url)
    else:
        f = urllib.urlopen(big_file_url)

    # Get the total length of the file
    scale = int(f.headers["content-length"])
    chunk_size = 500

    bar = CustomProgressBar(length=50,
                            left_limit='[',
                            right_limit=']',
                            head_repr=None,
                            empty_repr=' ',
                            filled_repr='|',
                            start=0,
                            scale_start=0,
                            scale_end=scale)

    print("Downloading a big txt file: ")

    print_flag = 0
    # Load all the data chunk by chunk
    while not bar.completed():
        f.read(chunk_size)
        bar.increase(chunk_size)

        # Don't print always
        if print_flag == 100:
            bar.show_progress_bar()
            print_flag = 0
        else:
            print_flag += 1

    bar.show_progress_bar()
    print("")
    print("Finished :)")
Exemplo n.º 4
0
def show_custom_animation():
    total = 50
    fill_char = '|'
    empty_char = '_'
    head = None
    left_limit = ''
    right_limit = ''
    scale_start = 0
    scale_end = 1000
    bar = CustomProgressBar(length=total,
                            left_limit=left_limit,
                            right_limit=right_limit,
                            head_repr=head,
                            empty_repr=empty_char,
                            filled_repr=fill_char,
                            start=0,
                            scale_start=scale_start,
                            scale_end=scale_end)
    bar.show_progress_bar()
    while (not bar.completed()):
        time.sleep(0.03)
        bar.increase(10)
        bar.show_progress_bar()