Updated for progress bar option

This commit is contained in:
Dimitris Zlatanidis 2024-03-23 18:56:21 +02:00
parent 370f9bcfb7
commit 42aa69ab56
10 changed files with 81 additions and 76 deletions

View file

@ -4,23 +4,25 @@
- Updated: - Updated:
* Blacklist using regex pattern * Blacklist using regex pattern
* Move command check-updates to option --check * Move command check-updates to option --check
* Rename option --no-silent to --silent * Rename option --no-silent to --progress-bar
* Config default silent mode to false * Config default silent mode to false
- Removed: - Removed:
* Remove SQLAlchemy dependency * Removed SQLAlchemy dependency
* Remove help command, instead use manpage * Removed help command, instead use manpage
* Remove clean-logs and clean-data commands * Removed clean-logs and clean-data commands
* Remove rules.toml config file * Removed rules.toml config file
* Remove --install-data option * Removed --install-data option
* Remove FILE_PATTERN from configs * Removed FILE_PATTERN from configs
* Remove --jobs option * Removed --jobs option
* Removed spinni_bar config
- Added: - Added:
* Check for upgrade packages using the option --check * Check for upgrade packages using the option --check
* MAKEFLAGS config to specify the number of jobs * MAKEFLAGS config to specify the number of jobs
* Support GPG verification * Support GPG verification
- Bugfixes: - Bugfixes:
* Double view message when update repositories * Double view message when update repositories
* Package file size for remove * Package file size for remove

View file

@ -33,10 +33,6 @@ CHECKSUM_MD5 = true
# Default is true. [true/false] # Default is true. [true/false]
DIALOG = true DIALOG = true
# If silent mode is true, it does not print the commands as they are executed.
# Default is false. [true/false]
SILENT_MODE = false
# Choose ascii printable characters. # Choose ascii printable characters.
# If true, it uses the extended characters, otherwise the basic ones. # If true, it uses the extended characters, otherwise the basic ones.
# Default is true. [true/false]. # Default is true. [true/false].
@ -50,8 +46,9 @@ ASK_QUESTION = true
# Alternatively, you can use the option '--parallel'. # Alternatively, you can use the option '--parallel'.
PARALLEL_DOWNLOADS = false PARALLEL_DOWNLOADS = false
# Enable or disable the spinning bar. Default is true. [true/false] # If progress bar is true, it does not print the commands as they are executed.
SPINNING_BAR = true # Default is false. [true/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 pixel. [spinner/pie/moon/line/pixel]

View file

@ -137,10 +137,10 @@ Example try: '\fIslpkg install python3 --search\fR' or '\fIslpkg download python
-s, search, -e, dependees, -t, tracking) -s, search, -e, dependees, -t, tracking)
.RE .RE
.P .P
.B -n, --silent .B -B, --progress-bar
.RS .RS
Enable silent mode, if it is false in the configuration file. (to be used with: -U, upgrade, -b, build, Apply it to see a static progress bar instead of process execute like building, installing or removing.
-i, install, -R, remove) (to be used with: -u, update, -U, upgrade, -b, build, -i, install, -R, remove)
.RE .RE
.P .P
.B -p, --pkg-version .B -p, --pkg-version

View file

@ -39,12 +39,16 @@ class CheckUpdates(Configs):
self.option_for_check: bool = self.utils.is_option( self.option_for_check: bool = self.utils.is_option(
('-c', '--check'), flags) ('-c', '--check'), flags)
def check_the_repositories(self, queue) -> None: self.option_for_progress_bar: bool = self.utils.is_option(
('-B', '--progress-bar'), flags)
def check_the_repositories(self, queue=None) -> None:
if self.option_for_repository: if self.option_for_repository:
self.repositories(self.repository) self.repositories(self.repository)
else: else:
self.check_updates_for_repositories() self.check_updates_for_repositories()
if queue is not None:
queue.put(self.compare) queue.put(self.compare)
self.view_messages(self.compare) self.view_messages(self.compare)
@ -129,8 +133,9 @@ class CheckUpdates(Configs):
print(f'\n\n{self.endc}{self.yellow}No updated packages since the last check.{self.endc}') print(f'\n\n{self.endc}{self.yellow}No updated packages since the last check.{self.endc}')
def updates(self) -> dict: def updates(self) -> dict:
queue = Queue()
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()
# Starting multiprocessing # Starting multiprocessing
process_1 = Process(target=self.check_the_repositories, args=(queue,)) process_1 = Process(target=self.check_the_repositories, args=(queue,))
@ -155,3 +160,7 @@ class CheckUpdates(Configs):
print('\x1b[?25h') print('\x1b[?25h')
return compare return compare
else:
print(f'\r{message} ', end='')
self.check_the_repositories()
return self.compare

View file

@ -43,11 +43,10 @@ class Configs:
curl_options: str = '' curl_options: str = ''
lftp_get_options: str = '-c get -e' lftp_get_options: str = '-c get -e'
lftp_mirror_options: str = '-c mirror --parallel=100 --only-newer --delete' lftp_mirror_options: str = '-c mirror --parallel=100 --only-newer --delete'
silent_mode: bool = False
ascii_characters: bool = True ascii_characters: bool = True
ask_question: bool = True ask_question: bool = True
parallel_downloads: bool = False parallel_downloads: bool = False
spinning_bar: str = True progress_bar: bool = False
progress_spinner: str = 'pixel' progress_spinner: str = 'pixel'
spinner_color: str = 'green' spinner_color: str = 'green'
border_color: str = 'bold_green' border_color: str = 'bold_green'
@ -88,11 +87,10 @@ class Configs:
curl_options: str = config['CURL_OPTIONS'] curl_options: str = config['CURL_OPTIONS']
lftp_get_options: str = config['LFTP_GET_OPTIONS'] lftp_get_options: str = config['LFTP_GET_OPTIONS']
lftp_mirror_options: str = config['LFTP_MIRROR_OPTIONS'] lftp_mirror_options: str = config['LFTP_MIRROR_OPTIONS']
silent_mode: bool = config['SILENT_MODE']
ascii_characters: bool = config['ASCII_CHARACTERS'] ascii_characters: bool = config['ASCII_CHARACTERS']
file_list_suffix: str = config['FILE_LIST_SUFFIX'] file_list_suffix: str = config['FILE_LIST_SUFFIX']
parallel_downloads: bool = config['PARALLEL_DOWNLOADS'] parallel_downloads: bool = config['PARALLEL_DOWNLOADS']
spinning_bar: str = config['SPINNING_BAR'] progress_bar: str = config['PROGRESS_BAR']
progress_spinner: str = config['PROGRESS_SPINNER'] progress_spinner: str = config['PROGRESS_SPINNER']
spinner_color: str = config['SPINNER_COLOR'] spinner_color: str = config['SPINNER_COLOR']
border_color: str = config['BORDER_COLOR'] border_color: str = config['BORDER_COLOR']

View file

