update source code

This commit is contained in:
Dimitris Zlatanidis 2015-02-04 01:35:48 +02:00
parent 3dcf34afdf
commit cb194c08e5
9 changed files with 48 additions and 26 deletions

View file

@ -47,7 +47,7 @@ def pkg_upgrade(repo):
# location = data[1] # location = data[1]
# size = data[2] # size = data[2]
# unsize = data[3] # unsize = data[3]
data = repo_data(PACKAGES_TXT, 2000, repo, slack_ver) data = repo_data(PACKAGES_TXT, 2000, repo)
index, toolbar_width = 0, 1000 index, toolbar_width = 0, 1000
for pkg in installed(): for pkg in installed():
index += 1 index += 1

View file

@ -31,7 +31,7 @@ from slpkg.__metadata__ import MetaData as _m
from slpkg.slack.slack_version import slack_ver from slpkg.slack.slack_version import slack_ver
def repo_data(PACKAGES_TXT, step, repo, version): def repo_data(PACKAGES_TXT, step, repo):
''' '''
Grap data packages Grap data packages
''' '''
@ -63,19 +63,19 @@ def repo_data(PACKAGES_TXT, step, repo, version):
rlocation, rlocation,
rsize, rsize,
runsize runsize
) = alien_filter(name, location, size, unsize, version) ) = alien_filter(name, location, size, unsize)
elif repo == "ktown": elif repo == "ktown":
(rname, (rname,
rlocation, rlocation,
rsize, rsize,
runsize runsize
) = ktown_filter(name, location, size, unsize, version) ) = ktown_filter(name, location, size, unsize)
elif repo == "multi": elif repo == "multi":
(rname, (rname,
rlocation, rlocation,
rsize, rsize,
runsize runsize
) = multi_filter(name, location, size, unsize, version) ) = multi_filter(name, location, size, unsize)
else: else:
rname, rlocation, rsize, runsize = name, location, size, unsize rname, rlocation, rsize, runsize = name, location, size, unsize
return [rname, rlocation, rsize, runsize] return [rname, rlocation, rsize, runsize]
@ -99,12 +99,12 @@ def rlw_filter(name, location, size, unsize):
return [fname, flocation, fsize, funsize] return [fname, flocation, fsize, funsize]
def alien_filter(name, location, size, unsize, version): def alien_filter(name, location, size, unsize):
''' '''
Filter Alien's repository data Filter Alien's repository data
''' '''
ver = slack_ver() ver = slack_ver()
if version == "current": if _m.slack_rel == "current":
ver = "current" ver = "current"
path_pkg = "pkg" path_pkg = "pkg"
if os.uname()[4] == "x86_64": if os.uname()[4] == "x86_64":
@ -119,12 +119,12 @@ def alien_filter(name, location, size, unsize, version):
return [fname, flocation, fsize, funsize] return [fname, flocation, fsize, funsize]
def ktown_filter(name, location, size, unsize, version): def ktown_filter(name, location, size, unsize):
''' '''
Filter Alien's ktown repository data Filter Alien's ktown repository data
''' '''
ver = slack_ver() ver = slack_ver()
if version == "current": if _m.slack_rel == "current":
ver = "current" ver = "current"
path_pkg = "x86" path_pkg = "x86"
if os.uname()[4] == "x86_64": if os.uname()[4] == "x86_64":
@ -139,12 +139,12 @@ def ktown_filter(name, location, size, unsize, version):
return [fname, flocation, fsize, funsize] return [fname, flocation, fsize, funsize]
def multi_filter(name, location, size, unsize, version): def multi_filter(name, location, size, unsize):
''' '''
Filter Alien's multilib repository data Filter Alien's multilib repository data
''' '''
ver = slack_ver() ver = slack_ver()
if version == "current": if _m.slack_rel == "current":
ver = "current" ver = "current"
(fname, flocation, fsize, funsize) = ([] for i in range(4)) (fname, flocation, fsize, funsize) = ([] for i in range(4))
for n, l, s, u in zip(name, location, size, unsize): for n, l, s, u in zip(name, location, size, unsize):

