mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-17 06:11:35 +01:00
fix ValueError func max(), add log
This commit is contained in:
parent
d08bd02298
commit
c35a87c0fd
6 changed files with 45 additions and 26 deletions
|
@ -74,6 +74,11 @@ def s_user(user):
|
|||
print("\nError: must have root privileges\n")
|
||||
sys.exit()
|
||||
|
||||
def build_FAILED(sbo_url, prgnam):
|
||||
print("\n{0}FAILED{1} to build the package {2}".format(colors.RED, colors.ENDC, prgnam))
|
||||
print("See log file in slpkg_Build directory or read README file:")
|
||||
print("{0}{1}\n".format(sbo_url, "README"))
|
||||
|
||||
def template(max):
|
||||
'''
|
||||
Print view template
|
||||
|
|
|
@ -38,7 +38,7 @@ def build_package(script, sources, path):
|
|||
log_file = ("build_{0}_log".format(prgnam))
|
||||
log_path = ("{0}{1}/".format(path, prgnam))
|
||||
log_date = time.strftime("%c")
|
||||
template = ("#" * 78 + "\n\n")
|
||||
template = ("#" * 79 + "\n\n")
|
||||
try:
|
||||
if os.path.isfile(log_path + log_file):
|
||||
os.remove(log_path + log_file)
|
||||
|
@ -60,6 +60,9 @@ def build_package(script, sources, path):
|
|||
if build:
|
||||
print build,
|
||||
log.write(str(build,))
|
||||
log.write(template)
|
||||
log.write(" " * 38 + "E N D\n\n")
|
||||
log.write(template)
|
||||
log.close()
|
||||
os.chdir(path)
|
||||
except (OSError, IOError):
|
||||
|
|
|
@ -53,7 +53,7 @@ def pkg_upgrade(binary):
|
|||
for pkg in binary:
|
||||
try:
|
||||
print subprocess.check_output("upgradepkg --install-new {0}".format(pkg),
|
||||
shell=True)
|
||||
shell=True)
|
||||
except subprocess.CalledProcessError:
|
||||
message = "Can't upgrade"
|
||||
if len(binary) > 1:
|
||||
|
@ -69,7 +69,7 @@ def pkg_reinstall(binary):
|
|||
for pkg in binary:
|
||||
try:
|
||||
print subprocess.check_output("upgradepkg --reinstall {0}".format(pkg),
|
||||
shell=True)
|
||||
shell=True)
|
||||
except subprocess.CalledProcessError:
|
||||
message = "Can't reinstall"
|
||||
if len(binary) > 1:
|
||||
|
@ -86,7 +86,7 @@ def pkg_remove(binary):
|
|||
removed, dependencies = [], []
|
||||
rmv_list, rmv_dependencies = [], []
|
||||
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
|
||||
colors.CYAN, ', '.join(binary), colors.ENDC))
|
||||
colors.CYAN, ", ".join(binary), colors.ENDC))
|
||||
for pkg in binary:
|
||||
pkgs = find_package(pkg + sp, pkg_path)
|
||||
if pkgs:
|
||||
|
@ -175,7 +175,7 @@ def pkg_find(binary):
|
|||
for pkg in binary:
|
||||
if find_package(pkg + sp, pkg_path):
|
||||
print(colors.GREEN + "[ installed ] - " + colors.ENDC + "\n ".join(
|
||||
find_package(pkg + sp, pkg_path)))
|
||||
find_package(pkg + sp, pkg_path)))
|
||||
else:
|
||||
message = "Can't find"
|
||||
pkg_not_found("", pkg, message, "")
|
||||
|
@ -212,12 +212,12 @@ def pkg_list(pattern):
|
|||
search = ""
|
||||
index, page = 0, 50
|
||||
for pkg in sorted(os.listdir(pkg_path)):
|
||||
if pattern in pkg:
|
||||
if search in pkg:
|
||||
index += 1
|
||||
print("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg))
|
||||
if index == page:
|
||||
key = raw_input("\nPress [ {0}Enter{1} ] >> Next page ".format(
|
||||
colors.CYAN, colors.ENDC))
|
||||
colors.CYAN, colors.ENDC))
|
||||
page += 50
|
||||
print # new line at end
|
||||
except KeyboardInterrupt:
|
||||
|
|
|
@ -31,7 +31,7 @@ from pkg.manager import pkg_upgrade
|
|||
|
||||
|
||||
from colors import colors
|
||||
from messages import template
|
||||
from messages import template, build_FAILED
|
||||
from functions import get_file
|
||||
from __metadata__ import tmp, pkg_path, build_path
|
||||
|
||||
|
@ -108,7 +108,7 @@ def sbo_check():
|
|||
requires.reverse() # Inverting the list brings the
|
||||
# dependencies in order to be installed.
|
||||
'''
|
||||
Because many packages use the same dependencies, in this loop
|
||||
Many packages use the same dependencies, in this loop
|
||||
creates a new list by removing duplicate dependencies but
|
||||
without spoiling the line must be installed.
|
||||
'''
|
||||
|
@ -119,7 +119,7 @@ def sbo_check():
|
|||
Last and after the list is created with the correct number
|
||||
of dependencies that must be installed, and add the particular
|
||||
packages that need to be upgraded if they are not already on
|
||||
the list.
|
||||
the list in end to list.
|
||||
'''
|
||||
for upg in upg_name:
|
||||
if upg not in dependencies_list:
|
||||
|
@ -199,7 +199,11 @@ def sbo_check():
|
|||
for search in find_package(prgnam, tmp):
|
||||
if "_SBo" in search:
|
||||
binary_list.append(search)
|
||||
binary = (tmp + max(binary_list)).split()
|
||||
try:
|
||||
binary = (tmp + max(binary_list)).split()
|
||||
except ValueError:
|
||||
build_FAILED(sbo_url, prgnam)
|
||||
sys.exit()
|
||||
pkg_upgrade(binary)
|
||||
print("Complete!\n")
|
||||
if len(pkg_for_upg) > 1:
|
||||
|
@ -213,7 +217,7 @@ def sbo_check():
|
|||
pkg, upg, ver))
|
||||
template(78)
|
||||
else:
|
||||
print("\nTotal {0} SBo packages are up to date:\n".format(len(sbo_list)))
|
||||
print("\nTotal {0} SBo packages are up to date\n".format(len(sbo_list)))
|
||||
else:
|
||||
sys.stdout.write("Done\n")
|
||||
print("\nNo SBo packages found\n")
|
||||
|
|
|
@ -27,7 +27,7 @@ import subprocess
|
|||
|
||||
from colors import colors
|
||||
from functions import get_file
|
||||
from messages import pkg_not_found, pkg_found, template
|
||||
from messages import pkg_not_found, pkg_found, template, build_FAILED
|
||||
from __metadata__ import tmp, pkg_path, build_path, log_path, sp
|
||||
|
||||
from pkg.find import find_package
|
||||
|
@ -101,7 +101,6 @@ def sbo_build(name):
|
|||
sbo_pkg = ("{0}-{1}".format(pkg, version))
|
||||
if find_package(sbo_pkg, pkg_path):
|
||||
pkg_sum += 1
|
||||
|
||||
sys.stdout.write("Done\n")
|
||||
'''
|
||||
Tag with color green if package already installed
|
||||
|
@ -170,11 +169,15 @@ def sbo_build(name):
|
|||
if not os.path.exists(build_path):
|
||||
os.mkdir(build_path)
|
||||
os.chdir(build_path)
|
||||
for pkg, ver in zip(dependencies, sbo_ver):
|
||||
sbo_file = "".join(find_package(pkg, pkg_path))
|
||||
sbo_file_version = sbo_file[len(pkg) + 1:-len(arch) - 7]
|
||||
if ver > sbo_file_version:
|
||||
prgnam = ("{0}-{1}".format(pkg, ver))
|
||||
for pkg, ver, ar in zip(dependencies, sbo_ver, pkg_arch):
|
||||
prgnam = ("{0}-{1}".format(pkg, ver))
|
||||
sbo_file = "".join(find_package(prgnam, pkg_path))
|
||||
if sbo_file:
|
||||
sbo_file_version = sbo_file[len(pkg) + 1:-len(ar) - 7]
|
||||
template(78)
|
||||
pkg_found(pkg, sbo_file_version)
|
||||
template(78)
|
||||
else:
|
||||
sbo_url = sbo_search_pkg(pkg)
|
||||
sbo_link = sbo_slackbuild_dwn(sbo_url)
|
||||
src_link = sbo_source_dwn(pkg).split()
|
||||
|
@ -197,15 +200,15 @@ def sbo_build(name):
|
|||
for search in find_package(prgnam, tmp):
|
||||
if "_SBo" in search:
|
||||
binary_list.append(search)
|
||||
binary = (tmp + max(binary_list)).split()
|
||||
try:
|
||||
binary = (tmp + max(binary_list)).split()
|
||||
except ValueError:
|
||||
build_FAILED(sbo_url, prgnam)
|
||||
sys.exit()
|
||||
pkg_upgrade(binary)
|
||||
print("Complete!\n")
|
||||
installs.append(pkg)
|
||||
versions.append(ver)
|
||||
else:
|
||||
template(78)
|
||||
pkg_found(pkg, sbo_file_version)
|
||||
template(78)
|
||||
'''
|
||||
Reference list only packages installed
|
||||
'''
|
||||
|
|
|
@ -27,7 +27,7 @@ import subprocess
|
|||
|
||||
from colors import colors
|
||||
from functions import get_file
|
||||
from messages import pkg_not_found, pkg_found, view_sbo, template
|
||||
from messages import pkg_not_found, pkg_found, view_sbo, template, build_FAILED
|
||||
from __metadata__ import tmp, build_path, pkg_path, slpkg_tmp, sp
|
||||
|
||||
from pkg.build import build_package
|
||||
|
@ -141,7 +141,11 @@ def sbo_network(name):
|
|||
for search in find_package(prgnam, tmp):
|
||||
if "_SBo" in search:
|
||||
binary_list.append(search)
|
||||
binary = (tmp + max(binary_list)).split()
|
||||
try:
|
||||
binary = (tmp + max(binary_list)).split()
|
||||
except ValueError:
|
||||
build_failed(sbo_url, prgnam)
|
||||
sys.exit()
|
||||
pkg_upgrade(binary)
|
||||
print("Complete!\n")
|
||||
break
|
||||
|
|
Loading…
Reference in a new issue