Skip to content

Commit

Permalink
monkeypatch shell completions defintions for older twisted
Browse files Browse the repository at this point in the history
The shell completions support was added in twisted 11.1.0. When
running with older twisted, add completions definitions we are using
to twisted.python.usage module.
  • Loading branch information
Elmir Jagudin committed Jun 5, 2013
1 parent 9f0b93c commit e5140ce
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 10 deletions.
27 changes: 20 additions & 7 deletions master/buildbot/monkeypatches/__init__.py
Expand Up @@ -67,14 +67,20 @@ def patch_gatherResults():
from buildbot.monkeypatches import gatherResults
gatherResults.patch()

def patch_twisted_completions():
"""
Shell completion support was introduced in twisted 11.1.0. Add dummy
completions definitions for older twisted.
"""
if twisted.version < versions.Version('twisted', 11, 1, 0):
from buildbot.monkeypatches import twisted_completions
twisted_completions.patch()

def patch_all(for_tests=False):
patch_bug4881()
patch_bug4520()
patch_bug5079()
patch_sqlalchemy2364()
patch_sqlalchemy2189()
patch_gatherResults()
def patch_all(for_scripts=False, for_tests=False):
if for_scripts:
# only apply twisted completions patch, skip the rest
patch_twisted_completions()
return

if for_tests:
from buildbot.monkeypatches import servicechecks
Expand All @@ -83,3 +89,10 @@ def patch_all(for_tests=False):
testcase_patch.patch_testcase_patch()
from buildbot.monkeypatches import testcase_synctest
testcase_synctest.patch_testcase_synctest()

patch_bug4881()
patch_bug4520()
patch_bug5079()
patch_sqlalchemy2364()
patch_sqlalchemy2189()
patch_gatherResults()
29 changes: 29 additions & 0 deletions master/buildbot/monkeypatches/twisted_completions.py
@@ -0,0 +1,29 @@
# This file is part of Buildbot. Buildbot is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members

from twisted.python import usage


def _dummy(**_):
pass


def patch():
"""
Add dummy completions definitions to twisted.python.usage.
"""
usage.Completions = _dummy
usage.CompleteDirs = _dummy
usage.CompleteFiles = _dummy
4 changes: 4 additions & 0 deletions master/buildbot/scripts/runner.py
Expand Up @@ -25,8 +25,12 @@
import re
import sys

from buildbot import monkeypatches
monkeypatches.patch_all(for_scripts=True)

from buildbot.scripts import base


# Note that the terms 'options' and 'config' are used interchangeably here - in
# fact, they are interchanged several times. Caveat legator.

Expand Down
20 changes: 17 additions & 3 deletions slave/buildslave/monkeypatches/__init__.py
Expand Up @@ -42,9 +42,23 @@ def patch_testcase_assert_raises_regexp():
from buildslave.monkeypatches import testcase_assert
testcase_assert.patch()

def patch_all(for_tests=False):
patch_bug4881()
patch_bug5079()
def patch_twisted_completions():
"""
Shell completion support was introduced in twisted 11.1.0. Add dummy
completions definitions for older twisted.
"""
if twisted.version < versions.Version('twisted', 11, 1, 0):
from buildslave.monkeypatches import twisted_completions
twisted_completions.patch()

def patch_all(for_scripts=False, for_tests=False):
if for_scripts:
# only apply twisted completions patch, skip the rest
patch_twisted_completions()
return

if for_tests:
patch_testcase_assert_raises_regexp()

patch_bug4881()
patch_bug5079()
28 changes: 28 additions & 0 deletions slave/buildslave/monkeypatches/twisted_completions.py
@@ -0,0 +1,28 @@
# This file is part of Buildbot. Buildbot is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members

from twisted.python import usage


def _dummy(**_):
pass


def patch():
"""
Add dummy completions definitions to twisted.python.usage.
"""
usage.Completions = _dummy
usage.CompleteDirs = _dummy
3 changes: 3 additions & 0 deletions slave/buildslave/scripts/runner.py
Expand Up @@ -19,6 +19,9 @@
import sys
import re
from twisted.python import usage, reflect
from buildslave import monkeypatches

monkeypatches.patch_all(for_scripts=True)

# the create/start/stop commands should all be run as the same user,
# preferably a separate 'buildbot' account.
Expand Down

0 comments on commit e5140ce

Please sign in to comment.