Skip to content

Commit ad9ede1

Browse files
committed
Merge branch 'add-flake-config'
2 parents 813ac71 + 42be6f1 commit ad9ede1

40 files changed

Lines changed: 76 additions & 3236 deletions

File tree

.travis.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ language: python
22
python:
33
- 2.7
44
- 3.4
5+
branches:
6+
only:
7+
- master
58
env:
6-
- DJANGO_VERSION=1.8.8
7-
- DJANGO_VERSION=1.6.11
9+
- DJANGO_VERSION=1.8.17
10+
- DJANGO_VERSION=1.9.12
811
install:
12+
- pip install flake8
913
- pip install -q Django==$DJANGO_VERSION
1014
- python setup.py install
15+
before_script:
16+
flake8 codespeed
1117
script:
1218
- python setup.py test
1319
- python manage.py test codespeed
14-

codespeed/admin.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,73 +6,67 @@
66
from django.contrib import admin
77

88

9+
@admin.register(Project)
910
class ProjectAdmin(admin.ModelAdmin):
1011
list_display = ('name', 'repo_type', 'repo_path', 'track')
1112

12-
admin.site.register(Project, ProjectAdmin)
13-
1413

14+
@admin.register(Branch)
1515
class BranchAdmin(admin.ModelAdmin):
1616
list_display = ('name', 'project')
1717
list_filter = ('project',)
1818

19-
admin.site.register(Branch, BranchAdmin)
20-
2119

20+
@admin.register(Revision)
2221
class RevisionAdmin(admin.ModelAdmin):
2322
list_display = ('commitid', 'branch', 'tag', 'date')
2423
list_filter = ('branch__project', 'branch', 'tag', 'date')
2524
search_fields = ('commitid', 'tag')
2625

27-
admin.site.register(Revision, RevisionAdmin)
28-
2926

27+
@admin.register(Executable)
3028
class ExecutableAdmin(admin.ModelAdmin):
3129
list_display = ('name', 'description', 'id', 'project')
3230
list_filter = ('project',)
3331
ordering = ['name']
3432
search_fields = ('name', 'description', 'project__name')
3533

36-
admin.site.register(Executable, ExecutableAdmin)
37-
3834

35+
@admin.register(Benchmark)
3936
class BenchmarkAdmin(admin.ModelAdmin):
4037
list_display = ('name', 'benchmark_type', 'data_type', 'description',
4138
'units_title', 'units', 'lessisbetter',
4239
'default_on_comparison')
43-
list_filter = ('data_type','lessisbetter')
40+
list_filter = ('data_type', 'lessisbetter')
4441
ordering = ['name']
4542
search_fields = ('name', 'description')
4643

47-
admin.site.register(Benchmark, BenchmarkAdmin)
48-
4944

45+
@admin.register(Environment)
5046
class EnvironmentAdmin(admin.ModelAdmin):
5147
list_display = ('name', 'cpu', 'memory', 'os', 'kernel')
5248
ordering = ['name']
5349
search_fields = ('name', 'cpu', 'memory', 'os', 'kernel')
5450

55-
admin.site.register(Environment, EnvironmentAdmin)
56-
5751

52+
@admin.register(Result)
5853
class ResultAdmin(admin.ModelAdmin):
5954
list_display = ('revision', 'benchmark', 'executable', 'environment',
6055
'value', 'date')
6156
list_filter = ('environment', 'executable', 'date', 'benchmark')
6257

63-
admin.site.register(Result, ResultAdmin)
64-
6558

6659
def recalculate_report(modeladmin, request, queryset):
6760
for report in queryset:
6861
report.save()
62+
63+
6964
recalculate_report.short_description = "Recalculate reports"
7065

7166

67+
@admin.register(Report)
7268
class ReportAdmin(admin.ModelAdmin):
7369
list_display = ('revision', 'summary', 'colorcode')
7470
list_filter = ('environment', 'executable')
7571
ordering = ['-revision']
7672
actions = [recalculate_report]
77-
78-
admin.site.register(Report, ReportAdmin)

codespeed/commits/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .logs import get_logs
1+
from .logs import get_logs # noqa

codespeed/commits/git.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,29 @@ def getlogs(endrev, startrev):
6969
tag = ""
7070

7171
cmd = ["git", "describe", "--tags", commit_id]
72-
Popen(cmd, stdout=PIPE, stderr=PIPE, cwd=working_copy)
72+
proc = Popen(cmd, stdout=PIPE, stderr=PIPE, cwd=working_copy)
7373

7474
try:
75-
stdout, stderr = p.communicate()
75+
stdout, stderr = proc.communicate()
7676
except ValueError:
7777
stdout = b''
7878
stderr = b''
7979

80-
if p.returncode == 0:
80+
if proc.returncode == 0:
8181
tag = stdout
8282

8383
date = datetime.datetime.fromtimestamp(
8484
int(date_t)).strftime("%Y-%m-%d %H:%M:%S")
8585

86-
logs.append({'date': date, 'message': subject, 'commitid': commit_id,
87-
'author': author_name, 'author_email': author_email,
88-
'body': body, 'short_commit_id': short_commit_id,
89-
'tag': tag})
86+
logs.append({
87+
'date': date,
88+
'message': subject,
89+
'commitid': commit_id,
90+
'author': author_name,
91+
'author_email': author_email,
92+
'body': body,
93+
'short_commit_id': short_commit_id,
94+
'tag': tag
95+
})
9096

