summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/views.py
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2014-08-29 16:42:00 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-09-01 08:51:33 +0100
commit372c9d144e87ab5f360c9763101916fbcb94e469 (patch)
treef2068f0b5ea257b65ee6f0c0f8397c97ab82025d /bitbake/lib/toaster/toastergui/views.py
parentacd4a1799d51a9f0b192d12b2c58387595b27bf7 (diff)
downloadpoky-372c9d144e87ab5f360c9763101916fbcb94e469.tar.gz
bitbake: toastergui: added pages for project details
We add new pages for the layer importing, layer details, showing project builds and project configuration. The pages are in read-only mode, but they're needed as to be able to verify the quality of data in the system. Write capabilities will be added in a subsequent patch. [YOCTO #6595] [YOCTO #6590] [YOCTO #6591] [YOCTO #6588] [YOCTO #6589] (Bitbake rev: eed9ae5c2a2bd7567e12ae9a4f02a5a966a1e1a3) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/views.py')
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py192
1 files changed, 179 insertions, 13 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 167b687d03..13788b0d55 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -903,7 +903,7 @@ def tasks_common(request, build_id, variant, task_anchor):
903 retval = _verify_parameters( request.GET, mandatory_parameters ) 903 retval = _verify_parameters( request.GET, mandatory_parameters )
904 if retval: 904 if retval:
905 if task_anchor: 905 if task_anchor:
906 mandatory_parameters['anchor']=task_anchor 906 mandatory_parameters['anchor']=task_anchor
907 return _redirect_parameters( variant, request.GET, mandatory_parameters, build_id = build_id) 907 return _redirect_parameters( variant, request.GET, mandatory_parameters, build_id = build_id)
908 (filter_string, search_term, ordering_string) = _search_tuple(request, Task) 908 (filter_string, search_term, ordering_string) = _search_tuple(request, Task)
909 queryset_all = Task.objects.filter(build=build_id).exclude(order__isnull=True).exclude(outcome=Task.OUTCOME_NA) 909 queryset_all = Task.objects.filter(build=build_id).exclude(order__isnull=True).exclude(outcome=Task.OUTCOME_NA)
@@ -917,19 +917,19 @@ def tasks_common(request, build_id, variant, task_anchor):
917 else: 917 else:
918 queryset = _get_queryset(Task, queryset_all, filter_string, search_term, ordering_string, 'order') 918 queryset = _get_queryset(Task, queryset_all, filter_string, search_term, ordering_string, 'order')
919 919
920 # compute the anchor's page 920 # compute the anchor's page
921 if anchor: 921 if anchor:
922 request.GET = request.GET.copy() 922 request.GET = request.GET.copy()
923 del request.GET['anchor'] 923 del request.GET['anchor']
924 i=0 924 i=0
925 a=int(anchor) 925 a=int(anchor)
926 count_per_page=int(request.GET.get('count', 100)) 926 count_per_page=int(request.GET.get('count', 100))
927 for task in queryset.iterator(): 927 for task in queryset.iterator():
928 if a == task.order: 928 if a == task.order:
929 new_page= (i / count_per_page ) + 1 929 new_page= (i / count_per_page ) + 1
930 request.GET.__setitem__('page', new_page) 930 request.GET.__setitem__('page', new_page)
931 mandatory_parameters['page']=new_page 931 mandatory_parameters['page']=new_page
932 return _redirect_parameters( variant, request.GET, mandatory_parameters, build_id = build_id) 932 return _redirect_parameters( variant, request.GET, mandatory_parameters, build_id = build_id)
933 i += 1 933 i += 1
934 934
935 tasks = _build_page_range(Paginator(queryset, request.GET.get('count', 100)),request.GET.get('page', 1)) 935 tasks = _build_page_range(Paginator(queryset, request.GET.get('count', 100)),request.GET.get('page', 1))
@@ -1917,10 +1917,12 @@ if toastermain.settings.MANAGED:
1917 return HttpResponse(json.dumps({"error":str(e) + "\n" + traceback.format_exc()}), content_type = "application/json") 1917 return HttpResponse(json.dumps({"error":str(e) + "\n" + traceback.format_exc()}), content_type = "application/json")
1918 1918
1919 def importlayer(request): 1919 def importlayer(request):
1920 raise Exception("TODO: implement page #6595") 1920 template = "importlayer.html"
1921 context = {
1922 }
1923 return render(request, template, context)
1921 1924
1922 def layers(request): 1925 def layers(request):
1923 # "TODO: implement page #6590"
1924 template = "layers.html" 1926 template = "layers.html"
1925 # define here what parameters the view needs in the GET portion in order to 1927 # define here what parameters the view needs in the GET portion in order to
1926 # be able to display something. 'count' and 'page' are mandatory for all views 1928 # be able to display something. 'count' and 'page' are mandatory for all views
@@ -2000,7 +2002,11 @@ if toastermain.settings.MANAGED:
2000 return render(request, template, context) 2002 return render(request, template, context)
2001 2003
2002 def layerdetails(request, layerid): 2004 def layerdetails(request, layerid):
2003 raise Exception("TODO: implement page #6591") 2005 template = "layerdetails.html"
2006 context = {
2007 'layerversion': Layer_Version.objects.get(pk = layerid),
2008 }
2009 return render(request, template, context)
2004 2010
2005 def targets(request): 2011 def targets(request):
2006 template = "targets.html" 2012 template = "targets.html"
@@ -2159,11 +2165,171 @@ if toastermain.settings.MANAGED:
2159 return render(request, template, context) 2165 return render(request, template, context)
2160 2166
2161 def projectconf(request, pid): 2167 def projectconf(request, pid):
2162 raise Exception("TODO: implement page #6588") 2168 template = "projectconf.html"
2169 context = {
2170 'configvars': ProjectVariable.objects.filter(project_id = pid),
2171 }
2172 return render(request, template, context)
2163 2173
2164 def projectbuilds(request, pid): 2174 def projectbuilds(request, pid):
2165 raise Exception("TODO: implement page #6589") 2175 template = 'projectbuilds.html'
2176 # define here what parameters the view needs in the GET portion in order to
2177 # be able to display something. 'count' and 'page' are mandatory for all views
2178 # that use paginators.
2179 mandatory_parameters = { 'count': 10, 'page' : 1, 'orderby' : 'completed_on:-' };
2180 retval = _verify_parameters( request.GET, mandatory_parameters )
2166 2181
2182 # boilerplate code that takes a request for an object type and returns a queryset
2183 # for that object type. copypasta for all needed table searches
2184 (filter_string, search_term, ordering_string) = _search_tuple(request, Build)
2185 queryset_all = Build.objects.all.exclude(outcome = Build.IN_PROGRESS)
2186 queryset_with_search = _get_queryset(Build, queryset_all, None, search_term, ordering_string, '-completed_on')
2187 queryset = _get_queryset(Build, queryset_all, filter_string, search_term, ordering_string, '-completed_on')
2188
2189 # retrieve the objects that will be displayed in the table; builds a paginator and gets a page range to display
2190 build_info = _build_page_range(Paginator(queryset, request.GET.get('count', 10)),request.GET.get('page', 1))
2191
2192
2193 # set up list of fstypes for each build
2194 fstypes_map = {};
2195 for build in build_info:
2196 targets = Target.objects.filter( build_id = build.id )
2197 comma = "";
2198 extensions = "";
2199 for t in targets:
2200 if ( not t.is_image ):
2201 continue
2202 tif = Target_Image_File.objects.filter( target_id = t.id )
2203 for i in tif:
2204 s=re.sub('.*tar.bz2', 'tar.bz2', i.file_name)
2205 if s == i.file_name:
2206 s=re.sub('.*\.', '', i.file_name)
2207 if None == re.search(s,extensions):
2208 extensions += comma + s
2209 comma = ", "
2210 fstypes_map[build.id]=extensions
2211
2212 # send the data to the template
2213 context = {
2214 'objects' : build_info,
2215 'objectname' : "builds",
2216 'default_orderby' : 'completed_on:-',
2217 'fstypes' : fstypes_map,
2218 'search_term' : search_term,
2219 'total_count' : queryset_with_search.count(),
2220 # Specifies the display of columns for the table, appearance in "Edit columns" box, toggling default show/hide, and specifying filters for columns
2221 'tablecols' : [
2222 {'name': 'Outcome', # column with a single filter
2223 'qhelp' : "The outcome tells you if a build successfully completed or failed", # the help button content
2224 'dclass' : "span2", # indication about column width; comes from the design
2225 'orderfield': _get_toggle_order(request, "outcome"), # adds ordering by the field value; default ascending unless clicked from ascending into descending
2226 'ordericon':_get_toggle_order_icon(request, "outcome"),
2227 # filter field will set a filter on that column with the specs in the filter description
2228 # the class field in the filter has no relation with clclass; the control different aspects of the UI
2229 # still, it is recommended for the values to be identical for easy tracking in the generated HTML
2230 'filter' : {'class' : 'outcome',
2231 'label': 'Show:',
2232 'options' : [
2233 ('Successful builds', 'outcome:' + str(Build.SUCCEEDED), queryset_with_search.filter(outcome=str(Build.SUCCEEDED)).count()), # this is the field search expression
2234 ('Failed builds', 'outcome:'+ str(Build.FAILED), queryset_with_search.filter(outcome=str(Build.FAILED)).count()),
2235 ]
2236 }
2237 },
2238 {'name': 'Target', # default column, disabled box, with just the name in the list
2239 'qhelp': "This is the build target or build targets (i.e. one or more recipes or image recipes)",
2240 'orderfield': _get_toggle_order(request, "target__target"),
2241 'ordericon':_get_toggle_order_icon(request, "target__target"),
2242 },
2243 {'name': 'Machine',
2244 'qhelp': "The machine is the hardware for which you are building a recipe or image recipe",
2245 'orderfield': _get_toggle_order(request, "machine"),
2246 'ordericon':_get_toggle_order_icon(request, "machine"),
2247 'dclass': 'span3'
2248 }, # a slightly wider column
2249 {'name': 'Started on', 'clclass': 'started_on', 'hidden' : 1, # this is an unchecked box, which hides the column
2250 'qhelp': "The date and time you started the build",
2251 'orderfield': _get_toggle_order(request, "started_on", True),
2252 'ordericon':_get_toggle_order_icon(request, "started_on"),
2253 'filter' : {'class' : 'started_on',
2254 'label': 'Show:',
2255 'options' : [
2256 ("Today's builds" , 'started_on__gte:'+timezone.now().strftime("%Y-%m-%d"), queryset_with_search.filter(started_on__gte=timezone.now()).count()),
2257 ("Yesterday's builds", 'started_on__gte:'+(timezone.now()-timedelta(hours=24)).strftime("%Y-%m-%d"), queryset_with_search.filter(started_on__gte=(timezone.now()-timedelta(hours=24))).count()),
2258 ("This week's builds", 'started_on__gte:'+(timezone.now()-timedelta(days=7)).strftime("%Y-%m-%d"), queryset_with_search.filter(started_on__gte=(timezone.now()-timedelta(days=7))).count()),
2259 ]
2260 }
2261 },
2262 {'name': 'Completed on',
2263 'qhelp': "The date and time the build finished",
2264 'orderfield': _get_toggle_order(request, "completed_on", True),
2265 'ordericon':_get_toggle_order_icon(request, "completed_on"),
2266 'orderkey' : 'completed_on',
2267 'filter' : {'class' : 'completed_on',
2268 'label': 'Show:',
2269 'options' : [
2270 ("Today's builds", 'completed_on__gte:'+timezone.now().strftime("%Y-%m-%d"), queryset_with_search.filter(completed_on__gte=timezone.now()).count()),
2271 ("Yesterday's builds", 'completed_on__gte:'+(timezone.now()-timedelta(hours=24)).strftime("%Y-%m-%d"), queryset_with_search.filter(completed_on__gte=(timezone.now()-timedelta(hours=24))).count()),
2272 ("This week's builds", 'completed_on__gte:'+(timezone.now()-timedelta(days=7)).strftime("%Y-%m-%d"), queryset_with_search.filter(completed_on__gte=(timezone.now()-timedelta(days=7))).count()),
2273 ]
2274 }
2275 },
2276 {'name': 'Failed tasks', 'clclass': 'failed_tasks', # specifing a clclass will enable the checkbox
2277 'qhelp': "How many tasks failed during the build",
2278 'filter' : {'class' : 'failed_tasks',
2279 'label': 'Show:',
2280 'options' : [
2281 ('Builds with failed tasks', 'task_build__outcome:4', queryset_with_search.filter(task_build__outcome=4).count()),
2282 ('Builds without failed tasks', 'task_build__outcome:NOT4', queryset_with_search.filter(~Q(task_build__outcome=4)).count()),
2283 ]
2284 }
2285 },
2286 {'name': 'Errors', 'clclass': 'errors_no',
2287 'qhelp': "How many errors were encountered during the build (if any)",
2288 'orderfield': _get_toggle_order(request, "errors_no", True),
2289 'ordericon':_get_toggle_order_icon(request, "errors_no"),
2290 'orderkey' : 'errors_no',
2291 'filter' : {'class' : 'errors_no',
2292 'label': 'Show:',
2293 'options' : [
2294 ('Builds with errors', 'errors_no__gte:1', queryset_with_search.filter(errors_no__gte=1).count()),
2295 ('Builds without errors', 'errors_no:0', queryset_with_search.filter(errors_no=0).count()),
2296 ]
2297 }
2298 },
2299 {'name': 'Warnings', 'clclass': 'warnings_no',
2300 'qhelp': "How many warnings were encountered during the build (if any)",
2301 'orderfield': _get_toggle_order(request, "warnings_no", True),
2302 'ordericon':_get_toggle_order_icon(request, "warnings_no"),
2303 'orderkey' : 'warnings_no',
2304 'filter' : {'class' : 'warnings_no',
2305 'label': 'Show:',
2306 'options' : [
2307 ('Builds with warnings','warnings_no__gte:1', queryset_with_search.filter(warnings_no__gte=1).count()),
2308 ('Builds without warnings','warnings_no:0', queryset_with_search.filter(warnings_no=0).count()),
2309 ]
2310 }
2311 },
2312 {'name': 'Time', 'clclass': 'time', 'hidden' : 1,
2313 'qhelp': "How long it took the build to finish",
2314 'orderfield': _get_toggle_order(request, "timespent", True),
2315 'ordericon':_get_toggle_order_icon(request, "timespent"),
2316 'orderkey' : 'timespent',
2317 },
2318 {'name': 'Log',
2319 'dclass': "span4",
2320 'qhelp': "Path to the build main log file",
2321 'clclass': 'log', 'hidden': 1,
2322 'orderfield': _get_toggle_order(request, "cooker_log_path"),
2323 'ordericon':_get_toggle_order_icon(request, "cooker_log_path"),
2324 'orderkey' : 'cooker_log_path',
2325 },
2326 {'name': 'Output', 'clclass': 'output',
2327 'qhelp': "The root file system types produced by the build. You can find them in your <code>/build/tmp/deploy/images/</code> directory",
2328 },
2329 ]
2330 }
2331
2332 return render(request, template, context)
2167else: 2333else:
2168 # these are pages that are NOT available in interactive mode 2334 # these are pages that are NOT available in interactive mode
2169 def managedcontextprocessor(request): 2335 def managedcontextprocessor(request):