Permalink
Browse files

Remove vim config from create_apikey, lots of pep8 fixes

  • Loading branch information...
1 parent 2fc727c commit 931c26e7d4ee009b6e3a1d09ab80f861b25119d1 @tobami committed Feb 25, 2012
View
@@ -11,43 +11,52 @@ class ProjectAdmin(admin.ModelAdmin):
admin.site.register(Project, ProjectAdmin)
+
class BranchAdmin(admin.ModelAdmin):
list_display = ('name', 'project')
admin.site.register(Branch, BranchAdmin)
+
class RevisionAdmin(admin.ModelAdmin):
list_display = ('commitid', 'branch', 'tag', 'date')
- list_filter = ('branch', 'tag', 'date')
+ list_filter = ('branch', 'tag', 'date')
search_fields = ('commitid', 'tag')
admin.site.register(Revision, RevisionAdmin)
+
class ExecutableAdmin(admin.ModelAdmin):
list_display = ('name', 'description', 'id', 'project')
search_fields = ('name', 'description', 'project')
admin.site.register(Executable, ExecutableAdmin)
+
class BenchmarkAdmin(admin.ModelAdmin):
- list_display = ('name', 'benchmark_type', 'description', 'units_title', 'units', 'lessisbetter', 'default_on_comparison')
+ list_display = ('name', 'benchmark_type', 'description', 'units_title',
+ 'units', 'lessisbetter', 'default_on_comparison')
ordering = ['name']
search_fields = ('name', 'description')
admin.site.register(Benchmark, BenchmarkAdmin)
+
class EnvironmentAdmin(admin.ModelAdmin):
list_display = ('name', 'cpu', 'memory', 'os', 'kernel')
search_fields = ('name', 'cpu', 'memory', 'os', 'kernel')
admin.site.register(Environment, EnvironmentAdmin)
+
class ResultAdmin(admin.ModelAdmin):
- list_display = ('revision', 'benchmark', 'executable', 'environment', 'value', 'date', 'environment')
- list_filter = ('date', 'environment', 'executable', 'benchmark')
+ list_display = ('revision', 'benchmark', 'executable', 'environment',
+ 'value', 'date', 'environment')
+ list_filter = ('date', 'environment', 'executable', 'benchmark')
admin.site.register(Result, ResultAdmin)
+
class ReportAdmin(admin.ModelAdmin):
list_display = ('revision', 'summary', 'colorcode')
ordering = ['-revision']
View
@@ -64,16 +64,16 @@ class Meta:
#excludes = ['email', 'password', 'is_superuser']
# Add it here.
#authorization = DjangoAuthorization()
- authorization= Authorization()
- #authentication = ApiKeyAuthentication()
+ authorization = Authorization()
+ #authentication = ApiKeyAuthentication()
class ProjectResource(ModelResource):
"""Resource for Project()"""
class Meta:
queryset = Project.objects.all()
- authorization= Authorization()
+ authorization = Authorization()
class BranchResource(ModelResource):
@@ -83,7 +83,7 @@ class BranchResource(ModelResource):
class Meta:
queryset = Branch.objects.all()
- authorization= Authorization()
+ authorization = Authorization()
class RevisionResource(ModelResource):
@@ -94,7 +94,7 @@ class RevisionResource(ModelResource):
class Meta:
queryset = Revision.objects.all()
- authorization= Authorization()
+ authorization = Authorization()
class ExecutableResource(ModelResource):
@@ -104,15 +104,15 @@ class ExecutableResource(ModelResource):
class Meta:
queryset = Executable.objects.all()
- authorization= Authorization()
+ authorization = Authorization()
class BenchmarkResource(ModelResource):
"""Resource for Benchmark()"""
class Meta:
queryset = Benchmark.objects.all()
- authorization= Authorization()
+ authorization = Authorization()
class EnvironmentResource(ModelResource):
@@ -121,15 +121,15 @@ class EnvironmentResource(ModelResource):
class Meta:
queryset = Environment.objects.all()
resource_name = 'environment'
- authorization= Authorization()
+ authorization = Authorization()
class ResultResource(ModelResource):
"""Resource for Result()"""
class Meta:
queryset = Result.objects.all()
- authorization= Authorization()
+ authorization = Authorization()
class ReportResource(ModelResource):
@@ -142,7 +142,7 @@ class ReportResource(ModelResource):
class Meta:
queryset = Report.objects.all()
allowed_methods = ['get']
- authorization= Authorization()
+ authorization = Authorization()
class ResultBundle(Bundle):
@@ -183,13 +183,13 @@ def __init__(self, obj=None, **kwargs):
self.obj = obj
self._populate_by_obj()
elif obj is None:
- self.obj = Result()
+ self.obj = Result()
else:
raise ValueError("obj has to be an instance of models.Result")
if self.data:
self._check_data()
- self.__data_validated = False #not used for now
+ self.__data_validated = False # not used for now
super(ResultBundle, self).__init__(data=self.data, obj=self.obj)
def _populate_obj_by_data(self):
@@ -213,7 +213,7 @@ def populate(key):
}.get(key, (None, None))()
try:
- self.obj.value = float(self.data['result_value'])
+ self.obj.value = float(self.data['result_value'])
except ValueError, error:
logging.error(
"Result value: {0} cannot be converted to float. {1}".format(
@@ -367,7 +367,7 @@ class ResultBundleResource(Resource):
class Meta:
resource_name = 'benchmark-result'
- authorization= Authorization()
+ authorization = Authorization()
allowed_methods = ['get', 'post', 'put', 'delete']
def get_resource_uri(self, bundle_or_obj):
@@ -417,7 +417,6 @@ def obj_create(self, bundle, request=None, **kwargs):
def obj_update(self, bundle, request=None, **kwargs):
return self.obj_create(bundle, request, **kwargs)
-
def post_list(self, request, **kwargs):
"""
Creates a new resource/object with the provided data.
@@ -458,4 +457,3 @@ def obj_delete(self, request=None, **kwargs):
def rollback(self, bundles):
pass
-
View
@@ -37,6 +37,7 @@ def updaterepo(project, update=True):
else:
return [{'error': False}]
+
def getlogs(endrev, startrev):
updaterepo(endrev.branch.project, update=False)
@@ -48,7 +49,7 @@ def getlogs(endrev, startrev):
if endrev.commitid != startrev.commitid:
cmd.append("%s...%s" % (startrev.commitid, endrev.commitid))
else:
- cmd.append("-1") # Only return one commit
+ cmd.append("-1") # Only return one commit
cmd.append(endrev.commitid)
working_copy = endrev.branch.project.working_copy
View
@@ -26,11 +26,12 @@
# revisions.
GITHUB_REVISION_LIMIT = 10
+
def updaterepo(project, update=True):
return
-def retrieve_revision(commit_id, username, project, revision = None):
+def retrieve_revision(commit_id, username, project, revision=None):
commit_url = 'http://github.com/api/v2/json/commits/show/%s/%s/%s' % (
username, project, commit_id)
@@ -73,13 +74,14 @@ def retrieve_revision(commit_id, username, project, revision = None):
return {'date': date,
'message': commit['message'],
- 'body': "", # TODO: pretty-print diffs
+ 'body': "", # TODO: pretty-print diffs
'author': commit['author']['name'],
'author_email': commit['author']['email'],
'commitid': commit['id'],
'short_commit_id': commit['id'][0:7],
'parents': commit['parents']}
+
def getlogs(endrev, startrev):
if endrev != startrev:
revisions = endrev.branch.revisions.filter(
@@ -108,15 +110,15 @@ def getlogs(endrev, startrev):
logs.append(last_rev_data)
revision_count += 1
ancestor_found = (startrev.commitid in [rev['id'] for rev in last_rev_data['parents']])
-
+
# Simple approach to find the startrev, stop after found or after
# #GITHUB_REVISION_LIMIT revisions are fetched
- while (revision_count < GITHUB_REVISION_LIMIT
+ while (revision_count < GITHUB_REVISION_LIMIT
and not ancestor_found
and len(last_rev_data['parents']) > 0):
last_rev_data = retrieve_revision(last_rev_data['parents'][0]['id'], username, project)
logs.append(last_rev_data)
revision_count += 1
ancestor_found = (startrev.commitid in [rev['id'] for rev in last_rev_data['parents']])
-
+
return sorted(logs, key=lambda i: i['date'], reverse=True)
View
@@ -1,4 +1,5 @@
-import os, datetime
+import os
+import datetime
from subprocess import Popen, PIPE
import logging
@@ -39,6 +40,7 @@ def updaterepo(project, update=True):
else:
return [{'error': False}]
+
def getlogs(endrev, startrev):
updaterepo(endrev.branch.project, update=False)
@@ -54,7 +56,7 @@ def getlogs(endrev, startrev):
if p.returncode != 0:
raise RuntimeError(str(stderr))
else:
- stdout = stdout.rstrip('\n')#Remove last newline
+ stdout = stdout.rstrip('\n') # Remove last newline
logs = []
for log in stdout.split("=newlog=\n"):
elements = []
@@ -78,9 +80,9 @@ def getlogs(endrev, startrev):
# 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})
+ 'date': date, 'author': author_name,
+ 'author_email': author_email, 'message': message,
+ 'short_commit_id': short_commit_id, 'commitid': commit_id})
# 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()
Oops, something went wrong.

0 comments on commit 931c26e

Please sign in to comment.