Skip to content

Instantly share code, notes, and snippets.

@mikeconley
Created November 18, 2012 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeconley/4107110 to your computer and use it in GitHub Desktop.
Save mikeconley/4107110 to your computer and use it in GitHub Desktop.
diff --git a/bot/reviewbot/tools/builtbot.py b/bot/reviewbot/tools/builtbot.py
new file mode 100644
index 0000000..666244c
--- /dev/null
+++ b/bot/reviewbot/tools/builtbot.py
@@ -0,0 +1,49 @@
+from reviewbot.tools.process import execute
+from reviewbot.tools import Tool
+
+
+class builtbot(Tool):
+ name = 'BuilBot try plugin'
+ version = '0.0'
+ description = "Attempt to build given diff on your buildbot servers"
+ options = [
+ # Buildmaster, run automatically, username, password, port,
+ {
+ 'name': 'max_line_length',
+ 'field_type': 'django.forms.IntegerField',
+ 'default': 79,
+ 'field_options': {
+ 'label': 'Maximum Line Length',
+ 'help_text': 'The maximum line length PEP8 will check for.',
+ 'required': True,
+ },
+ },
+ ]
+
+ def handle_file(self, f):
+ if not f.dest_file.endswith('.py'):
+ # Ignore the file.
+ return False
+
+ path = f.get_patched_file_path()
+ if not path:
+ return False
+
+ output = execute(
+ [
+ 'pep8',
+ '-r',
+ '--max-line-length=%i' % self.settings['max_line_length'],
+ path
+ ],
+ split_lines=True,
+ ignore_errors=True)
+
+ for line in output:
+ parsed = line.split(':')
+ lnum = int(parsed[1])
+ col = int(parsed[2])
+ msg = parsed[3]
+ f.comment('Col: %s\n%s' % (col, msg), lnum)
+
+ return True
--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment