Commit eda7ca80 authored by onny's avatar onny
Browse files

added config.json and download ability

parent 3aee38f6
{
"temp_directory": "/tmp/arch-upstream",
"database_sources": [
"http://mirror.23media.de/archlinux/core/os/x86_64/core.db",
"http://mirror.23media.de/archlinux/extra/os/x86_64/extra.db",
"http://mirror.23media.de/archlinux/community/os/x86_64/community.db"
]
}
File added
......@@ -10,6 +10,9 @@ from progressbar import AnimatedMarker, Bar, BouncingBar, Counter, ETA, \
SimpleProgress, Timer, AdaptiveETA, AbsoluteETA, AdaptiveTransferSpeed
from pkg_resources import parse_version
import itertools
from clint.textui import progress
import json
import datetime
PATH = os.path.dirname(os.path.abspath(__file__))
TEMPLATE_ENVIRONMENT = Environment(
......@@ -17,15 +20,17 @@ TEMPLATE_ENVIRONMENT = Environment(
loader=FileSystemLoader(os.path.join(PATH, 'templates')),
trim_blocks=False)
package_databases = ['/var/lib/pacman/sync/core.db',
'/var/lib/pacman/sync/community.db',
'/var/lib/pacman/sync/extra.db']
def load_config(config):
data = []
with open(config) as json_data:
data =json.load(json_data)
os.makedirs(data['temp_directory'], exist_ok=True)
return data
def load_database(package_database):
#os.makedirs("/tmp/archlinux-anitya")
os.chdir("/tmp/archlinux-anitya")
pkglist = []
tar = tarfile.open(database, "r:gz")
tar = tarfile.open(database, "r:tar")
tar.extractall()
for entry in tar.getmembers():
if entry.isfile() and "desc" in entry.name:
......@@ -66,6 +71,28 @@ def get_repo_status(packagename):
except:
return "Unknown"
package_databases = []
config = load_config('config/config.json')
for link in config['database_sources']:
local_filename = config['temp_directory'] + "/" + os.path.split(link)[1]
package_databases.append(local_filename)
r = requests.get(link, stream=True)
f = open(local_filename, 'wb')
file_size = int(r.headers['Content-Length'])
chunk = 1
num_bars = file_size / chunk
widgets = ['Downloading databases : ', Percentage(), ' ', SimpleProgress(format='(%(value)d of %(max_value)d)'), ' ', Bar(), ' ', Timer(), ' ', AdaptiveETA()]
bar = ProgressBar(widgets=widgets, maxval=num_bars).start()
i = 0
for chunk in r.iter_content():
f.write(chunk)
bar.update(i)
i+=1
f.close()
print("")
widgets = ['Loading local database : ', Percentage(), ' ', SimpleProgress(format='(%(value)d of %(max_value)d)'), ' ', Bar(), ' ', Timer(), ' ', AdaptiveETA()]
bar = ProgressBar(widgets=widgets, max_value=len(package_databases))
packages = []
......@@ -109,7 +136,8 @@ bar = ProgressBar(widgets=widgets, max_value=2)
bar.update(0)
context = { 'packages_outdated' : packages_outdated,
'packages_uptodate' : packages_uptodate,
'packages_notlisted' : packages_notlisted}
'packages_notlisted' : packages_notlisted,
'date' : datetime.datetime.now().strftime("%y/%m/%d %H:%M")}
html =TEMPLATE_ENVIRONMENT.get_template('upstream.html').render(context)
os.chdir(PATH)
with open('upstream.html', 'w') as f:
......@@ -117,7 +145,8 @@ with open('upstream.html', 'w') as f:
bar.update(1)
context = { 'packages_outdated' : packages_outdated,
'packages_uptodate' : packages_uptodate,
'packages_notlisted' : packages_notlisted}
'packages_notlisted' : packages_notlisted,
'date' : datetime.datetime.now().strftime("%y/%m/%d %H:%M")}
html =TEMPLATE_ENVIRONMENT.get_template('notlisted.html').render(context)
os.chdir(PATH)
with open('notlisted.html', 'w') as f:
......
<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><a href="upstream.html">outdated</a></li>
<li><b>notlisted</b></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>Status</th>
</tr>
</thead>
<tbody>
{% for package in packages_notlisted %}
<tr>
<td><a target=new href=https://www.archlinux.org/packages/?name={{ package['name'] }}>{{ package['name'] }}</a></td>
<td>{{ package['version'] }}</td>
<td>{{ package['upstreamversion'] }}</td>
<td>Unknown</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<i>{{ packages_notlisted|count }} packages outdated. Page last updated: {{ date }} UTC</i>
</div>
</body></html>
......@@ -53,54 +53,28 @@
</tr>
</thead>
<tbody>
{% for package in packages_outdated %}
<tr>
<td><a target=new href=https://www.archlinux.org/packages/?name=btrfs-progs>btrfs-progs</a></td>
<td><span class="red">4.9.1</span></td>
<td>4.10</td>
<td><span class="light_orange">Testing</span></td>
<td><a target=new href=https://www.archlinux.org/packages/?name={{ package['name'] }}>{{ package['name'] }}</a></td>
<td><span class="red">{{ package['version'] }}</span></td>
<td>{{ package['upstreamversion'] }}</td>
{% if package['status'] == "Unknown" %}
<td><span class="red">{{ package['status'] }}</span></td>
{% endif %}
{% if package['status'] == "Testing" %}
<td><span class="light_orange">{{ package['status'] }}</span></td>
{% endif %}
{% if package['status'] == "Flagged" %}
<td><span class="orange">{{ package['status'] }}</span></td>
{% endif %}
</tr>
<tr>
<td><a target=new href=https://www.archlinux.org/packages/?name=ca-certificates>ca-certificates</a></td>
<td><span class="red">20160507</span></td>
<td>20161130</td>
<td><span class="light_orange">Testing</span></td>
</tr>
<tr>
<td><a target=new href=https://www.archlinux.org/packages/?name=coreutils>coreutils</a></td>
<td><span class="red">8.26</span></td>
<td>8.27</td>
<td><span class="orange">Flagged</span></td>
</tr>
<tr>
<td><a target=new href=https://www.archlinux.org/packages/?name=cracklib>cracklib</a></td>
<td><span class="red">2.9.6</span></td>
<td>3.0pre2</td>
<td><span class="red">Unknown</span></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<i>{{ packages_outdated|count }} packages outdated. Page last updated: {{ date }} UTC</i>
</div>
</body></html>
\ No newline at end of file
</body></html>
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