9197
return logs

codespeed/commits/mercurial.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def updaterepo(project, update=True):
1919
return
2020

2121
p = Popen(['hg', 'pull', '-u'], stdout=PIPE, stderr=PIPE,
22-
cwd=project.working_copy)
22+
cwd=project.working_copy)
2323
stdout, stderr = p.communicate()
2424

2525
if p.returncode != 0 or stderr:
@@ -32,7 +32,7 @@ def updaterepo(project, update=True):
3232
cmd = ['hg', 'clone', project.repo_path, project.repo_name]
3333

3434
p = Popen(cmd, stdout=PIPE, stderr=PIPE,
35-
cwd=settings.REPOSITORY_BASE_PATH)
35+
cwd=settings.REPOSITORY_BASE_PATH)
3636
logger.debug('Cloning Mercurial repo {0} for project {1}'.format(
3737
project.repo_path, project))
3838
stdout, stderr = p.communicate()
@@ -48,9 +48,13 @@ def updaterepo(project, update=True):
4848
def getlogs(endrev, startrev):
4949
updaterepo(endrev.branch.project, update=False)
5050

51-
cmd = ["hg", "log",
52-
"-r", "%s::%s" % (startrev.commitid, endrev.commitid),
53-
"--template", "{rev}:{node|short}\n{node}\n{author|user}\n{author|email}\n{date}\n{tags}\n{desc}\n=newlog=\n"]
51+
cmd = [
52+
"hg", "log",
53+
"-r", "%s::%s" % (startrev.commitid, endrev.commitid),
54+
"--template",
55+
("{rev}:{node|short}\n{node}\n{author|user}\n{author|email}"
56+
"\n{date}\n{tags}\n{desc}\n=newlog=\n")
57+
]
5458

5559
working_copy = endrev.branch.project.working_copy
5660
p = Popen(cmd, stdout=PIPE, stderr=PIPE, cwd=working_copy)
@@ -66,8 +70,8 @@ def getlogs(endrev, startrev):
6670
elements = log.split('\n')[:-1]
6771
if len(elements) < 7:
6872
# "Malformed" log
69-
logs.append(
70-
{'date': '-', 'message': 'error parsing log', 'commitid': '-'})
73+
logs.append({
74+
'date': '-', 'message': 'error parsing log', 'commitid': '-'})
7175
else:
7276
short_commit_id = elements.pop(0)
7377
commit_id = elements.pop(0)
@@ -81,13 +85,19 @@ def getlogs(endrev, startrev):
8185

8286
# Parse date
8387
date = date.split('-')[0]
84-
date = datetime.datetime.fromtimestamp(float(date)).strftime("%Y-%m-%d %H:%M:%S")
88+
date = datetime.datetime.fromtimestamp(
89+
float(date)).strftime("%Y-%m-%d %H:%M:%S")
8590

8691
# Add changeset info
8792
logs.append({
88-
'date': date, 'author': author_name,
89-
'author_email': author_email, 'message': message,
90-
'short_commit_id': short_commit_id, 'commitid': commit_id, 'tag': tag})
93+
'date': date,
94+
'author': author_name,
95+
'author_email': author_email,
96+
'message': message,
97+
'short_commit_id': short_commit_id,
98+
'commitid': commit_id,
99+
'tag': tag
100+
})
91101
# Remove last log here because mercurial saves the short hast as commitid now
92102
if len(logs) > 1 and logs[-1].get('short_commit_id') == startrev.commitid:
93103
logs.pop()

codespeed/commits/subversion.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
22
"""Subversion commit logs support"""
3-
# -*- coding: utf-8 -*-
43
from __future__ import absolute_import
54

65
from datetime import datetime
@@ -32,7 +31,9 @@ def getlogs(newrev, startrev):
3231
loglimit = 200
3332

3433
def get_login(realm, username, may_save):
35-
return True, newrev.branch.project.repo_user, newrev.branch.project.repo_pass, False
34+
repo_user = newrev.branch.project.repo_user
35+
repo_pass = newrev.branch.project.repo_pass
36+
return True, repo_user, repo_pass, False
3637

3738
client = pysvn.Client()
3839
if newrev.branch.project.repo_user != "":
@@ -43,7 +44,7 @@ def get_login(realm, username, may_save):
4344
client.log(
4445
newrev.branch.project.repo_path,
4546
revision_start=pysvn.Revision(
46-
pysvn.opt_revision_kind.number, startrev.commitid
47+
pysvn.opt_revision_kind.number, startrev.commitid
4748
),
4849
revision_end=pysvn.Revision(
4950
pysvn.opt_revision_kind.number, newrev.commitid

codespeed/images.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def gen_image_from_results(result_data, width, height):
4747
font_sizes[idx] = 8
4848
elif value < 1000:
4949
font_sizes[idx] = 12
50-
50+
5151
if result_data['relative']:
5252
font_sizes[0] -= 2
5353

codespeed/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def clean(self):
122122
raise ValidationError("Invalid commit id %s" % self.commitid)
123123
if self.branch.project.repo_type == "S":
124124
try:
125-
long(self.commitid)
125+
int(self.commitid)
126126
except ValueError:
127127
raise ValidationError("Invalid SVN commit id %s" % self.commitid)
128128

0 commit comments

Comments
 (0)