Commit 951bdaf3 authored by Miquel Torres's avatar Miquel Torres
Browse files

Make flake8 happy

parent 2acc10d4
......@@ -6,73 +6,67 @@ from codespeed.models import (Project, Revision, Executable, Benchmark, Branch,
from django.contrib import admin
@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
list_display = ('name', 'repo_type', 'repo_path', 'track')
admin.site.register(Project, ProjectAdmin)
@admin.register(Branch)
class BranchAdmin(admin.ModelAdmin):
list_display = ('name', 'project')
list_filter = ('project',)
admin.site.register(Branch, BranchAdmin)
@admin.register(Revision)
class RevisionAdmin(admin.ModelAdmin):
list_display = ('commitid', 'branch', 'tag', 'date')
list_filter = ('branch__project', 'branch', 'tag', 'date')
search_fields = ('commitid', 'tag')
admin.site.register(Revision, RevisionAdmin)
@admin.register(Executable)
class ExecutableAdmin(admin.ModelAdmin):
list_display = ('name', 'description', 'id', 'project')
list_filter = ('project',)
ordering = ['name']
search_fields = ('name', 'description', 'project__name')
admin.site.register(Executable, ExecutableAdmin)
@admin.register(Benchmark)
class BenchmarkAdmin(admin.ModelAdmin):
list_display = ('name', 'benchmark_type', 'data_type', 'description',
'units_title', 'units', 'lessisbetter',
'default_on_comparison')
list_filter = ('data_type','lessisbetter')
list_filter = ('data_type', 'lessisbetter')
ordering = ['name']
search_fields = ('name', 'description')
admin.site.register(Benchmark, BenchmarkAdmin)
@admin.register(Environment)
class EnvironmentAdmin(admin.ModelAdmin):
list_display = ('name', 'cpu', 'memory', 'os', 'kernel')
ordering = ['name']
search_fields = ('name', 'cpu', 'memory', 'os', 'kernel')
admin.site.register(Environment, EnvironmentAdmin)
@admin.register(Result)
class ResultAdmin(admin.ModelAdmin):
list_display = ('revision', 'benchmark', 'executable', 'environment',
'value', 'date')
list_filter = ('environment', 'executable', 'date', 'benchmark')
admin.site.register(Result, ResultAdmin)
def recalculate_report(modeladmin, request, queryset):
for report in queryset:
report.save()
recalculate_report.short_description = "Recalculate reports"
@admin.register(Report)
class ReportAdmin(admin.ModelAdmin):
list_display = ('revision', 'summary', 'colorcode')
list_filter = ('environment', 'executable')
ordering = ['-revision']
actions = [recalculate_report]
admin.site.register(Report, ReportAdmin)
from .logs import get_logs
from .logs import get_logs # noqa
......@@ -69,23 +69,29 @@ def getlogs(endrev, startrev):
tag = ""
cmd = ["git", "describe", "--tags", commit_id]
Popen(cmd, stdout=PIPE, stderr=PIPE, cwd=working_copy)
proc = Popen(cmd, stdout=PIPE, stderr=PIPE, cwd=working_copy)
try:
stdout, stderr = p.communicate()
stdout, stderr = proc.communicate()
except ValueError:
stdout = b''
stderr = b''
if p.returncode == 0:
if proc.returncode == 0:
tag = stdout
date = datetime.datetime.fromtimestamp(
int(date_t)).strftime("%Y-%m-%d %H:%M:%S")
logs.append({'date': date, 'message': subject, 'commitid': commit_id,
'author': author_name, 'author_email': author_email,
'body': body, 'short_commit_id': short_commit_id,
'tag': tag})
logs.append({
'date': date,
'message': subject,
'commitid': commit_id,
'author': author_name,
'author_email': author_email,
'body': body,
'short_commit_id': short_commit_id,
'tag': tag
})
return logs
......@@ -19,7 +19,7 @@ def updaterepo(project, update=True):
return
p = Popen(['hg', 'pull', '-u'], stdout=PIPE, stderr=PIPE,
cwd=project.working_copy)
cwd=project.working_copy)
stdout, stderr = p.communicate()
if p.returncode != 0 or stderr:
......@@ -32,7 +32,7 @@ def updaterepo(project, update=True):
cmd = ['hg', 'clone', project.repo_path, project.repo_name]
p = Popen(cmd, stdout=PIPE, stderr=PIPE,
cwd=settings.REPOSITORY_BASE_PATH)
cwd=settings.REPOSITORY_BASE_PATH)
logger.debug('Cloning Mercurial repo {0} for project {1}'.format(
project.repo_path, project))
stdout, stderr = p.communicate()
......@@ -48,9 +48,13 @@ def updaterepo(project, update=True):
def getlogs(endrev, startrev):
updaterepo(endrev.branch.project, update=False)
cmd = ["hg", "log",
"-r", "%s::%s" % (startrev.commitid, endrev.commitid),
"--template", "{rev}:{node|short}\n{node}\n{author|user}\n{author|email}\n{date}\n{tags}\n{desc}\n=newlog=\n"]
cmd = [
"hg", "log",
"-r", "%s::%s" % (startrev.commitid, endrev.commitid),
"--template",
("{rev}:{node|short}\n{node}\n{author|user}\n{author|email}"
"\n{date}\n{tags}\n{desc}\n=newlog=\n")
]
working_copy = endrev.branch.project.working_copy
p = Popen(cmd, stdout=PIPE, stderr=PIPE, cwd=working_copy)
......@@ -66,8 +70,8 @@ def getlogs(endrev, startrev):
elements = log.split('\n')[:-1]
if len(elements) < 7:
# "Malformed" log
logs.append(
{'date': '-', 'message': 'error parsing log', 'commitid': '-'})
logs.append({
'date': '-', 'message': 'error parsing log', 'commitid': '-'})
else:
short_commit_id = elements.pop(0)
commit_id = elements.pop(0)
......@@ -81,13 +85,19 @@ def getlogs(endrev, startrev):
# Parse date
date = date.split('-')[0]
date = datetime.datetime.fromtimestamp(float(date)).strftime("%Y-%m-%d %H:%M:%S")
date = datetime.datetime.fromtimestamp(
float(date)).strftime("%Y-%m-%d %H:%M:%S")
# Add changeset info
logs.append({
'date': date, 'author': author_name,
'author_email': author_email, 'message': message,
'short_commit_id': short_commit_id, 'commitid': commit_id, 'tag': tag})
'date': date,
'author': author_name,
'author_email': author_email,
'message': message,
'short_commit_id': short_commit_id,
'commitid': commit_id,
'tag': tag
})
# Remove last log here because mercurial saves the short hast as commitid now
if len(logs) > 1 and logs[-1].get('short_commit_id') == startrev.commitid:
logs.pop()
......
# -*- coding: utf-8 -*-
"""Subversion commit logs support"""
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from datetime import datetime
......@@ -32,7 +31,9 @@ def getlogs(newrev, startrev):
loglimit = 200
def get_login(realm, username, may_save):
return True, newrev.branch.project.repo_user, newrev.branch.project.repo_pass, False
repo_user = newrev.branch.project.repo_user
repo_pass = newrev.branch.project.repo_pass
return True, repo_user, repo_pass, False
client = pysvn.Client()
if newrev.branch.project.repo_user != "":
......@@ -43,7 +44,7 @@ def getlogs(newrev, startrev):
client.log(
newrev.branch.project.repo_path,
revision_start=pysvn.Revision(
pysvn.opt_revision_kind.number, startrev.commitid
pysvn.opt_revision_kind.number, startrev.commitid
),
revision_end=pysvn.Revision(
pysvn.opt_revision_kind.number, newrev.commitid
......
......@@ -108,7 +108,8 @@ class TestAddResult(TestCase):
response = self.client.post(self.path, self.data)
self.assertEquals(response.status_code, 400)
self.assertEquals(
response.content.decode(), 'Value for key "' + key + '" empty in request')
response.content.decode(),
'Value for key "' + key + '" empty in request')
self.data[key] = backup
def test_missing_argument(self):
......@@ -119,7 +120,8 @@ class TestAddResult(TestCase):
response = self.client.post(self.path, self.data)
self.assertEquals(response.status_code, 400)
self.assertEquals(
response.content.decode(), 'Key "' + key + '" missing from request')
response.content.decode(),
'Key "' + key + '" missing from request')
self.data[key] = backup
def test_report_is_not_created(self):
......@@ -156,7 +158,8 @@ class TestAddResult(TestCase):
modified_data['executable'] = "My new executable"
response = self.client.post(self.path, modified_data)
self.assertEquals(response.status_code, 202)
self.assertEquals(response.content.decode(), "Result data saved successfully")
self.assertEquals(
response.content.decode(), "Result data saved successfully")
class TestAddJSONResults(TestCase):
......@@ -266,7 +269,8 @@ class TestAddJSONResults(TestCase):
{'json': json.dumps(self.data)})
self.assertEquals(response.status_code, 400)
self.assertEquals(response.content.decode(), "Environment " + bad_name + " not found")
self.assertEquals(
response.content.decode(), "Environment " + bad_name + " not found")
data['environment'] = 'bigdog'
def test_empty_argument(self):
......@@ -278,7 +282,9 @@ class TestAddJSONResults(TestCase):
response = self.client.post(self.path,
{'json': json.dumps(self.data)})
self.assertEquals(response.status_code, 400)
self.assertEquals(response.content.decode(), 'Value for key "' + key + '" empty in request')
self.assertEquals(
response.content.decode(),
'Value for key "' + key + '" empty in request')
data[key] = backup
def test_missing_argument(self):
......@@ -290,7 +296,8 @@ class TestAddJSONResults(TestCase):
response = self.client.post(self.path,
{'json': json.dumps(self.data)})
self.assertEquals(response.status_code, 400)
self.assertEquals(response.content.decode(), 'Key "' + key + '" missing from request')
self.assertEquals(
response.content.decode(), 'Key "' + key + '" missing from request')
data[key] = backup
def test_report_is_created(self):
......
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