feature added view version

This commit is contained in:
Dimitris Zlatanidis 2015-05-17 00:59:06 +03:00
parent 95f475acb2
commit 1e17a6b2d7
3 changed files with 26 additions and 3 deletions

View file

@ -227,6 +227,16 @@ class BinaryInstall(object):
if not self.if_upgrade:
self.pkg_ver = [''] * len(packages)
def package_ver(self, package):
'''
Return package version if package already installed
'''
name = "-".join(package[:-4].split("-")[:-3]) + "-"
pkg = "".join(find_package(name, _m.pkg_path)[0])
if pkg:
return split_package(pkg)[1]
return ""
def views(self, install, comp_sum, is_deps):
'''
Views packages
@ -240,9 +250,11 @@ class BinaryInstall(object):
for pkg, ver, comp in zip(install, self.pkg_ver, comp_sum):
pkg_split = split_package(pkg[:-4])
if find_package(pkg[:-4], _m.pkg_path):
ver = '-' + self.package_ver(pkg)
pkg_sum += 1
COLOR = _m.color['GREEN']
elif find_package(pkg_split[0] + "-", _m.pkg_path):
ver = '-' + self.package_ver(pkg)
COLOR = _m.color['YELLOW']
upg_sum += 1
else:

View file

@ -230,7 +230,7 @@ class SBoInstall(object):
def package_ver(self, sbo):
'''
Return package version if package exist
Return package version if package already installed
'''
pkg = "".join(find_package(sbo.split("-")[0] + "-", _m.pkg_path))
if pkg:

View file

@ -145,6 +145,16 @@ class Patches(object):
self.count_added += 1
self.count_upg -= 1
def package_ver(self, package):
'''
Return package version if package already installed
'''
name = "-".join(package[:-4].split("-")[:-3]) + "-"
pkg = "".join(find_package(name, _m.pkg_path)[0])
if pkg:
return split_package(pkg)[1]
return ""
def views(self):
'''
Views packages
@ -152,11 +162,12 @@ class Patches(object):
for upg, size in sorted(zip(self.upgrade_all, self.comp_sum)):
pkg_split = split_package(upg[:-4])
color = _m.color['YELLOW']
ver = "-" + self.package_ver(upg)
if not find_package(pkg_split[0], _m.pkg_path):
color = _m.color['RED']
print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>12}{12}".format(
color, pkg_split[0], _m.color['ENDC'],
" " * (24-len(pkg_split[0])), pkg_split[1],
color, pkg_split[0] + ver, _m.color['ENDC'],
" " * (24-len(pkg_split[0] + ver)), pkg_split[1],
" " * (18-len(pkg_split[1])), pkg_split[2],
" " * (8-len(pkg_split[2])), pkg_split[3],
" " * (7-len(pkg_split[3])), "Slack",