summaryrefslogtreecommitdiffstats
path: root/dashboard/src
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2018-03-06 12:07:05 -0500
committerSawyer Bergeron <sbergeron@iol.unh.edu>2018-03-26 21:14:25 +0000
commit350e21a65b0bbdab86808f984ebc4949eaac5a8b (patch)
tree38c1ad416fcff711eb270f632683f4c33e63128e /dashboard/src
parentb011d39bb162bf77f4bca8c6708b82973eb56eb6 (diff)
Gracefully Handle Missing Jenkins Utilization for Dev Pod
Jira: PHAROS-364 Change-Id: I0641c658914e600672151d7c0d1661acba794f0f Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
Diffstat (limited to 'dashboard/src')
-rw-r--r--dashboard/src/dashboard/views.py43
1 files changed, 24 insertions, 19 deletions
diff --git a/dashboard/src/dashboard/views.py b/dashboard/src/dashboard/views.py
index 62a9f83..4bab036 100644
--- a/dashboard/src/dashboard/views.py
+++ b/dashboard/src/dashboard/views.py
@@ -120,22 +120,27 @@ class JenkinsUtilizationJSON(View):
def get(self, request, *args, **kwargs):
resource = get_object_or_404(Resource, id=kwargs['resource_id'])
weeks = int(kwargs['weeks'])
- utilization = resource.slave.get_utilization(timedelta(weeks=weeks))
- utilization = [
- {
- 'label': 'Offline',
- 'data': utilization['offline'],
- 'color': '#d9534f'
- },
- {
- 'label': 'Online',
- 'data': utilization['online'],
- 'color': '#5cb85c'
- },
- {
- 'label': 'Idle',
- 'data': utilization['idle'],
- 'color': '#5bc0de'
- },
- ]
- return JsonResponse({'data': utilization})
+ try:
+ utilization = resource.slave.get_utilization(timedelta(weeks=weeks))
+ utilization = [
+ {
+ 'label': 'Offline',
+ 'data': utilization['offline'],
+ 'color': '#d9534f'
+ },
+ {
+ 'label': 'Online',
+ 'data': utilization['online'],
+ 'color': '#5cb85c'
+ },
+ {
+ 'label': 'Idle',
+ 'data': utilization['idle'],
+ 'color': '#5bc0de'
+ },
+ ]
+ jutilization = JsonResponse({'data': utilization})
+ except AttributeError:
+ return JsonResponse({'data': ''})
+ if jutilization:
+ return jutilization