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