Commit 2653cce1 authored by onny's avatar onny
Browse files

partial loading database

parent 207ee76a
......@@ -9,6 +9,7 @@ from progressbar import AnimatedMarker, Bar, BouncingBar, Counter, ETA, \
ProgressBar, ReverseBar, RotatingMarker, \
SimpleProgress, Timer, AdaptiveETA, AbsoluteETA, AdaptiveTransferSpeed
from pkg_resources import parse_version
import itertools
PATH = os.path.dirname(os.path.abspath(__file__))
TEMPLATE_ENVIRONMENT = Environment(
......@@ -20,22 +21,21 @@ package_databases = ['/var/lib/pacman/sync/core.db',
'/var/lib/pacman/sync/community.db',
'/var/lib/pacman/sync/extra.db']
def get_local_packages(package_databases):
def load_database(package_database):
#os.makedirs("/tmp/archlinux-anitya")
os.chdir("/tmp/archlinux-anitya")
pkglist = []
for database in package_databases:
tar = tarfile.open(database, "r:gz")
tar.extractall()
for entry in tar.getmembers():
if entry.isfile() and "desc" in entry.name:
descfile = tar.extractfile(entry)
content = str(descfile.read())
pkgversion = re.search(r'%VERSION%\\n(.*?)-',content).group(1)
pkgname = re.search(r'%NAME%\\n(.*?)\\n',content).group(1)
pkglist.append({ 'name' : pkgname, 'version' : pkgversion })
descfile.close()
tar.close()
tar = tarfile.open(database, "r:gz")
tar.extractall()
for entry in tar.getmembers():
if entry.isfile() and "desc" in entry.name:
descfile = tar.extractfile(entry)
content = str(descfile.read())
pkgversion = re.search(r'%VERSION%\\n(.*?)-',content).group(1)
pkgname = re.search(r'%NAME%\\n(.*?)\\n',content).group(1)
pkglist.append({ 'name' : pkgname, 'version' : pkgversion })
descfile.close()
tar.close()
return pkglist
def get_upstream_version(packagename):
......@@ -61,10 +61,12 @@ def get_repo_status(packagename):
return "Unknown"
widgets = ['Loading local database : ', Percentage(), ' ', SimpleProgress(format='(%(value)d of %(max_value)d)'), ' ', Bar(), ' ', Timer(), ' ', AdaptiveETA()]
bar = ProgressBar(widgets=widgets, max_value=1)
bar.update(0)
packages = get_local_packages(package_databases)
bar.update(1)
bar = ProgressBar(widgets=widgets, max_value=len(package_databases))
packages = []
for idx, database in enumerate(package_databases):
bar.update(idx)
packages = sum([packages, load_database(database)], [])
bar.update(idx+1)
print("")
packages_outdated = []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment