mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-26 09:58:31 +01:00
Updated for update repository
This commit is contained in:
parent
888da294f2
commit
4a16fa5fe5
3 changed files with 41 additions and 10 deletions
|
@ -24,7 +24,6 @@ class CheckUpdates:
|
|||
|
||||
def check(self) -> bool:
|
||||
""" Checks the ChangeLogs and returns True or False. """
|
||||
print(end='\rChecking for news in the Changelog.txt file... ')
|
||||
local_date = 0
|
||||
|
||||
local_chg_txt = Path(self.configs.sbo_repo_path,
|
||||
|
@ -63,7 +62,6 @@ class CheckUpdates:
|
|||
|
||||
# Terminate process 2 if process 1 finished
|
||||
if not p1.is_alive():
|
||||
# print(f'{self.endc}{self.yellow} Done{self.endc}', end='')
|
||||
p2.terminate()
|
||||
|
||||
# Wait until process 2 finish
|
||||
|
|
|
@ -158,7 +158,7 @@ class Argparse:
|
|||
|
||||
if len(self.args) == 1:
|
||||
update = UpdateRepository(self.flags)
|
||||
update.sbo()
|
||||
update.repository()
|
||||
raise SystemExit()
|
||||
self.usage.help(1)
|
||||
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from pathlib import Path
|
||||
from multiprocessing import Process
|
||||
|
||||
from slpkg.downloader import Downloader
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.downloader import Downloader
|
||||
from slpkg.create_data import CreateData
|
||||
from slpkg.models.models import SBoTable
|
||||
from slpkg.views.views import ViewMessage
|
||||
from slpkg.progress_bar import ProgressBar
|
||||
from slpkg.check_updates import CheckUpdates
|
||||
from slpkg.models.models import session as Session
|
||||
|
||||
|
@ -18,17 +20,15 @@ class UpdateRepository:
|
|||
def __init__(self, flags: list):
|
||||
self.flags = flags
|
||||
self.configs = Configs
|
||||
self.colors = self.configs.colour
|
||||
self.color = self.colors()
|
||||
self.endc = self.color['endc']
|
||||
self.session = Session
|
||||
self.progress = ProgressBar()
|
||||
|
||||
def sbo(self):
|
||||
""" Updated the sbo repository. """
|
||||
view = ViewMessage(self.flags)
|
||||
check_updates = CheckUpdates()
|
||||
|
||||
if not check_updates.check():
|
||||
print('\n\nNo changes in ChangeLog.txt between your last update and now.')
|
||||
else:
|
||||
print('\n\nThere are new updates available!')
|
||||
|
||||
view.question()
|
||||
|
||||
|
@ -49,6 +49,39 @@ class UpdateRepository:
|
|||
data = CreateData()
|
||||
data.insert_sbo_table()
|
||||
|
||||
def check(self):
|
||||
check_updates = CheckUpdates()
|
||||
if not check_updates.check():
|
||||
print(f'\n\n{self.endc}No changes in ChangeLog.txt between your last update and now.')
|
||||
else:
|
||||
print(f'\n\n{self.endc}There are new updates available!')
|
||||
|
||||
def repository(self):
|
||||
""" Starting multiprocessing download process. """
|
||||
message = f'Checking for news in the Changelog.txt file...'
|
||||
|
||||
# Starting multiprocessing
|
||||
p1 = Process(target=self.check)
|
||||
p2 = Process(target=self.progress.bar, args=(message, ''))
|
||||
|
||||
p1.start()
|
||||
p2.start()
|
||||
|
||||
# Wait until process 1 finish
|
||||
p1.join()
|
||||
|
||||
# Terminate process 2 if process 1 finished
|
||||
if not p1.is_alive():
|
||||
p2.terminate()
|
||||
|
||||
# Wait until process 2 finish
|
||||
p2.join()
|
||||
|
||||
# Restore the terminal cursor
|
||||
print('\x1b[?25h', end='')
|
||||
|
||||
self.sbo()
|
||||
|
||||
@staticmethod
|
||||
def delete_file(folder: str, txt_file: str):
|
||||
""" Delete the file. """
|
||||
|
|
Loading…
Reference in a new issue