Conflicts:
	euscanwww/djeuscan/processing/scan/scan_portage.py

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino 2012-07-24 08:15:56 +02:00
commit fd12bf1cb4
13 changed files with 34 additions and 104 deletions

View File

@ -88,9 +88,12 @@ class Package(models.Model):
class Meta: class Meta:
unique_together = ['category', 'name'] unique_together = ['category', 'name']
def __unicode__(self): def cp(self):
return '%s/%s' % (self.category, self.name) return '%s/%s' % (self.category, self.name)
def __unicode__(self):
return self.cp()
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
self.full_clean() self.full_clean()
@ -137,10 +140,17 @@ class Version(models.Model):
class Meta: class Meta:
unique_together = ['package', 'slot', 'revision', 'version', 'overlay'] unique_together = ['package', 'slot', 'revision', 'version', 'overlay']
def cpv(self):
return '%s/%s-%s-%s' % (
self.package.category, self.package.name, self.version,
self.revision if self.revision != 'r0' else ''
)
def __unicode__(self): def __unicode__(self):
return '%s/%s-%s-%s:%s [%s]' % ( return '%s/%s-%s-%s:%s [%s]' % (
self.package.category, self.package.name, self.version, self.package.category, self.package.name, self.version,
self.revision, self.slot, self.overlay or "<upstream>" self.revision if self.revision != 'r0' else '',
self.slot, self.overlay or "<upstream>"
) )
def save(self, *args, **kwargs): def save(self, *args, **kwargs):

View File

@ -160,6 +160,7 @@ class ScanMetadata(object):
maintainer = self.store_maintainer( maintainer = self.store_maintainer(
maintainer_name, maintainer_email maintainer_name, maintainer_email
) )
herd.maintainers.add(maintainer) herd.maintainers.add(maintainer)
@ -169,7 +170,7 @@ def scan_metadata(packages=None, category=None, logger=None, populate=False):
if category: if category:
packages = Package.objects.filter(category=category) packages = Package.objects.filter(category=category)
elif not packages: elif packages == None:
packages = Package.objects.all() packages = Package.objects.all()
if populate: if populate:

View File

@ -31,8 +31,11 @@ class ScanUpstream(object):
ebuild = out[package]["metadata"]["ebuild"] ebuild = out[package]["metadata"]["ebuild"]
except KeyError: except KeyError:
self.logger.error( self.logger.error(
"Error while scanning upstream for package %s!\n%s", "Error while scanning upstream for package %s!",
package, package
)
self.logger.debug(
"Error %s",
out_json out_json
) )
return {} return {}

View File

