[Kimchi-devel] [PATCH v2] Add checking for UI codes when running make check-local

Ramon Medeiros ramonn at linux.vnet.ibm.com
Wed Nov 25 19:15:19 UTC 2015


Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>

Changes:
v2:
Add Copyright text
Use diff to expose ui codes not used

---
 Makefile.am                                    |  1 +
 check_ui_code_errors.sh                        | 31 ++++++++++++++++++++++++++
 src/wok/plugins/kimchi/Makefile.am             |  2 +-
 src/wok/plugins/kimchi/check_ui_code_errors.sh | 31 ++++++++++++++++++++++++++
 src/wok/plugins/kimchi/model/vms.py            |  6 ++---
 5 files changed, 67 insertions(+), 4 deletions(-)
 create mode 100755 check_ui_code_errors.sh
 create mode 100755 src/wok/plugins/kimchi/check_ui_code_errors.sh

diff --git a/Makefile.am b/Makefile.am
index 027344f..106a577 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -56,6 +56,7 @@ check-local:
 	$(PEP8) --version
 	$(PEP8) --filename '*.py,*.py.in' --exclude="$(PEP8_BLACKLIST)" .
 
+	/bin/bash check_ui_code_errors.sh
 
 # Link built mo files in the source tree to enable use of translations from
 # within the source tree
diff --git a/check_ui_code_errors.sh b/check_ui_code_errors.sh
new file mode 100755
index 0000000..58e5990
--- /dev/null
+++ b/check_ui_code_errors.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2015
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+
+errors="$(cat ui/pages/i18n.json.tmpl | grep -o 'WOK[0-9A-Z]*'| sort)"
+uiErrors="$(grep -Ro 'WOK[0-9A-Z]*' ui/js/ | cut -d: -f2 | sort| uniq)"
+
+# all errors on i18n are present in js/html files: success
+if [ "$errors" == "$uiErrors" ]; then
+    echo "UI errors codes are correct"
+else
+    echo "Error while checking UI errors codes."
+    diff  <(echo "$errors" ) <(echo "$uiErrors")
+fi
diff --git a/src/wok/plugins/kimchi/Makefile.am b/src/wok/plugins/kimchi/Makefile.am
index 8a55b23..250dc83 100644
--- a/src/wok/plugins/kimchi/Makefile.am
+++ b/src/wok/plugins/kimchi/Makefile.am
@@ -65,7 +65,7 @@ check-local:
 
 	$(PEP8) --version
 	$(PEP8) --filename '*.py,*.py.in' --exclude="$(PEP8_BLACKLIST)" .
-
+	./check_ui_code_errors.sh
 
 # Link built mo files in the source tree to enable use of translations from
 # within the source tree
diff --git a/src/wok/plugins/kimchi/check_ui_code_errors.sh b/src/wok/plugins/kimchi/check_ui_code_errors.sh
new file mode 100755
index 0000000..e44c688
--- /dev/null
+++ b/src/wok/plugins/kimchi/check_ui_code_errors.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2015
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+
+errors="$(cat ui/pages/i18n.json.tmpl | grep -o 'KCH[0-9A-Z]*'| sort)"
+uiErrors="$(grep -Ro 'KCH[0-9A-Z]*' ui/js/ | cut -d: -f2 | sort| uniq)"
+
+# all errors on i18n are present in js/html files: success
+if [ "$errors" == "$uiErrors" ]; then
+    echo "UI errors codes are correct"
+else
+    echo "Error while checking UI errors codes."
+    diff  <(echo "$errors" ) <(echo "$uiErrors")
+fi
diff --git a/src/wok/plugins/kimchi/model/vms.py b/src/wok/plugins/kimchi/model/vms.py
index 7e12b91..366f1b4 100644
--- a/src/wok/plugins/kimchi/model/vms.py
+++ b/src/wok/plugins/kimchi/model/vms.py
@@ -1520,9 +1520,9 @@ class VMModel(object):
     def migration_pre_check(self, remote_host, user, password):
         self._check_if_host_not_localhost(remote_host)
         self._check_if_password_less_login_enabled(
-           remote_host,
-           user,
-           password
+            remote_host,
+            user,
+            password
         )
         self._check_if_migrating_same_arch_hypervisor(remote_host, user)
 
-- 
2.1.0




More information about the Kimchi-devel mailing list