Merge branch 'master' of https://github.com/iksaif/euscan
Conflicts: euscanwww/djeuscan/processing/scan/scan_portage.py Signed-off-by: volpino <fox91@anche.no>
@ -88,9 +88,12 @@ class Package(models.Model):
|
||||
class Meta:
|
||||
unique_together = ['category', 'name']
|
||||
|
||||
def __unicode__(self):
|
||||
def cp(self):
|
||||
return '%s/%s' % (self.category, self.name)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.cp()
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.full_clean()
|
||||
|
||||
@ -137,10 +140,17 @@ class Version(models.Model):
|
||||
class Meta:
|
||||
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):
|
||||
return '%s/%s-%s-%s:%s [%s]' % (
|
||||
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):
|
||||
|
@ -160,6 +160,7 @@ class ScanMetadata(object):
|
||||
maintainer = self.store_maintainer(
|
||||
maintainer_name, maintainer_email
|
||||
)
|
||||
|
||||
herd.maintainers.add(maintainer)
|
||||
|
||||
|
||||
@ -169,7 +170,7 @@ def scan_metadata(packages=None, category=None, logger=None, populate=False):
|
||||
|
||||
if category:
|
||||
packages = Package.objects.filter(category=category)
|
||||
elif not packages:
|
||||
elif packages == None:
|
||||
packages = Package.objects.all()
|
||||
|
||||
if populate:
|
||||
|
@ -31,8 +31,11 @@ class ScanUpstream(object):
|
||||
ebuild = out[package]["metadata"]["ebuild"]
|
||||
except KeyError:
|
||||
self.logger.error(
|
||||
"Error while scanning upstream for package %s!\n%s",
|
||||
package,
|
||||
"Error while scanning upstream for package %s!",
|
||||
package
|
||||
)
|
||||
self.logger.debug(
|
||||
"Error %s",
|
||||
out_json
|
||||
)
|
||||
return {}
|
||||
|
@ -158,6 +158,7 @@ def update_portage_trees():
|
||||
@task
|
||||
def update_portage(packages=None):
|
||||
update_portage_trees()
|
||||
scan_metadata(packages=None, populate=True)
|
||||
(
|
||||
group_one(scan_portage, portage.settings.categories,
|
||||
attr_name="category", purge_packages=True,
|
||||
|
@ -132,6 +132,7 @@
|
||||
{% endif %}
|
||||
|
||||
{{ version.version }} - {{ version.urls }}
|
||||
{% if confidence < 100 %}({{ version.confidence }}%){% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
@ -168,9 +169,7 @@
|
||||
<dt>euscan log</dt>
|
||||
<dd>
|
||||
<p>Date: {{ log.datetime }}
|
||||
<pre class="log">
|
||||
{{ log.result|ansi_to_html|safe }}
|
||||
</pre>
|
||||
<pre class="log">{{ msg|ansi_to_html|safe }}</pre>
|
||||
</dd>
|
||||
{% endif %}
|
||||
</dl>
|
||||
|
@ -3,8 +3,6 @@ from django.conf import settings
|
||||
|
||||
from euscan.version import is_version_type_stable, get_version_type
|
||||
|
||||
from djeuscan.utils import plaintext2html
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@ -73,4 +71,6 @@ def version_type(version):
|
||||
|
||||
@register.filter
|
||||
def ansi_to_html(text):
|
||||
return plaintext2html(text)
|
||||
from ansi2html import Ansi2HTMLConverter
|
||||
conv = Ansi2HTMLConverter(inline=True, linkify=True)
|
||||
return conv.convert(text, full=False)
|
||||
|
@ -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', ' ' * tabstop)
|
||||
t = t.replace(' ', ' ')
|
||||
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
|
@ -1,6 +1,7 @@
|
||||
""" Views """
|
||||
|
||||
import inspect
|
||||
import json
|
||||
from annoying.decorators import render_to, ajax_request
|
||||
|
||||
from django.http import Http404
|
||||
@ -202,6 +203,13 @@ def package(request, category, package):
|
||||
log = log[0] if log else None
|
||||
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:
|
||||
last_scan = EuscanResult.objects.for_package(package).latest().datetime
|
||||
except EuscanResult.DoesNotExist:
|
||||
@ -242,6 +250,7 @@ def package(request, category, package):
|
||||
'upstream': upstream,
|
||||
'log': log,
|
||||
'vlog': vlog,
|
||||
'msg' : msg,
|
||||
'last_scan': last_scan,
|
||||
'favourited': favourited,
|
||||
'refreshed': refreshed,
|
||||
|
@ -239,7 +239,6 @@ CELERYD_CONCURRENCY = 4
|
||||
TASKS_UPSTREAM_GROUPS = 32
|
||||
|
||||
CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"
|
||||
CELERYBEAT_SCHEDULE = {}
|
||||
|
||||
# LDAP authentication
|
||||
# TODO: Test data - change me!
|
||||
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 821 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.1 KiB |