@ -158,6 +158,7 @@ def update_portage_trees():
@task @task
def update_portage(packages=None): def update_portage(packages=None):
update_portage_trees() update_portage_trees()
scan_metadata(packages=None, populate=True)
( (
group_one(scan_portage, portage.settings.categories, group_one(scan_portage, portage.settings.categories,
attr_name="category", purge_packages=True, attr_name="category", purge_packages=True,

View File

@ -132,6 +132,7 @@
{% endif %} {% endif %}
{{ version.version }} - {{ version.urls }} {{ version.version }} - {{ version.urls }}
{% if confidence < 100 %}({{ version.confidence }}%){% endif %}
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
@ -168,9 +169,7 @@
<dt>euscan log</dt> <dt>euscan log</dt>
<dd> <dd>
<p>Date: {{ log.datetime }} <p>Date: {{ log.datetime }}
<pre class="log"> <pre class="log">{{ msg|ansi_to_html|safe }}</pre>
{{ log.result|ansi_to_html|safe }}
</pre>
</dd> </dd>
{% endif %} {% endif %}
</dl> </dl>

View File

@ -3,8 +3,6 @@ from django.conf import settings
from euscan.version import is_version_type_stable, get_version_type from euscan.version import is_version_type_stable, get_version_type
from djeuscan.utils import plaintext2html
register = template.Library() register = template.Library()
@ -73,4 +71,6 @@ def version_type(version):
@register.filter @register.filter
def ansi_to_html(text): def ansi_to_html(text):
return plaintext2html(text) from ansi2html import Ansi2HTMLConverter
conv = Ansi2HTMLConverter(inline=True, linkify=True)
return conv.convert(text, full=False)

View File

@ -1,92 +0,0 @@
import re
import cgi
colorcodes = {
'bold': ('\\\u001b[01m|\\\u001b[36;01m', '\\\u001b[39;49;00m'),
'cyan': ('\\\u001b[36m', '\\\u001b[39m'),
'blue': ('\\\u001b[34m', '\\\u001b[39m'),
'red': ('\\\u001b[31m', '\\\u001b[39m'),
'magenta': ('\\\u001b[35m', '\\\u001b[39m'),
'green': ('\\\u001b[32;01m', '\\\u001b[39;49;00m'),
'underline': ('\\\u001b[4m', '\\\u001b[24m'),
}
def recolor(color, text):
regexp = r"(?:%s)(.*?)(?:%s)" % colorcodes[color]
regexp = regexp.replace('[', r'\[')
return re.sub(
regexp, r'''<span style="color: %s">\1</span>''' % color, text
)
def bold(text):
regexp = "(?:%s)(.*?)(?:%s)" % colorcodes['bold']
regexp = regexp.replace('[', r'\[')
return re.sub(regexp, r'<span style="font-weight:bold">\1</span>', text)
def underline(text):
regexp = "(?:%s)(.*?)(?:%s)" % colorcodes['underline']
regexp = regexp.replace('[', r'\[')
return re.sub(
regexp, r'<span style="text-decoration: underline">\1</span>', text
)
def removebells(text):
return text.replace('\07', '')
def removebackspaces(text):
backspace_or_eol = r'(.\010)|(\033\[K)'
n = 1
while n > 0:
text, n = re.subn(backspace_or_eol, '', text, 1)
return text
def plaintext2html(text, tabstop=4):
def do_sub(m):
c = m.groupdict()
if c['htmlchars']:
return cgi.escape(c['htmlchars'])
if c['lineend']:
return '<br>'
elif c['space']:
t = m.group().replace('\t', '&nbsp;' * tabstop)
t = t.replace(' ', '&nbsp;')
return t
elif c['space'] == '\t':
return ' ' * tabstop
else:
url = m.group('protocal')
if url.startswith(' '):
prefix = ' '
url = url[1:]
else:
prefix = ''
last = m.groups()[-1]
if last in ['\n', '\r', '\r\n']:
last = '<br/>'
return '%s%s' % (prefix, url)
re_string = re.compile(
r'(?P<htmlchars>[<&>])|(?P<space>^[ \t]+)|(?P<lineend>\r\n|\r|\n)|'
r'(?P<protocal>(^|\s)((http|ftp)://.*?))(\s|$)',
re.S | re.M | re.I
)
result = re.sub(re_string, do_sub, text)
result = re.sub(r"\\n", "<br/>", result)
result = recolor('cyan', result)
result = recolor('blue', result)
result = recolor('red', result)
result = recolor('magenta', result)
result = recolor('green', result)
result = bold(result)
result = underline(result)
result = removebells(result)
result = removebackspaces(result)
return result

View File

@ -1,6 +1,7 @@
""" Views """ """ Views """
import inspect import inspect
import json
from annoying.decorators import render_to, ajax_request from annoying.decorators import render_to, ajax_request
from django.http import Http404 from django.http import Http404
@ -202,6 +203,13 @@ def package(request, category, package):
log = log[0] if log else None log = log[0] if log else None
vlog = VersionLog.objects.for_package(package, order=True) vlog = VersionLog.objects.for_package(package, order=True)
result = json.loads(log.result) if log else None
if result and package.cp() in result:
msg = result[package.cp()]['messages']
else:
msg = ""
try: try:
last_scan = EuscanResult.objects.for_package(package).latest().datetime last_scan = EuscanResult.objects.for_package(package).latest().datetime
except EuscanResult.DoesNotExist: except EuscanResult.DoesNotExist:
@ -242,6 +250,7 @@ def package(request, category, package):
'upstream': upstream, 'upstream': upstream,
'log': log, 'log': log,
'vlog': vlog, 'vlog': vlog,
'msg' : msg,
'last_scan': last_scan, 'last_scan': last_scan,
'favourited': favourited, 'favourited': favourited,
'refreshed': refreshed, 'refreshed': refreshed,

View File

@ -239,7 +239,6 @@ CELERYD_CONCURRENCY = 4
TASKS_UPSTREAM_GROUPS = 32 TASKS_UPSTREAM_GROUPS = 32
CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler" CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"
CELERYBEAT_SCHEDULE = {}
# LDAP authentication # LDAP authentication
# TODO: Test data - change me! # TODO: Test data - change me!

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 821 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB