mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-11-16 07:47:35 +01:00
Added pythondialog for upgrade
This commit is contained in:
parent
86ab4deecd
commit
e38314906d
5 changed files with 37 additions and 2 deletions
|
@ -21,6 +21,7 @@ Requirements
|
|||
.. code-block:: bash
|
||||
|
||||
SQLAlchemy >= 1.4.36
|
||||
pythondialog >= 3.5.3
|
||||
toml >= 0.10.2
|
||||
|
||||
Install
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
SQLAlchemy>=1.4.36
|
||||
pythondialog>=3.5.3
|
||||
toml>=0.10.2
|
|
@ -39,6 +39,7 @@ packages =
|
|||
python_requires = >=3.7
|
||||
install_requires =
|
||||
SQLAlchemy >= 1.4.36
|
||||
pythondialog >= 3.5.3
|
||||
toml >= 0.10.2
|
||||
include_package_data = True
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ class Argparse:
|
|||
self.check.database()
|
||||
|
||||
upgrade = Upgrade()
|
||||
packages = list(upgrade.packages())
|
||||
packages = upgrade.packages()
|
||||
|
||||
if not packages:
|
||||
print('\nEverything is up-to-date.\n')
|
||||
|
|
|
@ -2,22 +2,31 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import locale
|
||||
from dialog import Dialog
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.views.version import Version
|
||||
from slpkg.queries import SBoQueries
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.blacklist import Blacklist
|
||||
|
||||
|
||||
# This is almost always a good thing to do at the beginning of your programs.
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
|
||||
|
||||
class Upgrade:
|
||||
""" Upgrade the installed packages. """
|
||||
|
||||
def __init__(self):
|
||||
self.configs = Configs
|
||||
self.utils = Utilities()
|
||||
self.d = Dialog(dialog="dialog")
|
||||
self.d.set_background_title(f'{self.configs.prog_name} {Version().version}')
|
||||
|
||||
def packages(self):
|
||||
def search(self):
|
||||
""" Compares version of packages and returns the maximum. """
|
||||
repo_packages = SBoQueries('').sbos()
|
||||
black = Blacklist().get()
|
||||
|
@ -34,3 +43,26 @@ class Upgrade:
|
|||
|
||||
if LooseVersion(repo_ver) > LooseVersion(installed_ver):
|
||||
yield inst_pkg_name
|
||||
|
||||
def packages(self):
|
||||
""" Choose packages for upgrade. """
|
||||
choices = []
|
||||
packages = self.search()
|
||||
|
||||
for package in packages:
|
||||
pkg = self.utils.is_installed(package)
|
||||
version = self.utils.split_installed_pkg(pkg)[1]
|
||||
choices += [(package, version, False)]
|
||||
|
||||
code, tags = self.d.checklist(f'There are {len(choices)} packages for upgrade:',
|
||||
title='Choose packages you want to upgrade',
|
||||
height=10, width=70, list_height=0, choices=choices)
|
||||
|
||||
if code == self.d.OK:
|
||||
os.system('clear')
|
||||
if not tags:
|
||||
raise SystemExit()
|
||||
return tags
|
||||
|
||||
os.system('clear')
|
||||
raise SystemExit()
|
||||
|
|
Loading…
Reference in a new issue