Commit 207ee76a authored by onny's avatar onny
Browse files

enhanced progressbar

parent 3da8c337
......@@ -4,7 +4,10 @@ import os
from jinja2 import Environment, FileSystemLoader
import requests
import time
import progressbar
from progressbar import AnimatedMarker, Bar, BouncingBar, Counter, ETA, \
FileTransferSpeed, FormatLabel, Percentage, \
ProgressBar, ReverseBar, RotatingMarker, \
SimpleProgress, Timer, AdaptiveETA, AbsoluteETA, AdaptiveTransferSpeed
from pkg_resources import parse_version
PATH = os.path.dirname(os.path.abspath(__file__))
......@@ -14,8 +17,8 @@ TEMPLATE_ENVIRONMENT = Environment(
trim_blocks=False)
package_databases = ['/var/lib/pacman/sync/core.db',
'/var/lib/pacman/sync/community.db',
'/var/lib/pacman/sync/extra.db']
'/var/lib/pacman/sync/community.db',
'/var/lib/pacman/sync/extra.db']
def get_local_packages(package_databases):
#os.makedirs("/tmp/archlinux-anitya")
......@@ -37,23 +40,38 @@ def get_local_packages(package_databases):
def get_upstream_version(packagename):
response = requests.get('https://release-monitoring.org/api/projects/?pattern='+packagename)
for project in response.json()['projects']:
if project['name'] == packagename:
if project['version']:
return project['version'].replace('.src','')
else:
return "None"
try:
for project in response.json()['projects']:
if project['name'] == packagename:
if project['version']:
return project['version'].replace('.src','')
else:
return "None"
except:
return "None"
print("Loading local package databases ...")
packages = get_local_packages(package_databases)
def get_repo_status(packagename):
response = requests.get('https://www.archlinux.org/packages/search/json/?name='+packagename)
try:
if response.json()['results'][0]['flag_date'] == None:
return "Unknown"
else:
return "Flagged"
except:
return "Unknown"
packages = packages[8740:]
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)
print("")
print("Checking upstream versions ...")
packages_outdated = []
packages_uptodate = []
packages_notlisted = []
bar = progressbar.ProgressBar(max_value=len(packages))
widgets = ['Checking upstream versions : ', Percentage(), ' ', SimpleProgress(format='(%(value)d of %(max_value)d)'), ' ', Bar(), ' ', Timer(), ' ', AdaptiveETA()]
bar = ProgressBar(widgets=widgets, max_value=len(packages))
for idx, package in enumerate(packages):
bar.update(idx)
upstreamversion = get_upstream_version(package['name'])
......@@ -65,14 +83,34 @@ for idx, package in enumerate(packages):
packages_outdated.append(packages[idx])
else:
packages_uptodate.append(packages[idx])
bar.update(idx+1)
print("")
print("Writing template ...")
widgets = ['Checking repository status : ', Percentage(), ' ', SimpleProgress(format='(%(value)d of %(max_value)d)'), ' ', Bar(), ' ', Timer(), ' ', AdaptiveETA()]
bar = ProgressBar(widgets=widgets, max_value=len(packages_outdated))
for idx, package in enumerate(packages_outdated):
bar.update(idx)
status = get_repo_status(package['name'])
packages_outdated[idx]['status'] = status
bar.update(idx+1)
print("")
widgets = ['Writing template : ', Percentage(), ' ', SimpleProgress(format='(%(value)d of %(max_value)d)'), ' ', Bar(), ' ', Timer(), ' ', AdaptiveETA()]
bar = ProgressBar(widgets=widgets, max_value=2)
bar.update(0)
context = { 'packages_outdated' : packages_outdated,
'packages_uptodate' : packages_uptodate,
'packages_notlisted' : packages_notlisted}
html =TEMPLATE_ENVIRONMENT.get_template('template.html').render(context)
html =TEMPLATE_ENVIRONMENT.get_template('upstream.html').render(context)
os.chdir(PATH)
with open('upstream.html', 'w') as f:
f.write(html)
print("Done!")
bar.update(1)
context = { 'packages_outdated' : packages_outdated,
'packages_uptodate' : packages_uptodate,
'packages_notlisted' : packages_notlisted}
html =TEMPLATE_ENVIRONMENT.get_template('notlisted.html').render(context)
os.chdir(PATH)
with open('notlisted.html', 'w') as f:
f.write(html)
bar.update(2)
<html><head>
<title>Upstream releases - Arch Linux Upstream Tracker</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="icon" href="https://security.archlinux.org/static/favicon.ico">
<link href="upstream_files/css.css" rel="stylesheet">
<link rel="stylesheet" href="upstream_files/normalize.css" type="text/css" media="all">
<link rel="stylesheet" href="upstream_files/style.css" type="text/css" media="all">
<link href="https://security.archlinux.org/advisory/feed.atom" rel="alternate" title="Recent advisories" type="application/atom+xml">
<link rel="stylesheet" type="text/css" href="upstream_files/socialwidgets.css"></head>
<body>
<div id="archnavbar">
<div id="logo"><a href="https://archlinux.org/">overview</a></div>
<div id="archnavbarmenu">
<ul id="archnavbarlist">
<li id="anb-home"><a href="https://archlinux.org/" title="Arch news, packages, projects and more">Home</a></li>
<li id="anb-packages"><a href="https://archlinux.org/packages/" title="Arch Package Database">Packages</a></li>
<li id="anb-forums"><a href="https://bbs.archlinux.org/" title="Community forums">Forums</a></li>
<li id="anb-wiki"><a href="https://wiki.archlinux.org/" title="Community documentation">Wiki</a></li>
<li id="anb-bugs"><a href="https://bugs.archlinux.org/" title="Report and track bugs">Bugs</a></li>
<li id="anb-security"><a href="#" title="Arch Linux Security Tracker">Upstream</a></li>
<li id="anb-aur"><a href="https://aur.archlinux.org/" title="Arch Linux User Repository">AUR</a></li>
<li id="anb-download"><a href="https://archlinux.org/download/" title="Get Arch Linux">Download</a></li>
</ul>
</div>
</div>
<div class="content">
<div class="navbar">
<ul>
<li><a href="https://security.archlinux.org/">issues</a></li>
<li><a href="https://security.archlinux.org/advisory">advisories</a></li>
<li><a href="https://security.archlinux.org/todo">todo</a></li>
<li><a href="https://security.archlinux.org/login">login</a></li>
</ul>
</div>
<hr>
<h1>Packages</h1>
<div class="navbar">
<ul>
<li><b>outdated</b></li>
<li><a href="https://security.archlinux.org/issues/all">all</a></li>
</ul>
</div>
<div class="scroll-x">
<table class="styled-table full size">
<thead>
<tr>
<th>Package</th>
<th>Version</th>
<th>Upstream Version</th>
<th>Ticket</th>
</tr>
</thead>
<tbody>
{% for package in packages_outdated %}
<tr>
<td>{{ package['name'] }}</td>
<td><span class="red">{{ package['version'] }}</span></td>
<td>{{ package['upstreamversion'] }}</td>
<td>Link</td>
{% endfor %}
</tbody>
</table>
</div>
<div class="navbar">
<ul>
<li><b>uptodate</b></li>
<li><a href="https://security.archlinux.org/issues/all">all</a></li>
</ul>
</div>
<div class="scroll-x">
<table class="styled-table full size">
<thead>
<tr>
<th>Package</th>
<th>Version</th>
<th>Upstream Version</th>
<th>Ticket</th>
</tr>
</thead>
<tbody>
{% for package in packages_uptodate %}
<tr>
<td>{{ package['name'] }}</td>
<td><span class="green">{{ package['version'] }}</span></td>
<td>{{ package['upstreamversion'] }}</td>
<td>Link</td>
{% endfor %}
</tbody>
</table>
</div>
<div class="navbar">
<ul>
<li><b>notlisted</b></li>
<li><a href="https://security.archlinux.org/issues/all">all</a></li>
</ul>
</div>
<div class="scroll-x">
<table class="styled-table full size">
<thead>
<tr>
<th>Package</th>
<th>Version</th>
<th>Upstream Version</th>
<th>Ticket</th>
</tr>
</thead>
<tbody>
{% for package in packages_notlisted %}
<tr>
<td>{{ package['name'] }}</td>
<td>{{ package['version'] }}</td>
<td>{{ package['upstreamversion'] }}</td>
<td>Link</td>
{% endfor %}
</tbody>
</table>
</div>
</div>
</body></html>
......@@ -24,6 +24,7 @@
</div>
</div>
<div class="content">
<!--
<div class="navbar">
<ul>
<li><a href="https://security.archlinux.org/">issues</a></li>
......@@ -33,11 +34,12 @@
</ul>
</div>
<hr>
-->
<h1>Packages</h1>
<div class="navbar">
<ul>
<li><b>outdated</b></li>
<li><a href="https://security.archlinux.org/issues/all">all</a></li>
<li><a href="notlisted.html">notlisted</a></li>
</ul>
</div>
<div class="scroll-x">
......@@ -47,119 +49,68 @@
<th>Package</th>
<th>Version</th>
<th>Upstream Version</th>
<th>Ticket</th>
<th>Status</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="navbar">
<ul>
<li><b>uptodate</b></li>
<li><a href="https://security.archlinux.org/issues/all">all</a></li>
</ul>
</div>
<div class="scroll-x">
<table class="styled-table full size">
<thead>
<tr>
<th>Package</th>
<th>Version</th>
<th>Upstream Version</th>
<th>Ticket</th>
<td><a target=new href=https://www.archlinux.org/packages/?name=systemd>systemd</a></td>
<td><span class="red">232</span></td>
<td>v233</td>
<td><span class="red">Unknown</span></td>
</tr>
</thead>
<tbody>
<tr>
<td>cksfv</td>
<td><span class="green">1.3.14</span></td>
<td>1.3.14</td>
<td>Link</td>
<tr>
<td>clalsadrv</td>
<td><span class="green">2.0.0</span></td>
<td>2.0.0</td>
<td>Link</td>
<tr>
<td>clamtk</td>
<td><span class="green">5.24</span></td>
<td>None</td>
<td>Link</td>
<tr>
<td>clamz</td>
<td><span class="green">0.5</span></td>
<td>None</td>
<td>Link</td>
</tbody>
</table>
</div>
<div class="navbar">
<ul>
<li><b>notlisted</b></li>
<li><a href="https://security.archlinux.org/issues/all">all</a></li>
</ul>
</div>
<div class="scroll-x">
<table class="styled-table full size">
<thead>
<tr>
<th>Package</th>
<th>Version</th>
<th>Upstream Version</th>
<th>Ticket</th>
<td><a target=new href=https://www.archlinux.org/packages/?name=thin-provisioning-tools>thin-provisioning-tools</a></td>
<td><span class="red">0.6.3</span></td>
<td>v0.7.0-rc2</td>
<td><span class="red">Unknown</span></td>
</tr>
</thead>
<tbody>
<tr>
<td>clanlib</td>
<td>4.0.0</td>
<td>None</td>
<td>Link</td>
<tr>
<td>clasp</td>
<td>3.2.1</td>
<td>None</td>
<td>Link</td>
<tr>
<td>classpath</td>
<td>0.99</td>
<td>None</td>
<td>Link</td>
<td><a target=new href=https://www.archlinux.org/packages/?name=wpa_supplicant>wpa_supplicant</a></td>
<td><span class="red">1:2.6</span></td>
<td>2.6</td>
<td><span class="red">Unknown</span></td>
</tr>
<tr>
<td>clearsilver</td>
<td>0.10.5</td>
<td>None</td>
<td>Link</td>
<td><a target=new href=https://www.archlinux.org/packages/?name=xfsprogs>xfsprogs</a></td>
<td><span class="red">4.9.0</span></td>
<td>4.10.0</td>
<td><span class="red">Unknown</span></td>
</tr>
<tr>
<td>clementine</td>
<td>1.3.1</td>
<td>None</td>
<td>Link</td>
<td><a target=new href=https://www.archlinux.org/packages/?name=zlib>zlib</a></td>
<td><span class="red">1:1.2.11</span></td>
<td>1.2.11</td>
<td><span class="red">Unknown</span></td>
</tr>
<tr>
<td>clewn</td>
<td>1.15</td>
<td>None</td>
<td>Link</td>
<td><a target=new href=https://www.archlinux.org/packages/?name=0ad>0ad</a></td>
<td><span class="red">a21</span></td>
<td>0.0.21</td>
<td><span class="red">Unknown</span></td>
</tr>
</tbody>
</table>
</div>
</div>
</body></html>
\ No newline at end of file
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