mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-25 09:58:41 +01:00
Updated for progress bar
This commit is contained in:
parent
a31e760118
commit
20633621a3
7 changed files with 32 additions and 31 deletions
|
@ -1,8 +1,12 @@
|
|||
## slpkg - ChangeLog
|
||||
|
||||
### 5.0.4 - 01/04/2024
|
||||
### 5.0.4 - 02/04/2024
|
||||
- Updated:
|
||||
* Updated to ignore blacklist installed packages
|
||||
* Updated progress bar spinners
|
||||
|
||||
- Removed:
|
||||
* python3-progress dependency
|
||||
|
||||
### 5.0.3 - 01/04/2024
|
||||
- Updated:
|
||||
|
|
|
@ -61,12 +61,12 @@ PARALLEL_DOWNLOADS = false
|
|||
PROGRESS_BAR = false
|
||||
|
||||
# There are 5 predefined spinners for the progress bar.
|
||||
# Default is pixel. [spinner/pie/moon/line/pixel]
|
||||
PROGRESS_SPINNER = "pixel"
|
||||
# Default is spinner. [spinner/pie/moon/line/pixel/ball/clock]
|
||||
PROGRESS_SPINNER = "spinner"
|
||||
|
||||
# Choose color for the progress bar spinner.
|
||||
# Default is green. [white/green/violet/yellow/blue/cyan/grey/red]
|
||||
SPINNER_COLOR = "green"
|
||||
# Default is white. [white/green/violet/yellow/blue/cyan/grey/red]
|
||||
SPINNER_COLOR = "white"
|
||||
|
||||
# Choose color for the border box.
|
||||
# Bold colors: [bold_green/bold_cyan/bold_yellow/bold_red/bold_blue]
|
||||
|
|
|
@ -36,8 +36,7 @@ classifiers = [
|
|||
]
|
||||
|
||||
dependencies = [
|
||||
"pythondialog>=3.5.3",
|
||||
"progress>=1.6",
|
||||
"pythondialog>=3.5.3"
|
||||
]
|
||||
|
||||
[tool.flit_core]
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
pythondialog >= 3.5.3
|
||||
progress >= 1.6
|
||||
build >= 0.10.0
|
||||
|
||||
[socks]
|
||||
|
|
|
@ -141,7 +141,7 @@ class CheckUpdates(Configs):
|
|||
print()
|
||||
|
||||
def updates(self) -> dict:
|
||||
message: str = 'Checking for news, please wait...'
|
||||
message: str = 'Checking for news, please wait'
|
||||
if self.progress_bar or self.option_for_progress_bar:
|
||||
queue = Queue()
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import time
|
||||
from progress.spinner import (PixelSpinner, LineSpinner,
|
||||
MoonSpinner, PieSpinner, Spinner)
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.views.asciibox import AsciiBox
|
||||
|
@ -13,40 +11,32 @@ class ProgressBar(Configs):
|
|||
|
||||
def __init__(self):
|
||||
super(Configs, self).__init__()
|
||||
self.spinner = PixelSpinner
|
||||
self.ascii = AsciiBox()
|
||||
|
||||
self.color: str = self.endc
|
||||
self.spinners: dict = {}
|
||||
self.spinners_color: dict = {}
|
||||
self.spinner: str = ''
|
||||
self.bar_message: str = ''
|
||||
|
||||
def progress_bar(self, message: str, filename=None) -> None:
|
||||
""" Creating progress bar. """
|
||||
self.assign_spinners()
|
||||
self.assign_spinner_colors()
|
||||
self.set_spinner()
|
||||
self.assign_spinner_colors()
|
||||
self.set_color()
|
||||
self.set_the_spinner_message(filename, message)
|
||||
print('\x1b[?25l', end='') # Hide cursor before starting
|
||||
|
||||
bar_spinner = self.spinner(f'{self.bar_message}{self.color}')
|
||||
# print('\033[F', end='', flush=True)
|
||||
current_state = 0 # Index of the current state
|
||||
try:
|
||||
while True:
|
||||
print(f"\r{self.bar_message}{self.color}{self.spinner[current_state]}{self.endc}", end="")
|
||||
time.sleep(0.1)
|
||||
bar_spinner.next()
|
||||
current_state = (current_state + 1) % len(self.spinner)
|
||||
except KeyboardInterrupt:
|
||||
print('\x1b[?25h', end='')
|
||||
raise SystemExit(1)
|
||||
|
||||
def assign_spinners(self) -> None:
|
||||
self.spinners: dict = {
|
||||
'pixel': PixelSpinner,
|
||||
'line': LineSpinner,
|
||||
'moon': MoonSpinner,
|
||||
'pie': PieSpinner,
|
||||
'spinner': Spinner
|
||||
}
|
||||
|
||||
def assign_spinner_colors(self) -> None:
|
||||
self.spinners_color: dict = {
|
||||
'green': self.green,
|
||||
|
@ -60,16 +50,25 @@ class ProgressBar(Configs):
|
|||
}
|
||||
|
||||
def set_the_spinner_message(self, filename: str, message: str) -> None:
|
||||
self.bar_message: str = f"{self.endc}{message} "
|
||||
self.bar_message: str = f'{message}... '
|
||||
if filename:
|
||||
self.bar_message: str = (f"{'':>2}{self.yellow}{self.ascii.bullet}{self.endc} {filename}: "
|
||||
f"{message}... ")
|
||||
|
||||
def set_spinner(self) -> None:
|
||||
self.spinners: dict = {
|
||||
'spinner': ('-', '\\', '|', '/'),
|
||||
'pie': ('◷', '◶', '◵', '◴'),
|
||||
'moon': ('◑', '◒', '◐', '◓'),
|
||||
'line': ('⎺', '⎻', '⎼', '⎽', '⎼', '⎻'),
|
||||
'pixel': ('⣾', '⣷', '⣯', '⣟', '⡿', '⢿', '⣻', '⣽'),
|
||||
'ball': ('_', '.', '|', 'o'),
|
||||
'clock': ('🕛', '🕑', '🕒', '🕔', '🕧', '🕗', '🕘', '🕚')
|
||||
}
|
||||
try:
|
||||
self.spinner: str = self.spinners[self.progress_spinner]
|
||||
self.spinner: tuple = self.spinners[self.progress_spinner]
|
||||
except KeyError:
|
||||
self.spinner = PixelSpinner
|
||||
self.spinner: tuple = self.spinners['spinner']
|
||||
|
||||
def set_color(self) -> None:
|
||||
try:
|
||||
|
|
|
@ -23,11 +23,11 @@ class TestSBoQueries(unittest.TestCase):
|
|||
self.assertEqual([], self.data[self.name]['download64'])
|
||||
|
||||
def test_requires(self):
|
||||
self.assertEqual(['python3-build', 'SQLAlchemy', 'python3-pythondialog', 'python3-progress'],
|
||||
self.assertEqual(['python3-build', 'python3-pythondialog'],
|
||||
self.data[self.name]['requires'])
|
||||
|
||||
def test_version(self):
|
||||
self.assertEqual('4.9.8', self.data[self.name]['version'])
|
||||
self.assertEqual('5.0.4', self.data[self.name]['version'])
|
||||
|
||||
def test_checksum_x86(self):
|
||||
self.assertListEqual(['9f9cf626d7246202886774c6cbc2cccf'], self.data[self.name]['md5sum'])
|
||||
|
|
Loading…
Reference in a new issue