You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2017/04/12 01:04:01 UTC

[1/2] mesos git commit: Fixed linting script when run with no arguments.

Repository: mesos
Updated Branches:
  refs/heads/master 476a8096d -> 7c6969941


Fixed linting script when run with no arguments.

The python linter needs to be run in a virtualenv due to how
it requires multiple modules that may or may not be installed
(or the correct version) in the host environment.  We originally
re-made this virtualenv whenever some specific files were
changed (such as the pip-requirements.txt, which describes
the virtualenv's dependencies).

However, this logic was missing the case where we ran
support/mesos-style.py with no arguments.  In this case, the
entire codebase is linted.  Therefore, the virtualenv should
also be rebuilt in this case.


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2e55afb3
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2e55afb3
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2e55afb3

Branch: refs/heads/master
Commit: 2e55afb35a912d0b6f8968bfb34832e645cb7903
Parents: 476a809
Author: Joseph Wu <jo...@apache.org>
Authored: Tue Apr 11 17:52:28 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Tue Apr 11 17:52:28 2017 -0700

----------------------------------------------------------------------
 support/mesos-style.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2e55afb3/support/mesos-style.py
----------------------------------------------------------------------
diff --git a/support/mesos-style.py b/support/mesos-style.py
index 6489c2d..5828040 100755
--- a/support/mesos-style.py
+++ b/support/mesos-style.py
@@ -296,12 +296,15 @@ class PyLinter(LinterBase):
 
         if 'pip-requirements.txt' in basenames:
             print 'The "pip-requirements.txt" file has changed.'
-            print 'Rebuilding virtualenv ...'
             return True
 
         if 'mesos.bash_completion' in basenames:
             print 'The "mesos.bash_completion" file has changed.'
-            print 'Rebuilding virtualenv ...'
+            return True
+
+        # NOTE: If the file list is empty, we are linting the entire codebase.
+        # We should always rebuild the virtualenv in this case.
+        if len(file_list) <= 0:
             return True
 
         return False
@@ -312,6 +315,8 @@ class PyLinter(LinterBase):
         '''
         cli_dir = os.path.abspath(self.source_dirs[0])
 
+        print 'Rebuilding virtualenv ...'
+
         p = subprocess.Popen(
             [os.path.join(cli_dir, 'bootstrap')],
             stdout=subprocess.PIPE)


[2/2] mesos git commit: Fixed some style issues in the style linting script.

Posted by jo...@apache.org.
Fixed some style issues in the style linting script.

Running `support/mesos-style.py` on itself results in a couple
dozen errors.  This fixes a few minor whitespace/naming errors.


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/7c696994
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/7c696994
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/7c696994

Branch: refs/heads/master
Commit: 7c696994110ec4223edc1d83d4212b116157c8cf
Parents: 2e55afb
Author: Joseph Wu <jo...@apache.org>
Authored: Tue Apr 11 18:01:18 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Tue Apr 11 18:02:45 2017 -0700

----------------------------------------------------------------------
 support/mesos-style.py | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7c696994/support/mesos-style.py
----------------------------------------------------------------------
diff --git a/support/mesos-style.py b/support/mesos-style.py
index 5828040..53ffe3b 100755
--- a/support/mesos-style.py
+++ b/support/mesos-style.py
@@ -60,7 +60,7 @@ class LinterBase(object):
         '''
         exclude_file_regex = re.compile(self.exclude_files)
         source_criteria_regex = re.compile(self.source_files)
-        for root, dirs, files in os.walk(root_dir):
+        for root, _, files in os.walk(root_dir):
             for name in files:
                 path = os.path.join(root, name)
                 if exclude_file_regex.search(path) is not None:
@@ -268,8 +268,8 @@ class PyLinter(LinterBase):
             ['. {virtualenv_dir}/bin/activate; \
              PYTHONPATH={lib_dir}:{bin_dir} pylint --rcfile={config} --ignore={ignore} {files}'.\
              format(virtualenv_dir=os.path.join(cli_dir, '.virtualenv'),
-                    lib_dir=os.path.join(cli_dir,'lib'),
-                    bin_dir=os.path.join(cli_dir,'bin'),
+                    lib_dir=os.path.join(cli_dir, 'lib'),
+                    bin_dir=os.path.join(cli_dir, 'bin'),
                     config=os.path.join(cli_dir, 'pylint.config'),
                     ignore=os.path.join(cli_dir, 'bin', 'mesos'),
                     files=source_files)],
@@ -292,7 +292,7 @@ class PyLinter(LinterBase):
 
         basenames = []
         if file_list:
-            basenames = [os.path.basename(file) for file in file_list]
+            basenames = [os.path.basename(path) for path in file_list]
 
         if 'pip-requirements.txt' in basenames:
             print 'The "pip-requirements.txt" file has changed.'
@@ -329,16 +329,16 @@ class PyLinter(LinterBase):
 
         if p.returncode != 0:
             sys.stderr.write(output)
-            sys.exit(1);
+            sys.exit(1)
 
     def main(self, file_list):
-       '''
-       Override main to rebuild our virtualenv if necessary.
-       '''
-       if self.__should_build_virtualenv(file_list):
-           self.__build_virtualenv()
+        '''
+        Override main to rebuild our virtualenv if necessary.
+        '''
+        if self.__should_build_virtualenv(file_list):
+            self.__build_virtualenv()
 
-       return super(PyLinter, self).main(file_list)
+        return super(PyLinter, self).main(file_list)
 
 
 if __name__ == '__main__':