浏览代码

HUE-1044 [oozie] Show progress of bundles on the dashboard

Average the progress of each coordinator
Fix html escaping error when login-in with an empty password or login
Romain Rigaux 12 年之前
父节点
当前提交
09f120a6b1
共有 2 个文件被更改,包括 22 次插入3 次删除
  1. 2 2
      desktop/core/src/desktop/templates/login.mako
  2. 20 1
      desktop/libs/liboozie/src/liboozie/types.py

+ 2 - 2
desktop/core/src/desktop/templates/login.mako

@@ -65,11 +65,11 @@ from django.utils.translation import ugettext as _
                 <form method="POST" action="${action}" class="well">
                     <label>${_('Username')}
                         ${ form['username'] | n,unicode }
-                        ${ form['username'].errors }
+                        ${ form['username'].errors | n,unicode }
                     </label>
                     <label>${_('Password')}
                         ${ form['password'] | n,unicode }
-                        ${ form['password'].errors }
+                        ${ form['password'].errors | n,unicode }
                     </label>
 
                     %if first_login_ever:

+ 20 - 1
desktop/libs/liboozie/src/liboozie/types.py

@@ -254,6 +254,19 @@ class BundleAction(Action):
     else:
       self.conf_dict = {}
 
+  def get_progress(self):
+    """How much more time before the next action."""
+    next = mktime(parse_timestamp(self.lastAction))
+    start = mktime(parse_timestamp(self.startTime))
+    end = mktime(parse_timestamp(self.endTime))
+
+    if end != start:
+      progress = min(int((1 - (end - next) / (end - start)) * 100), 100)
+    else:
+      progress = 100
+
+    return progress
+
 
 class Job(object):
   RUNNING_STATUSES = set(['PREP', 'RUNNING', 'SUSPENDED', 'PREP', # Workflow
@@ -534,7 +547,13 @@ class Bundle(Job):
     return reverse('oozie:list_oozie_bundle', kwargs={'job_id': self.id})
 
   def get_progress(self):
-    return 50
+    progresses = [action.get_progress() for action in self.actions]
+    count = len(progresses)
+
+    if count != 0:
+      return sum(progresses) / float(count)
+    else:
+      return 0
 
 
 class JobList(object):