View file

@ -49,10 +49,10 @@ from dependency import Dependencies
class BinaryInstall(object): class BinaryInstall(object):
def __init__(self, packages, repo, version): def __init__(self, packages, repo):
self.packages = packages self.packages = packages
self.repo = repo self.repo = repo
self.version = version self.version = _m.slack_rel
self.tmp_path = _m.slpkg_tmp_packages self.tmp_path = _m.slpkg_tmp_packages
self.dwn, self.dep_dwn = [], [] self.dwn, self.dep_dwn = [], []
self.install, self.dep_install = [], [] self.install, self.dep_install = [], []
@ -114,7 +114,7 @@ class BinaryInstall(object):
print("After this process, {0} {1} of additional disk " print("After this process, {0} {1} of additional disk "
"space will be used.{2}".format(size[1], unit[1], "space will be used.{2}".format(size[1], unit[1],
_m.color['ENDC'])) _m.color['ENDC']))
print('') print("")
if Msg().answer() in ['y', 'Y']: if Msg().answer() in ['y', 'Y']:
self.install.reverse() self.install.reverse()
Download(self.tmp_path, (self.dep_dwn + self.dwn)).start() Download(self.tmp_path, (self.dep_dwn + self.dwn)).start()
@ -237,7 +237,7 @@ class BinaryInstall(object):
self.pkg_ver = [''] * len(install) self.pkg_ver = [''] * len(install)
for pkg, ver, comp in zip(install, self.pkg_ver, comp_sum): for pkg, ver, comp in zip(install, self.pkg_ver, comp_sum):
pkg_split = split_package(pkg[:-4]) pkg_split = split_package(pkg[:-4])
if find_package(pkg_split[0] + "-" + pkg_split[1], _m.pkg_path): if find_package(pkg[:-4], _m.pkg_path):
pkg_sum += 1 pkg_sum += 1
COLOR = _m.color['GREEN'] COLOR = _m.color['GREEN']
elif find_package(pkg_split[0] + "-", _m.pkg_path): elif find_package(pkg_split[0] + "-", _m.pkg_path):
@ -276,7 +276,7 @@ class BinaryInstall(object):
# location = data[1] # location = data[1]
# size = data[2] # size = data[2]
# unsize = data[3] # unsize = data[3]
data = repo_data(self.PACKAGES_TXT, self.step, self.repo, self.version) data = repo_data(self.PACKAGES_TXT, self.step, self.repo)
for pkg in packages: for pkg in packages:
for name, loc, comp, uncomp in zip(data[0], data[1], data[2], for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
data[3]): data[3]):

View file

@ -59,22 +59,21 @@ class Case(object):
def __init__(self, package): def __init__(self, package):
self.package = package self.package = package
self.release = _m.slack_rel
def sbo_install(self): def sbo_install(self):
SBoInstall(self.package).start(False) SBoInstall(self.package).start(False)
def binary_install(self, repo): def binary_install(self, repo):
BinaryInstall(self.package, repo, self.release).start(False) BinaryInstall(self.package, repo).start(False)
def sbo_upgrade(self): def sbo_upgrade(self):
SBoInstall(sbo_upgrade()).start(True) SBoInstall(sbo_upgrade()).start(True)
def slack_upgrade(self): def slack_upgrade(self):
Patches(self.release).start() Patches().start()
def binary_upgrade(self, repo): def binary_upgrade(self, repo):
BinaryInstall(pkg_upgrade(repo), repo, self.release).start(True) BinaryInstall(pkg_upgrade(repo), repo).start(True)
def main(): def main():

View file