@ -59,8 +59,8 @@ class Menu(Configs):
self.flag_short_full_reverse: str = '-E' self.flag_short_full_reverse: str = '-E'
self.flag_search: str = '--search' self.flag_search: str = '--search'
self.flag_short_search: str = '-S' self.flag_short_search: str = '-S'
self.flag_for_silent: str = '--silent' self.flag_for_progress_bar: str = '--progress-bar'
self.flag_short_for_silent: str = '-n' self.flag_short_for_progress_bar: str = '-B'
self.flag_pkg_version: str = '--pkg-version' self.flag_pkg_version: str = '--pkg-version'
self.flag_short_pkg_version: str = '-p' self.flag_short_pkg_version: str = '-p'
self.flag_parallel: str = '--parallel' self.flag_parallel: str = '--parallel'
@ -97,8 +97,8 @@ class Menu(Configs):
self.flag_short_full_reverse, self.flag_short_full_reverse,
self.flag_search, self.flag_search,
self.flag_short_search, self.flag_short_search,
self.flag_for_silent, self.flag_for_progress_bar,
self.flag_short_for_silent, self.flag_short_for_progress_bar,
self.flag_pkg_version, self.flag_pkg_version,
self.flag_short_pkg_version, self.flag_short_pkg_version,
self.flag_parallel, self.flag_parallel,
@ -123,7 +123,9 @@ class Menu(Configs):
self.flag_repository, self.flag_repository,
self.flag_short_repository, self.flag_short_repository,
self.flag_parallel, self.flag_parallel,
self.flag_short_parallel self.flag_short_parallel,
self.flag_for_progress_bar,
self.flag_short_for_progress_bar,
], ],
'upgrade': [ 'upgrade': [
self.flag_yes, self.flag_yes,
@ -134,8 +136,8 @@ class Menu(Configs):
self.flag_short_resolve_off, self.flag_short_resolve_off,
self.flag_reinstall, self.flag_reinstall,
self.flag_short_reinstall, self.flag_short_reinstall,
self.flag_for_silent, self.flag_for_progress_bar,
self.flag_short_for_silent, self.flag_short_for_progress_bar,
self.flag_repository, self.flag_repository,
self.flag_short_repository, self.flag_short_repository,
self.flag_parallel, self.flag_parallel,
@ -154,8 +156,8 @@ class Menu(Configs):
self.flag_short_resolve_off, self.flag_short_resolve_off,
self.flag_search, self.flag_search,
self.flag_short_search, self.flag_short_search,
self.flag_for_silent, self.flag_for_progress_bar,
self.flag_short_for_silent, self.flag_short_for_progress_bar,
self.flag_repository, self.flag_repository,
self.flag_short_repository, self.flag_short_repository,
self.flag_parallel, self.flag_parallel,
@ -174,8 +176,8 @@ class Menu(Configs):
self.flag_short_skip_installed, self.flag_short_skip_installed,
self.flag_search, self.flag_search,
self.flag_short_search, self.flag_short_search,
self.flag_for_silent, self.flag_for_progress_bar,
self.flag_short_for_silent, self.flag_short_for_progress_bar,
self.flag_repository, self.flag_repository,
self.flag_short_repository, self.flag_short_repository,
self.flag_parallel, self.flag_parallel,
@ -204,8 +206,8 @@ class Menu(Configs):
self.flag_short_resolve_off, self.flag_short_resolve_off,
self.flag_search, self.flag_search,
self.flag_short_search, self.flag_short_search,
self.flag_for_silent, self.flag_for_progress_bar,
self.flag_short_for_silent, self.flag_short_for_progress_bar,
], ],
'find': [ 'find': [
self.flag_search, self.flag_search,

View file

@ -27,8 +27,8 @@ class MultiProcess(Configs):
self.bottom_message: str = 'EOF - End of log file' self.bottom_message: str = 'EOF - End of log file'
if flags is not None: if flags is not None:
self.option_for_silent: bool = self.utils.is_option( self.option_for_progress_bar: bool = self.utils.is_option(
('-n', '--silent'), flags) ('-B', '--progress-bar'), flags)
def run(self, command: str, filename: str, progress_message: str) -> None: def run(self, command: str, filename: str, progress_message: str) -> None:
""" Starting a multiprocessing process. """ Starting a multiprocessing process.
@ -39,7 +39,7 @@ class MultiProcess(Configs):
Returns: Returns:
None. None.
""" """
if self.silent_mode or self.option_for_silent: if self.progress_bar or self.option_for_progress_bar:
done: str = f'{self.bgreen}{self.ascii.done}{self.endc}' done: str = f'{self.bgreen}{self.ascii.done}{self.endc}'
failed: str = f'{self.bred}{self.ascii.failed}{self.endc}' failed: str = f'{self.bred}{self.ascii.failed}{self.endc}'
@ -83,7 +83,7 @@ class MultiProcess(Configs):
# Write the process to the log file and to the terminal. # Write the process to the log file and to the terminal.
with process.stdout as output: with process.stdout as output:
for i, line in enumerate(output): for i, line in enumerate(output):
if not self.silent_mode and not self.option_for_silent: if not self.progress_bar and not self.option_for_progress_bar:
print(line.strip()) # Print to console print(line.strip()) # Print to console
if self.process_log: if self.process_log:
with open(self.slpkg_log_file, 'a') as log: with open(self.slpkg_log_file, 'a') as log:
@ -100,7 +100,7 @@ class MultiProcess(Configs):
def _error_process(self): def _error_process(self):
""" Prints error message for a process. """ """ Prints error message for a process. """
if not self.silent_mode and not self.option_for_silent: if not self.progress_bar and not self.option_for_progress_bar:
message: str = f'Error occurred with process. Please check the log file.' message: str = f'Error occurred with process. Please check the log file.'
print() print()
print(len(message) * '=') print(len(message) * '=')

View file

@ -29,7 +29,6 @@ class ProgressBar(Configs):
self.set_color() self.set_color()
self.set_the_spinner_message(filename, message) self.set_the_spinner_message(filename, message)
if self.spinning_bar:
bar_spinner = self.spinner(f'{self.bar_message}{self.color}') bar_spinner = self.spinner(f'{self.bar_message}{self.color}')
# print('\033[F', end='', flush=True) # print('\033[F', end='', flush=True)
try: try:
@ -38,9 +37,6 @@ class ProgressBar(Configs):
bar_spinner.next() bar_spinner.next()
except KeyboardInterrupt: except KeyboardInterrupt:
raise SystemExit(1) raise SystemExit(1)
else:
print(f"{'':>2}{self.yellow}{self.ascii.bullet}{self.endc} {filename}: "
f"{message}... {self.color}", end='')
def assign_spinners(self) -> None: def assign_spinners(self) -> None:
self.spinners: dict = { self.spinners: dict = {

View file

@ -75,12 +75,14 @@ class Usage(Configs):
f' {self.yellow}-c, --check{self.endc} Check a procedure before you run it.\n' f' {self.yellow}-c, --check{self.endc} Check a procedure before you run it.\n'
f' {self.yellow}-O, --resolve-off{self.endc} Turns off dependency resolving.\n' f' {self.yellow}-O, --resolve-off{self.endc} Turns off dependency resolving.\n'
f' {self.yellow}-r, --reinstall{self.endc} Upgrade packages of the same version.\n' f' {self.yellow}-r, --reinstall{self.endc} Upgrade packages of the same version.\n'
f' {self.yellow}-k, --skip-installed{self.endc} Skip installed packages.\n' f' {self.yellow}-k, --skip-installed{self.endc} Skip installed packages during the building\n'
f'{"":>28}or installation progress.\n'
f' {self.yellow}-E, --full-reverse{self.endc} Display the full reverse dependency.\n' f' {self.yellow}-E, --full-reverse{self.endc} Display the full reverse dependency.\n'
f' {self.yellow}-S, --search{self.endc} Search and load packages using the dialog.\n' f' {self.yellow}-S, --search{self.endc} Search and load packages using the dialog.\n'
f' {self.yellow}-n, --silent{self.endc} Enable silent mode.\n' f' {self.yellow}-B, --progress-bar{self.endc} Display static progress bar instead of\n'
f'{"":>28}process execute.\n'
f' {self.yellow}-p, --pkg-version{self.endc} Print the repository package version.\n' f' {self.yellow}-p, --pkg-version{self.endc} Print the repository package version.\n'
f' {self.yellow}-P, --parallel{self.endc} Download files in parallel.\n' f' {self.yellow}-P, --parallel{self.endc} Enable download files in parallel.\n'
f' {self.yellow}-m, --no-case{self.endc} Case-insensitive pattern matching.\n' f' {self.yellow}-m, --no-case{self.endc} Case-insensitive pattern matching.\n'
f' {self.yellow}-o, --repository={self.endc}NAME Change repository you want to work.\n' f' {self.yellow}-o, --repository={self.endc}NAME Change repository you want to work.\n'
f' {self.yellow}-z, --directory={self.endc}PATH Download files to a specific path.\n' f' {self.yellow}-z, --directory={self.endc}PATH Download files to a specific path.\n'

View file

@ -37,11 +37,10 @@ class TestConfigs(unittest.TestCase):
self.assertEqual('', self.configs.curl_options) self.assertEqual('', self.configs.curl_options)
self.assertEqual('-c get -e', self.configs.lftp_get_options) self.assertEqual('-c get -e', self.configs.lftp_get_options)
self.assertEqual('-c mirror --parallel=100 --only-newer --delete', self.configs.lftp_mirror_options) self.assertEqual('-c mirror --parallel=100 --only-newer --delete', self.configs.lftp_mirror_options)
self.assertEqual(False, self.configs.silent_mode)
self.assertEqual(True, self.configs.ascii_characters) self.assertEqual(True, self.configs.ascii_characters)
self.assertEqual(True, self.configs.ask_question) self.assertEqual(True, self.configs.ask_question)
self.assertEqual(False, self.configs.parallel_downloads) self.assertEqual(False, self.configs.parallel_downloads)
self.assertEqual(True, self.configs.spinning_bar) self.assertEqual(True, self.configs.progress_bar)
self.assertEqual('pixel', self.configs.progress_spinner) self.assertEqual('pixel', self.configs.progress_spinner)
self.assertEqual('green', self.configs.spinner_color) self.assertEqual('green', self.configs.spinner_color)
self.assertEqual('bold_green', self.configs.border_color) self.assertEqual('bold_green', self.configs.border_color)