Skip to content

Commit

Permalink
Rename some settings properties to improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
tobami committed Jan 14, 2011
1 parent 35b09cd commit 10ed8d2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 35 deletions.
35 changes: 17 additions & 18 deletions speedcenter/codespeed/settings.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
## General default options ##
defaultenvironment = None #Name of the environment which should be selected as default
def_environment = None #Name of the environment which should be selected as default


defaultbaseline = None # Which executable + revision should be default as a baseline
# Given as the name of the executable and commitid of the revision
# Example: defaultbaseline = {'executable': 'myexe', 'revision': '21'}
def_baseline = None # Which executable + revision should be default as a baseline
# Given as the name of the executable and commitid of the revision
# Example: defaultbaseline = {'executable': 'myexe', 'revision': '21'}

trend = 10 # Default value for the depth of the trend
# Used by reports for the latest runs and changes view
Expand All @@ -18,26 +18,25 @@
trend_threshold = 4.0

# Changes view options ##
defaultexecutable = None # Executable that should be chosen as default in the changes view
# Given as the id of the executable.
# Example: defaultexecutable = "myexe"
def_executable = None # Executable that should be chosen as default in the changes view
# Given as the id of the executable.
# Example: defaultexecutable = "myexe"

## Comparison view options ##
charttype = 'normal bars' # The options are 'normal bars', 'stacked bars' and 'relative bars'
chart_type = 'normal bars' # The options are 'normal bars', 'stacked bars' and 'relative bars'

normalization = False # True will enable normalization as the default selection
# in the Comparison view. The default normalization can be
# chosen in the defaultbaseline setting

chartorientation = 'vertical' # 'vertical' or 'horizontal can be chosen as
chart_orientation = 'vertical' # 'vertical' or 'horizontal can be chosen as
# default chart orientation

comp_defaultexecutables = None # Which executable + revision should be checked
# Given as a list of tuples containing the
# name of an executable + commitid of a revision
# An 'L' denotes the last revision
# Example:
# comp_defaultexecutables = [
# ('myexe', '21df2423ra'),
# ('myexe', 'L'),
#]
comp_executables = None # Which executable + revision should be checked as default
# Given as a list of tuples containing the
# name of an executable + commitid of a revision
# An 'L' denotes the last revision
# Example:
# comp_executables = [
# ('myexe', '21df2423ra'),
# ('myexe', 'L'),]
37 changes: 20 additions & 17 deletions speedcenter/codespeed/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,43 +47,45 @@ def getbaselineexecutables():
'name': name,
})
# move default to first place
if hasattr(settings, 'defaultbaseline') and settings.defaultbaseline != None:
if hasattr(settings, 'def_baseline') and settings.def_baseline != None:
try:
for base in baseline:
if base['key'] == "none": continue
exename = settings.defaultbaseline['executable']
commitid = settings.defaultbaseline['revision']
exename = settings.def_baseline['executable']
commitid = settings.def_baseline['revision']
if base['executable'].name == exename and base['revision'].commitid == commitid:
baseline.remove(base)
baseline.insert(1, base)
break
except KeyError:
# TODO: write to server logs
#error in settings.defaultbaseline
#error in settings.def_baseline
pass
return baseline

def getdefaultenvironment():
default = Environment.objects.all()
if not len(default): return 0
if not len(default):
return 0
default = default[0]
if hasattr(settings, 'defaultenvironment'):
if hasattr(settings, 'def_environment'):
try:
default = Environment.objects.get(name=settings.defaultenvironment)
default = Environment.objects.get(name=settings.def_environment)
except Environment.DoesNotExist:
pass
return default

def getdefaultexecutable():
default = None
if hasattr(settings, 'defaultexecutable') and settings.defaultexecutable != None:
if hasattr(settings, 'def_executable') and settings.def_executable != None:
try:
default = Executable.objects.get(name=settings.defaultexecutable)
default = Executable.objects.get(name=settings.def_executable)
except Executable.DoesNotExist:
pass
if default == None:
execquery = Executable.objects.filter(project__track=True)
if len(execquery): default = execquery[0]
if len(execquery):
default = execquery[0]

return default

Expand All @@ -93,7 +95,8 @@ def getcomparisonexes():
maxlen = 20
# add all tagged revs for any project
for exe in getbaselineexecutables():
if exe['key'] == "none": continue
if exe['key'] == "none":
continue
executablekeys.append(exe['key'])
executables.append(exe)

Expand Down Expand Up @@ -185,9 +188,9 @@ def comparison(request):
if not i: continue
if i in exekeys:
checkedexecutables.append(i)
elif hasattr(settings, 'comp_defaultexecutables') and\
settings.comp_defaultexecutables != None:
for exe, rev in settings.comp_defaultexecutables:
elif hasattr(settings, 'com_executables') and\
settings.comp_executables != None:
for exe, rev in settings.comp_executables:
try:
exe = Executable.objects.get(name=exe)
key = str(exe.id) + "+"
Expand Down Expand Up @@ -246,8 +249,8 @@ def comparison(request):
selectedchart = charts[0]
if 'chart' in data and data['chart'] in charts:
selectedchart = data['chart']
elif hasattr(settings, 'charttype') and settings.charttype in charts:
selectedchart = settings.charttype
elif hasattr(settings, 'chart_type') and settings.chart_type in charts:
selectedchart = settings.chart_type

selectedbaseline = "none"
if 'bas' in data and data['bas'] in exekeys:
Expand All @@ -262,7 +265,7 @@ def comparison(request):
checkedexecutables.remove(selectedbaseline)
selecteddirection = False
if 'hor' in data and data['hor'] == "true" or\
hasattr(settings, 'chartorientation') and settings.chartorientation == 'horizontal':
hasattr(settings, 'chart_orientation') and settings.chart_orientation == 'horizontal':
selecteddirection = True

return render_to_response('codespeed/comparison.html', {
Expand Down

0 comments on commit 10ed8d2

Please sign in to comment.