@ -79,21 +79,33 @@ class Msg(object):
print("+" + "=" * max_len) print("+" + "=" * max_len)
def checking(self): def checking(self):
'''
Message checking
'''
sys.stdout.write("{0}Checking ...{1}".format(_m.color['GREY'], sys.stdout.write("{0}Checking ...{1}".format(_m.color['GREY'],
_m.color['ENDC'])) _m.color['ENDC']))
sys.stdout.flush() sys.stdout.flush()
def reading(self): def reading(self):
'''
Message reading
'''
sys.stdout.write("{0}Reading package lists ...{1}".format( sys.stdout.write("{0}Reading package lists ...{1}".format(
_m.color['GREY'], _m.color['ENDC'])) _m.color['GREY'], _m.color['ENDC']))
sys.stdout.flush() sys.stdout.flush()
def resolving(self): def resolving(self):
'''
Message resolving
'''
sys.stdout.write("{0}Resolving dependencies ...{1}".format( sys.stdout.write("{0}Resolving dependencies ...{1}".format(
_m.color['GREY'], _m.color['ENDC'])) _m.color['GREY'], _m.color['ENDC']))
sys.stdout.flush() sys.stdout.flush()
def done(self): def done(self):
'''
Message done
'''
sys.stdout.write("{0}Done{1}\n".format(_m.color['GREY'], sys.stdout.write("{0}Done{1}\n".format(_m.color['GREY'],
_m.color['ENDC'])) _m.color['ENDC']))
@ -107,18 +119,27 @@ class Msg(object):
return message return message
def not_found(self, if_upgrade): def not_found(self, if_upgrade):
'''
Message not found packages
'''
if if_upgrade: if if_upgrade:
print('\nNot found packages for upgrade\n') print('\nNot found packages for upgrade\n')
else: else:
print('\nNot found packages for installation\n') print('\nNot found packages for installation\n')
def upg_inst(self, if_upgrade): def upg_inst(self, if_upgrade):
'''
Message installing or upgrading
'''
if not if_upgrade: if not if_upgrade:
print("Installing:") print("Installing:")
else: else:
print("Upgrading:") print("Upgrading:")
def answer(self): def answer(self):
'''
Message answer
'''
if _m.default_answer == "y": if _m.default_answer == "y":
answer = _m.default_answer answer = _m.default_answer
else: else:

View file

@ -76,7 +76,7 @@ class BuildPackage(object):
# change permissions # change permissions
subprocess.call("chmod +x {0}.SlackBuild".format(self.prgnam), subprocess.call("chmod +x {0}.SlackBuild".format(self.prgnam),
shell=True) shell=True)
pass_var = self.pass_variable() pass_var = self._pass_variable()
if _m.sbo_build_log == "on": if _m.sbo_build_log == "on":
if os.path.isfile(self.build_logs + self.log_file): if os.path.isfile(self.build_logs + self.log_file):
os.remove(self.build_logs + self.log_file) os.remove(self.build_logs + self.log_file)
@ -102,7 +102,7 @@ class BuildPackage(object):
print("") # new line at exit print("") # new line at exit
sys.exit(0) sys.exit(0)
def pass_variable(self): def _pass_variable(self):
''' '''
Grep slpkg bash variable Grep slpkg bash variable
''' '''

View file

@ -78,8 +78,7 @@ class PackageManager(object):
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
self.not_found("Can't reinstall", self.binary, pkg) self.not_found("Can't reinstall", self.binary, pkg)
@staticmethod def _not_found(self, message, binary, pkg):
def not_found(message, binary, pkg):
if len(binary) > 1: if len(binary) > 1:
bol = eol = "" bol = eol = ""
else: else:

View file

@ -30,6 +30,9 @@ from __metadata__ import MetaData as _m
class RepoList(object): class RepoList(object):
'''
List of repositories
'''
def __init__(self): def __init__(self):
self.all_repos = { self.all_repos = {

View file

@ -48,8 +48,8 @@ from slack_version import slack_ver
class Patches(object): class Patches(object):
def __init__(self, version): def __init__(self):
self.version = version self.version = _m.slack_rel
self.patch_path = _m.slpkg_tmp_patches self.patch_path = _m.slpkg_tmp_patches
Msg().reading() Msg().reading()
if self.version == "stable": if self.version == "stable":