From 3ff649953d836efe3089e42f8f11a4c6abe648be Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Wed, 25 Mar 2015 13:34:27 +0000 Subject: bitbake: toastergui: prevent error on empty build list This patch prevents errors being thrown on date limit computations if the build list is empty. [YOCTO #7513] (Bitbake rev: 8068539b6c2913fed66a865b547a653159d8c794) Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastergui/views.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'bitbake') diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index fdd80222ab..2f8fb1a8e3 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py @@ -334,8 +334,14 @@ def _add_daterange_context(queryset_all, request, daterange_list): context_date['daterange_filter']='' for key in daterange_list: queryset_key = queryset_all.order_by(key) - context_date['dateMin_'+key]=timezone.localtime(getattr(queryset_key.first(),key)).strftime("%d/%m/%Y") - context_date['dateMax_'+key]=timezone.localtime(getattr(queryset_key.last(),key)).strftime("%d/%m/%Y") + try: + context_date['dateMin_'+key]=timezone.localtime(getattr(queryset_key.first(),key)).strftime("%d/%m/%Y") + except AttributeError: + context_date['dateMin_'+key]=timezone.localtime(timezone.now()) + try: + context_date['dateMax_'+key]=timezone.localtime(getattr(queryset_key.last(),key)).strftime("%d/%m/%Y") + except AttributeError: + context_date['dateMax_'+key]=timezone.localtime(timezone.now()) return context_date,today_begin,yesterday_begin -- cgit v1.2.3-54-g00ecf