mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-29 10:26:12 +01:00
Merge branch 'develop'
This commit is contained in:
commit
3f9488612c
4 changed files with 63 additions and 20 deletions
|
@ -29,22 +29,23 @@ class Downloader:
|
|||
self.byellow = f'{self.bold}{self.yellow}'
|
||||
self.bred = f'{self.bold}{self.red}'
|
||||
self.progress = ProgressBar()
|
||||
self.output = 0
|
||||
self.stderr = None
|
||||
self.stdout = None
|
||||
|
||||
def wget(self):
|
||||
""" Wget downloader. """
|
||||
output = subprocess.call(f'wget {self.configs.wget_options} --directory-prefix={self.path} {self.url}',
|
||||
shell=True, stderr=self.stderr, stdout=self.stdout)
|
||||
if output != 0:
|
||||
raise SystemExit(output)
|
||||
self.output = subprocess.call(f'wget {self.configs.wget_options} --directory-prefix={self.path} {self.url}',
|
||||
shell=True, stderr=self.stderr, stdout=self.stdout)
|
||||
if self.output != 0:
|
||||
raise SystemExit(self.output)
|
||||
|
||||
def check_if_downloaded(self):
|
||||
""" Checks if the file downloaded. """
|
||||
file = self.url.split('/')[-1]
|
||||
path_file = Path(self.path, file)
|
||||
if not path_file.exists():
|
||||
raise SystemExit(f"\n{self.red}FAILED {self.stderr}:{self.endc} '{self.blue}{self.url}{self.endc}' "
|
||||
raise SystemExit(f"\n{self.red}FAILED {self.output}:{self.endc} '{self.blue}{self.url}{self.endc}' "
|
||||
f"to download.\n")
|
||||
|
||||
def download(self):
|
||||
|
@ -68,9 +69,11 @@ class Downloader:
|
|||
|
||||
# Terminate process 2 if process 1 finished
|
||||
if not p1.is_alive():
|
||||
|
||||
if p1.exitcode != 0:
|
||||
done = f' {self.bred} Failed{self.endc}'
|
||||
self.stderr = p1.exitcode
|
||||
self.output = p1.exitcode
|
||||
|
||||
print(f'{self.endc}{done}', end='')
|
||||
p2.terminate()
|
||||
|
||||
|
|
|
@ -25,13 +25,16 @@ class RemovePackages:
|
|||
self.color = self.colors()
|
||||
self.bold = self.color['bold']
|
||||
self.yellow = self.color['yellow']
|
||||
self.byellow = f'{self.bold}{self.yellow}'
|
||||
self.red = self.color['red']
|
||||
self.endc = self.color['endc']
|
||||
self.byellow = f'{self.bold}{self.yellow}'
|
||||
self.bred = f'{self.bold}{self.red}'
|
||||
self.installed_packages = []
|
||||
self.dependencies = []
|
||||
self.utils = Utilities()
|
||||
self.progress = ProgressBar()
|
||||
self.output = 0
|
||||
self.remove_pkg = None
|
||||
self.stderr = None
|
||||
self.stdout = None
|
||||
|
||||
|
@ -59,6 +62,7 @@ class RemovePackages:
|
|||
def remove_packages(self):
|
||||
""" Run Slackware command to remove the packages. """
|
||||
for package in self.installed_packages:
|
||||
self.remove_pkg = package
|
||||
command = f'{self.configs.removepkg} {package}'
|
||||
self.multi_process(command, package)
|
||||
|
||||
|
@ -79,6 +83,7 @@ class RemovePackages:
|
|||
def multi_process(self, command, package):
|
||||
""" Starting multiprocessing remove process. """
|
||||
if self.configs.view_mode == 'new':
|
||||
done = f' {self.byellow} Done{self.endc}'
|
||||
message = f'{self.red}Remove{self.endc}'
|
||||
self.stderr = subprocess.DEVNULL
|
||||
self.stdout = subprocess.DEVNULL
|
||||
|
@ -95,7 +100,12 @@ class RemovePackages:
|
|||
|
||||
# Terminate process 2 if process 1 finished
|
||||
if not p1.is_alive():
|
||||
print(f'{self.endc}{self.byellow} Done{self.endc}', end='')
|
||||
|
||||
if p1.exitcode != 0:
|
||||
done = f' {self.bred} Failed{self.endc}'
|
||||
self.output = p1.exitcode
|
||||
|
||||
print(f'{self.endc}{done}', end='')
|
||||
p2.terminate()
|
||||
|
||||
# Wait until process 2 finish
|
||||
|
@ -106,9 +116,16 @@ class RemovePackages:
|
|||
else:
|
||||
self.process(command)
|
||||
|
||||
self.print_error()
|
||||
|
||||
def process(self, command):
|
||||
""" Processes execution. """
|
||||
output = subprocess.call(command, shell=True,
|
||||
stderr=self.stderr, stdout=self.stdout)
|
||||
if output > 0:
|
||||
raise SystemExit(output)
|
||||
self.output = subprocess.call(command, shell=True,
|
||||
stderr=self.stderr, stdout=self.stdout)
|
||||
if self.output != 0:
|
||||
raise SystemExit(self.output)
|
||||
|
||||
def print_error(self):
|
||||
""" Stop the process and print the error message. """
|
||||
if self.output != 0:
|
||||
raise SystemExit(f"\n{self.red}FAILED {self.stderr}:{self.endc} package '{self.remove_pkg}' to remove.\n")
|
||||
|
|
|
@ -41,12 +41,15 @@ class Slackbuilds:
|
|||
self.cyan = self.color['cyan']
|
||||
self.red = self.color['red']
|
||||
self.yellow = self.color['yellow']
|
||||
self.byellow = f'{self.bold}{self.yellow}'
|
||||
self.endc = self.color['endc']
|
||||
self.byellow = f'{self.bold}{self.yellow}'
|
||||
self.bred = f'{self.bold}{self.red}'
|
||||
self.install_order = []
|
||||
self.dependencies = []
|
||||
self.sbos = {}
|
||||
self.progress = ProgressBar()
|
||||
self.process_message = None
|
||||
self.output = 0
|
||||
self.stderr = None
|
||||
self.stdout = None
|
||||
|
||||
|
@ -231,9 +234,14 @@ class Slackbuilds:
|
|||
execute = self.configs.reinstall
|
||||
|
||||
message = f'{self.cyan}Installing{self.endc}'
|
||||
self.process_message = f"'{pkg}' to install"
|
||||
|
||||
if self.mode == 'upgrade':
|
||||
self.process_message = f"package '{pkg}' to upgrade"
|
||||
message = f'{self.cyan}Upgrade{self.endc}'
|
||||
|
||||
command = f'{execute} {self.configs.tmp_path}/{package}'
|
||||
|
||||
self.multi_process(command, package, message)
|
||||
|
||||
def creating_package_for_install(self, name: str):
|
||||
|
@ -264,6 +272,8 @@ class Slackbuilds:
|
|||
self.set_makeflags()
|
||||
|
||||
message = f'{self.red}Build{self.endc}'
|
||||
self.process_message = f"package '{name}' to build"
|
||||
|
||||
self.multi_process(execute, name, message)
|
||||
|
||||
@staticmethod
|
||||
|
@ -286,6 +296,7 @@ class Slackbuilds:
|
|||
def multi_process(self, command, filename, message):
|
||||
""" Starting multiprocessing install/upgrade process. """
|
||||
if self.configs.view_mode == 'new':
|
||||
done = f' {self.byellow} Done{self.endc}'
|
||||
self.stderr = subprocess.DEVNULL
|
||||
self.stdout = subprocess.DEVNULL
|
||||
|
||||
|
@ -301,7 +312,12 @@ class Slackbuilds:
|
|||
|
||||
# Terminate process 2 if process 1 finished
|
||||
if not p1.is_alive():
|
||||
print(f'{self.endc}{self.byellow} Done{self.endc}', end='')
|
||||
|
||||
if p1.exitcode != 0:
|
||||
done = f' {self.bred} Failed{self.endc}'
|
||||
self.output = p1.exitcode
|
||||
|
||||
print(f'{self.endc}{done}', end='')
|
||||
p2.terminate()
|
||||
|
||||
# Wait until process 2 finish
|
||||
|
@ -312,9 +328,16 @@ class Slackbuilds:
|
|||
else:
|
||||
self.process(command)
|
||||
|
||||
self.print_error()
|
||||
|
||||
def process(self, command):
|
||||
""" Processes execution. """
|
||||
output = subprocess.call(command, shell=True,
|
||||
stderr=self.stderr, stdout=self.stdout)
|
||||
if output > 0:
|
||||
raise SystemExit(output)
|
||||
self.output = subprocess.call(command, shell=True,
|
||||
stderr=self.stderr, stdout=self.stdout)
|
||||
if self.output != 0:
|
||||
raise SystemExit(self.output)
|
||||
|
||||
def print_error(self):
|
||||
""" Stop the process and print the error message. """
|
||||
if self.output != 0:
|
||||
raise SystemExit(f"\n{self.red}FAILED {self.output}:{self.endc} {self.process_message}.\n")
|
||||
|
|
|
@ -91,7 +91,7 @@ class ViewMessage:
|
|||
print(f'{self.bold}{self.green}{self.llc}' + f'{self.hl}' * (self.columns - 2) + f'{self.lrc}{self.endc}')
|
||||
|
||||
def view_skipping_packages(self, sbo, version):
|
||||
print(f'[ {self.yellow}Skipping{self.endc} ] {sbo}-{version} {self.red}(already installed){self.endc}')
|
||||
print(f'[{self.yellow}Skipping{self.endc}] {sbo}-{version} {self.red}(already installed){self.endc}')
|
||||
|
||||
def build_packages(self, slackbuilds: list, dependencies: list):
|
||||
""" View packages for build only. """
|
||||
|
@ -214,7 +214,7 @@ class ViewMessage:
|
|||
def summary(self, slackbuilds: list, dependencies: list, option: str):
|
||||
""" View the status of the packages action. """
|
||||
slackbuilds.extend(dependencies)
|
||||
install = upgrade = remove = build = 0
|
||||
install = upgrade = remove = 0
|
||||
|
||||
for sbo in slackbuilds:
|
||||
inst_ver = repo_ver = 0
|
||||
|
|
Loading…
Reference in a new issue