]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Improve error if python can't run pep8
authorNick Harper <nharper@fb.com>
Tue, 19 Mar 2013 18:44:49 +0000 (11:44 -0700)
committerNick Harper <nharper@fb.com>
Tue, 19 Mar 2013 18:44:49 +0000 (11:44 -0700)
Summary:
On systems with an ancient version of python, the pep8 linter won't run.
Instead of blowing up in the user's face, we should display a nice error
message.

Test Plan:
Put /usr/bin (where the ancient version of python is) at the beginning of
my path and tried to lint some python. I got a nice error instead of a
stack trace.

Reviewers: epriestley, wez

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5356

src/lint/linter/ArcanistPEP8Linter.php

index f798bf088d6b0a05af48ec8992a1f2f07b07ba0d..215a8a43d4e9e7b9e247944064b218f5a7c956bd 100644 (file)
@@ -74,6 +74,13 @@ final class ArcanistPEP8Linter extends ArcanistFutureLinter {
       }
     }
 
+    list(, $stderr) = execx('/usr/bin/env python -V');
+    if ($stderr < 'Python 2.5') {
+      throw new ArcanistUsageException(
+        "Python 2.5 or greater is required to run the PEP8 Python linter, but ".
+        rtrim($stderr)." was found instead.");
+    }
+
     return $bin;
   }