fix ValueError func max(), add log

This commit is contained in:
Dimitris Zlatanidis 2014-09-06 17:47:53 +03:00
parent d08bd02298
commit c35a87c0fd
6 changed files with 45 additions and 26 deletions

View file

@ -74,6 +74,11 @@ def s_user(user):
print("\nError: must have root privileges\n") print("\nError: must have root privileges\n")
sys.exit() 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): def template(max):
''' '''
Print view template Print view template

View file

@ -38,7 +38,7 @@ def build_package(script, sources, path):
log_file = ("build_{0}_log".format(prgnam)) log_file = ("build_{0}_log".format(prgnam))
log_path = ("{0}{1}/".format(path, prgnam)) log_path = ("{0}{1}/".format(path, prgnam))
log_date = time.strftime("%c") log_date = time.strftime("%c")
template = ("#" * 78 + "\n\n") template = ("#" * 79 + "\n\n")
try: try:
if os.path.isfile(log_path + log_file): if os.path.isfile(log_path + log_file):
os.remove(log_path + log_file) os.remove(log_path + log_file)
@ -60,6 +60,9 @@ def build_package(script, sources, path):
if build: if build:
print build, print build,
log.write(str(build,)) log.write(str(build,))
log.write(template)
log.write(" " * 38 + "E N D\n\n")
log.write(template)
log.close() log.close()
os.chdir(path) os.chdir(path)
except (OSError, IOError): except (OSError, IOError):

View file

@ -86,7 +86,7 @@ def pkg_remove(binary):
removed, dependencies = [], [] removed, dependencies = [], []
rmv_list, rmv_dependencies = [], [] rmv_list, rmv_dependencies = [], []
print("\nPackages with name matching [ {0}{1}{2} ]\n".format( 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: for pkg in binary:
pkgs = find_package(pkg + sp, pkg_path) pkgs = find_package(pkg + sp, pkg_path)
if pkgs: if pkgs:
@ -212,7 +212,7 @@ def pkg_list(pattern):
search = "" search = ""
index, page = 0, 50 index, page = 0, 50
for pkg in sorted(os.listdir(pkg_path)): for pkg in sorted(os.listdir(pkg_path)):
if pattern in pkg: if search in pkg:
index += 1 index += 1
print("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg)) print("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg))
if index == page: if index == page:

View file

@ -31,7 +31,7 @@ from pkg.manager import pkg_upgrade
from colors import colors from colors import colors
from messages import template from messages import template, build_FAILED
from functions import get_file from functions import get_file
from __metadata__ import tmp, pkg_path, build_path from __metadata__ import tmp, pkg_path, build_path
@ -108,7 +108,7 @@ def sbo_check():
requires.reverse() # Inverting the list brings the requires.reverse() # Inverting the list brings the
# dependencies in order to be installed. # 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 creates a new list by removing duplicate dependencies but
without spoiling the line must be installed. 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 Last and after the list is created with the correct number
of dependencies that must be installed, and add the particular of dependencies that must be installed, and add the particular
packages that need to be upgraded if they are not already on 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: for upg in upg_name:
if upg not in dependencies_list: if upg not in dependencies_list:
@ -199,7 +199,11 @@ def sbo_check():
for search in find_package(prgnam, tmp): for search in find_package(prgnam, tmp):
if "_SBo" in search: if "_SBo" in search:
binary_list.append(search) binary_list.append(search)
try:
binary = (tmp + max(binary_list)).split() binary = (tmp + max(binary_list)).split()
except ValueError:
build_FAILED(sbo_url, prgnam)
sys.exit()
pkg_upgrade(binary) pkg_upgrade(binary)
print("Complete!\n") print("Complete!\n")
if len(pkg_for_upg) > 1: if len(pkg_for_upg) > 1:
@ -213,7 +217,7 @@ def sbo_check():
pkg, upg, ver)) pkg, upg, ver))
template(78) template(78)
else: 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: else:
sys.stdout.write("Done\n") sys.stdout.write("Done\n")
print("\nNo SBo packages found\n") print("\nNo SBo packages found\n")

View file

@ -27,7 +27,7 @@ import subprocess
from colors import colors from colors import colors
from functions import get_file 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 __metadata__ import tmp, pkg_path, build_path, log_path, sp
from pkg.find import find_package from pkg.find import find_package
@ -101,7 +101,6 @@ def sbo_build(name):
sbo_pkg = ("{0}-{1}".format(pkg, version)) sbo_pkg = ("{0}-{1}".format(pkg, version))
if find_package(sbo_pkg, pkg_path): if find_package(sbo_pkg, pkg_path):
pkg_sum += 1 pkg_sum += 1
sys.stdout.write("Done\n") sys.stdout.write("Done\n")
''' '''
Tag with color green if package already installed Tag with color green if package already installed
@ -170,11 +169,15 @@ def sbo_build(name):
if not os.path.exists(build_path): if not os.path.exists(build_path):
os.mkdir(build_path) os.mkdir(build_path)
os.chdir(build_path) os.chdir(build_path)
for pkg, ver in zip(dependencies, sbo_ver): for pkg, ver, ar in zip(dependencies, sbo_ver, pkg_arch):
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)) 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_url = sbo_search_pkg(pkg)
sbo_link = sbo_slackbuild_dwn(sbo_url) sbo_link = sbo_slackbuild_dwn(sbo_url)
src_link = sbo_source_dwn(pkg).split() src_link = sbo_source_dwn(pkg).split()
@ -197,15 +200,15 @@ def sbo_build(name):
for search in find_package(prgnam, tmp): for search in find_package(prgnam, tmp):
if "_SBo" in search: if "_SBo" in search:
binary_list.append(search) binary_list.append(search)
try:
binary = (tmp + max(binary_list)).split() binary = (tmp + max(binary_list)).split()
except ValueError:
build_FAILED(sbo_url, prgnam)
sys.exit()
pkg_upgrade(binary) pkg_upgrade(binary)
print("Complete!\n") print("Complete!\n")
installs.append(pkg) installs.append(pkg)
versions.append(ver) versions.append(ver)
else:
template(78)
pkg_found(pkg, sbo_file_version)
template(78)
''' '''
Reference list only packages installed Reference list only packages installed
''' '''

View file

@ -27,7 +27,7 @@ import subprocess
from colors import colors from colors import colors
from functions import get_file 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 __metadata__ import tmp, build_path, pkg_path, slpkg_tmp, sp
from pkg.build import build_package from pkg.build import build_package
@ -141,7 +141,11 @@ def sbo_network(name):
for search in find_package(prgnam, tmp): for search in find_package(prgnam, tmp):
if "_SBo" in search: if "_SBo" in search:
binary_list.append(search) binary_list.append(search)
try:
binary = (tmp + max(binary_list)).split() binary = (tmp + max(binary_list)).split()
except ValueError:
build_failed(sbo_url, prgnam)
sys.exit()
pkg_upgrade(binary) pkg_upgrade(binary)
print("Complete!\n") print("Complete!\n")
break break