aboutsummaryrefslogtreecommitdiffstats
path: root/src/dashboard
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
commitc5214f6accee741d64efd29498d813aae9f4068e (patch)
treec4c116f801cb5b23168968115991f46da926ef05 /src/dashboard
parent1db9f7772a9266edd84c33592322c5dd2e4aeae8 (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 'src/dashboard')
-rw-r--r--src/dashboard/views.py43
1 files changed, 24 insertions, 19 deletions
diff --git a/src/dashboard/views.py b/src/dashboard/views.py
index 62a9f83..4bab036 100644
--- a/src/dashboard/views.py
+++ b/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