diff options
-rw-r--r-- | scripts/check.py | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/scripts/check.py b/scripts/check.py index 1dfc899..a49fc29 100644 --- a/scripts/check.py +++ b/scripts/check.py @@ -12,8 +12,16 @@ class cmd_check(Command): name = 'check' usage_args = '' + def run_pylint(self, args): + p = subprocess.Popen([ 'pylint' ] + args, stdout=subprocess.PIPE) + + output = p.stdout.read() + print output + + return len(output.strip()) > 0 + def lint(self, module): - subprocess.call(['pylint', module, '--rcfile=%s' % pylintrc_path]) + return self.run_pylint([module, '--rcfile=%s' % pylintrc_path]) def lint_path(self, path): cwd = os.getcwd() @@ -25,21 +33,27 @@ class cmd_check(Command): if f.endswith('.py'): python_files.append(os.path.join(path, f)) - cmd = ['pylint', '--rcfile=%s' % pylintrc_path] - cmd.extend(python_files) - subprocess.call(cmd) + args = ['--rcfile=%s' % pylintrc_path] + python_files + result = self.run_pylint(args) os.chdir(cwd) + return result + def run(self, config, options, args): + result = True + print 'Pylint the sugar shell...' sugar_path = os.path.join(config.prefix, 'share', 'sugar') - self.lint_path(os.path.join(sugar_path, 'shell')) - self.lint_path(os.path.join(sugar_path, 'service')) + + result &= self.lint_path(os.path.join(sugar_path, 'shell')) + result &= self.lint_path(os.path.join(sugar_path, 'service')) print 'Pylint the sugar module...' - self.lint('sugar') + result &= self.lint('sugar') + + return result register_command(cmd_check) |