Repository: oppia/oppia

Issue:
Pylint errors does not allow pre_push_hook to fail
In case of a Pylint error the `pre_push_hook` should fail. This is not observed currently as the error code returned from the `pre_commit_linter` in case of a Pylint error is zero (should be non-zero).

Following is an example:
```
> python2 scripts/pre_commit_linter.py; echo $?
Starting directive scope check
----------------------------------------
SUCCESS  Directive scope check passed

----------------------------------------

Starting controller dependency line break check
----------------------------------------
SUCCESS  Controller dependency line break check passed

----------------------------------------

Starting HTML directive name check
----------------------------------------

----------------------------------------

There are no files to be checked.
Starting import-order checks
----------------------------------------

----------------------------------------

Starting newline-at-EOF checks
----------------------------------------

----------------------------------------

(1 files checked, 0 errors found)
SUCCESS   Newline character checks passed
Starting docstring checks
----------------------------------------

----------------------------------------

SUCCESS   Docstring check passed
Starting comment checks
----------------------------------------

----------------------------------------

SUCCESS   Comments check passed
Starting HTML tag and attribute check
----------------------------------------
SUCCESS  HTML tag and attribute check passed

----------------------------------------

Starting HTML linter...
----------------------------------------

----------------------------------------

SUCCESS   HTML linting passed
HTML linting finished.

Starting linter...
Starting CSS, Javascript and Python Linting
----------------------------------------
There are no CSS files to lint.
There are no CSS files to lint.
There are no JavaScript files to lint.
Linting 1 Python files
Linting Python files 1 to 1...
Using config file /home/jude/foss/oppia/.pylintrc
Python linting finished.


Summary of Errors:
----------------------------------------



************* Module oppia.scripts.pre_commit_linter
W:467, 4: Unused variable 'temp' (unused-variable)

------------------------------------------------------------------
Your code has been rated at 9.99/10 (previous run: 9.99/10, +0.00)



Starting Pattern Checks
----------------------------------------

----------------------------------------

There are no files to be checked.
Starting copyright notice check
----------------------------------------
SUCCESS  Copyright notice check passed

----------------------------------------

0
```
The last line denotes the status code which should be non-zero.
Pylint errors does not allow pre_push_hook to fail
In case of a Pylint error the `pre_push_hook` should fail. This is not observed currently as the error code returned from the `pre_commit_linter` in case of a Pylint error is zero (should be non-zero).

Following is an example:
```
> python2 scripts/pre_commit_linter.py; echo $?
Starting directive scope check
----------------------------------------
SUCCESS  Directive scope check passed

----------------------------------------

Starting controller dependency line break check
----------------------------------------
SUCCESS  Controller dependency line break check passed

----------------------------------------

Starting HTML directive name check
----------------------------------------

----------------------------------------

There are no files to be checked.
Starting import-order checks
----------------------------------------

----------------------------------------

Starting newline-at-EOF checks
----------------------------------------

----------------------------------------

(1 files checked, 0 errors found)
SUCCESS   Newline character checks passed
Starting docstring checks
----------------------------------------

----------------------------------------

SUCCESS   Docstring check passed
Starting comment checks
----------------------------------------

----------------------------------------

SUCCESS   Comments check passed
Starting HTML tag and attribute check
----------------------------------------
SUCCESS  HTML tag and attribute check passed

----------------------------------------

Starting HTML linter...
----------------------------------------

----------------------------------------

SUCCESS   HTML linting passed
HTML linting finished.

Starting linter...
Starting CSS, Javascript and Python Linting
----------------------------------------
There are no CSS files to lint.
There are no CSS files to lint.
There are no JavaScript files to lint.
Linting 1 Python files
Linting Python files 1 to 1...
Using config file /home/jude/foss/oppia/.pylintrc
Python linting finished.


Summary of Errors:
----------------------------------------



************* Module oppia.scripts.pre_commit_linter
W:467, 4: Unused variable 'temp' (unused-variable)

------------------------------------------------------------------
Your code has been rated at 9.99/10 (previous run: 9.99/10, +0.00)



Starting Pattern Checks
----------------------------------------

----------------------------------------

There are no files to be checked.
Starting copyright notice check
----------------------------------------
SUCCESS  Copyright notice check passed

----------------------------------------

0
```
The last line denotes the status code which should be non-zero.


Discussion:

Resolving patch:
diff --git a/scripts/pre_commit_linter.py b/scripts/pre_commit_linter.py
--- a/scripts/pre_commit_linter.py
+++ b/scripts/pre_commit_linter.py
@@ -750,7 +750,7 @@ def _pre_commit_linter(all_files):
     number_of_files_to_lint = sum(
         len(file_group) for file_group in file_groups_to_lint)
 
-    timeout_multiplier = 1000
+    timeout_multiplier = 2000
     for file_group, process in zip(file_groups_to_lint, linting_processes):
         # try..except block is needed to catch ZeroDivisionError
         # when there are no CSS, HTML, JavaScript and Python files to lint.
@@ -771,10 +771,15 @@ def _pre_commit_linter(all_files):
     print 'Summary of Errors:'
     print '----------------------------------------'
     summary_messages = []
-    summary_messages.append(css_in_html_result.get())
-    summary_messages.append(css_result.get())
-    summary_messages.append(js_result.get())
-    summary_messages.append(py_result.get())
+
+    result_queues = [
+        css_in_html_result, css_result,
+        js_result, py_result]
+
+    for result_queue in result_queues:
+        while not result_queue.empty():
+            summary_messages.append(result_queue.get())
+
     print '\n'.join(summary_messages)
     print ''
     return summary_messages


Test patch:
diff --git a/core/domain/exp_services_test.py b/core/domain/exp_services_test.py
--- a/core/domain/exp_services_test.py
+++ b/core/domain/exp_services_test.py
@@ -208,7 +208,8 @@ def _create_search_query(self, terms, categories, languages):
 
         Args:
             terms: list(str). A list of terms to be added in the query.
-            categories: list(str). A list of categories to be added in the query.
+            categories: list(str). A list of categories to be added in the
+                query.
             languages: list(str). A list of languages to be added in the query.
 
         Returns: