mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-30 20:34:38 +01:00
Move methods to utilities
This commit is contained in:
parent
62c358ae8a
commit
e4ac36fbe2
2 changed files with 15 additions and 15 deletions
|
@ -2,7 +2,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
|
||||||
|
@ -95,8 +94,8 @@ class Slackbuilds:
|
||||||
for sbo in self.install_order:
|
for sbo in self.install_order:
|
||||||
file = f'{sbo}{self.tar_suffix}'
|
file = f'{sbo}{self.tar_suffix}'
|
||||||
|
|
||||||
self.remove_file_if_exists(self.tmp_slpkg, file)
|
self.utils.remove_file_if_exists(self.tmp_slpkg, file)
|
||||||
self.remove_folder_if_exists(self.build_path, sbo)
|
self.utils.remove_folder_if_exists(self.build_path, sbo)
|
||||||
|
|
||||||
location = SBoQueries(sbo).location()
|
location = SBoQueries(sbo).location()
|
||||||
url = f'{self.sbo_url}/{location}/{file}'
|
url = f'{self.sbo_url}/{location}/{file}'
|
||||||
|
@ -183,15 +182,3 @@ class Slackbuilds:
|
||||||
wget.download(path, source)
|
wget.download(path, source)
|
||||||
md5sum = Md5sum(self.flags)
|
md5sum = Md5sum(self.flags)
|
||||||
md5sum.check(source, checksum, name)
|
md5sum.check(source, checksum, name)
|
||||||
|
|
||||||
def remove_file_if_exists(self, path: str, file: str):
|
|
||||||
''' Clean the the old files. '''
|
|
||||||
archive = f'{path}/{file}'
|
|
||||||
if os.path.isfile(archive):
|
|
||||||
os.remove(archive)
|
|
||||||
|
|
||||||
def remove_folder_if_exists(self, path: str, folder: str):
|
|
||||||
''' Clean the the old folders. '''
|
|
||||||
directory = f'{path}/{folder}'
|
|
||||||
if os.path.isdir(directory):
|
|
||||||
shutil.rmtree(directory)
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import shutil
|
||||||
import tarfile
|
import tarfile
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
@ -40,3 +41,15 @@ class Utilities:
|
||||||
for pkg in os.listdir(self.log_packages):
|
for pkg in os.listdir(self.log_packages):
|
||||||
if package in pkg:
|
if package in pkg:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def remove_file_if_exists(self, path: str, file: str):
|
||||||
|
''' Clean the the old files. '''
|
||||||
|
archive = f'{path}/{file}'
|
||||||
|
if os.path.isfile(archive):
|
||||||
|
os.remove(archive)
|
||||||
|
|
||||||
|
def remove_folder_if_exists(self, path: str, folder: str):
|
||||||
|
''' Clean the the old folders. '''
|
||||||
|
directory = f'{path}/{folder}'
|
||||||
|
if os.path.isdir(directory):
|
||||||
|
shutil.rmtree(directory)
|
||||||
|
|
Loading…
Add table
Reference in a new issue