Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into doc-htt-client-ssl-v…
Browse files Browse the repository at this point in the history
…alid-7879
  • Loading branch information
glyph committed Jan 14, 2017
2 parents 8da7cdd + 80ce0cc commit b341886
Show file tree
Hide file tree
Showing 69 changed files with 2,161 additions and 457 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ matrix:
# Twistedchecker is running as a separate job so that we can ignore if it
# fails.
- python: 2.7
env: TOXENV=txchecker-travis
env: TOXENV=txchecker-travis-required
- python: 2.7
env: TOXENV=txchecker-travis-all
allow_failures:
- env: TOXENV=txchecker-travis-all


addons:
Expand Down
40 changes: 23 additions & 17 deletions .travis/twistedchecker-trunk-diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,43 @@
# * SCRIPT_NAME twisted/words/
# * SCRIPT_NAME twisted.words

target=$1
set -e # Exit with error is a command exits with an unchecked error.
set -u # Exit with error if an undefined variable is dereferenced.

target="$1";

# FIXME: https://github.com/twisted/twistedchecker/issues/116
# Since for unknown modules twistedchecker will return the same error, the
# diff will fail to detect that we are trying to check an invalid path or
# module.
# This is why we check that the argument is a path and if not a path, it is
# an importable module.
if [ ! -d "$target" ]; then
python -c "import $target" 2> /dev/null
if [ $? -ne 0 ]; then
>&2 echo "$target does not exists as a path or as a module."
exit 1
fi
fi
if [ ! -d "${target}" ]; then
if ! python -c "import ${target}" 2> /dev/null; then
>&2 echo "${target} does not exists as a path or as a module.";
exit 1;
fi;
fi;

# Make sure we have trunk on the local repo.
git fetch origin +refs/heads/trunk:refs/remotes/origin/trunk
git fetch origin "+refs/heads/trunk:refs/remotes/origin/trunk";

# Explicitly ignore extension modules. See: https://github.com/twisted/twistedchecker/issues/118
mkdir -p build/
twistedchecker --ignore='raiser.so,portmap.so,_sendmsg.so' -f parseable "$target" > build/twistedchecker-branch.report
# Explicitly ignore extension modules.
# See: https://github.com/twisted/twistedchecker/issues/118
mkdir -p build/;
twistedchecker \
--ignore="raiser.so,portmap.so,_sendmsg.so" \
--disable="${TWISTEDCHECKER_SKIP_WARNINGS:-}" \
--output-format=parseable \
"${target}" \
> "build/twistedchecker-branch.report" || true;

# Make sure repo is producing the diff with prefix so that the output of
# `git diff` can be parsed by diff_cover.
git config diff.noprefix false
git config diff.noprefix false;

diff-quality \
--violations=pylint \
--fail-under=100 \
--compare-branch=origin/trunk build/twistedchecker-branch.report

diff_exit_code=$?
exit $diff_exit_code
--compare-branch=origin/trunk \
build/twistedchecker-branch.report;
72 changes: 72 additions & 0 deletions admin/pr_as_branch
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/sh

set -e
set -u


# Usage

usage() {
program=$(basename "$0");

if [ $# != 0 ]; then echo "$@"; echo ""; fi;

echo "${program}: usage:";
echo " ${program} pull_request_number trac_ticket_number branch_name";
echo "";
echo "Note: branch_name should not include the ticket number prefix; that ";
echo "will be added automatically.";
echo "";
echo "${program} creates a branch in the Twisted GitHub repository from a";
echo "forked pull request. This is necessary in order to create a branch";
echo "that is visible to the Buildbot-based builder infrastructure.";
}


# Options

while [ $# != 0 ]; do
case "$1" in
--help)
usage;
exit 0;
;;
--|*) break; ;;
esac;
done;

if [ $# != 3 ]; then
usage "Invalid arguments: $*";
exit 1;
fi;

PR_NUMBER="$1"; shift;
TICKET_NUMBER="$1"; shift;
BRANCH_NAME="$1"; shift;


# Do The Right Thing

#repo="https://github.com/twisted/twisted.git";
repo="git@github.com:twisted/twisted.git";

wc="$(dirname "$(dirname "$0")")/.git";

if [ ! -d "${wc}" ]; then
wc="$(mktemp -d -t twisted.XXXX)";

git clone --depth 1 --progress "${repo}" "${wc}";

cloned=true;
else
cloned=false;
fi;

cd "${wc}";

git fetch origin "refs/pull/${PR_NUMBER}/head";
git push origin "FETCH_HEAD:refs/heads/${TICKET_NUMBER}-${BRANCH_NAME}";

if ${cloned}; then
rm -fr "${wc}";
fi;
5 changes: 4 additions & 1 deletion docs/conch/examples/demo.tac
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ from twisted.conch import manhole_tap
manhole_tap.makeService({"telnetPort": "tcp:6023",
"sshPort": "tcp:6022",
"namespace": {"foo": "bar"},
"passwd": "passwd"}).setServiceParent(application)
"passwd": "passwd",
"sshKeyDir": "<USER DATA DIR>",
"sshKeyName": "server.key",
"sshKeySize": 4096}).setServiceParent(application)
21 changes: 16 additions & 5 deletions docs/conch/examples/demo_draw.tac
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,30 @@

# You can run this .tac file directly with:
# twistd -ny demo_draw.tac
#
# Re-using a private key is dangerous, generate one.
#
# For this example you can use:
#
# $ ckeygen -t rsa -f ssh-keys/ssh_host_rsa_key

"""A trivial drawing application.
"""
A trivial drawing application.
Clients are allowed to connect and spew various characters out over
the terminal. Spacebar changes the drawing character, while the arrow
keys move the cursor.
"""

from twisted.application import internet, service
from twisted.conch.insults import insults
from twisted.conch.telnet import TelnetTransport, TelnetBootstrapProtocol
from twisted.conch.manhole_ssh import ConchFactory, TerminalRealm

from twisted.internet import protocol
from twisted.application import internet, service
from twisted.conch.ssh import keys
from twisted.cred import checkers, portal
from twisted.internet import protocol



class Draw(insults.TerminalProtocol):
"""Protocol which accepts arrow key and spacebar input and places
Expand Down Expand Up @@ -47,7 +56,7 @@ class Draw(insults.TerminalProtocol):
self.terminal.cursorBackward()

def makeService(args):
checker = checkers.InMemoryUsernamePasswordDatabaseDontUse(username="password")
checker = checkers.InMemoryUsernamePasswordDatabaseDontUse(username=b"password")

f = protocol.ServerFactory()
f.protocol = lambda: TelnetTransport(TelnetBootstrapProtocol,
Expand All @@ -67,6 +76,8 @@ def makeService(args):
rlm.chainedProtocolFactory = chainProtocolFactory
ptl = portal.Portal(rlm, [checker])
f = ConchFactory(ptl)
f.publicKeys[b"ssh-rsa"] = keys.Key.fromFile("ssh-keys/ssh_host_rsa_key.pub")
f.privateKeys[b"ssh-rsa"] = keys.Key.fromFile("ssh-keys/ssh_host_rsa_key")
csvc = internet.TCPServer(args['ssh'], f)

m = service.MultiService()
Expand Down
23 changes: 17 additions & 6 deletions docs/conch/examples/demo_insults.tac
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@

# You can run this .tac file directly with:
# twistd -ny demo_insults.tac
#
# Re-using a private key is dangerous, generate one.
#
# For this example you can use:
#
# $ ckeygen -t rsa -f ssh-keys/ssh_host_rsa_key

"""Various simple terminal manipulations using the insults module.
"""
Various simple terminal manipulations using the insults module.
This demo sets up two listening ports: one on 6022 which accepts ssh
connections; one on 6023 which accepts telnet connections. No login
Expand All @@ -21,14 +28,16 @@ animation process.

import random, string

from twisted.python import log
from twisted.internet import protocol, task
from twisted.application import internet, service
from twisted.cred import checkers, portal

from twisted.conch.insults import insults
from twisted.conch.telnet import TelnetTransport, TelnetBootstrapProtocol
from twisted.conch.manhole_ssh import ConchFactory, TerminalRealm
from twisted.conch.ssh import keys
from twisted.cred import checkers, portal
from twisted.internet import protocol, task
from twisted.python import log



class DrawingFinished(Exception):
"""Sentinel exception, raised when no \"frames\" for a particular
Expand Down Expand Up @@ -218,7 +227,7 @@ class DemoProtocol(insults.TerminalProtocol):


def makeService(args):
checker = checkers.InMemoryUsernamePasswordDatabaseDontUse(username="password")
checker = checkers.InMemoryUsernamePasswordDatabaseDontUse(username=b"password")

f = protocol.ServerFactory()
f.protocol = lambda: TelnetTransport(TelnetBootstrapProtocol,
Expand All @@ -238,6 +247,8 @@ def makeService(args):
rlm.chainedProtocolFactory = chainProtocolFactory
ptl = portal.Portal(rlm, [checker])
f = ConchFactory(ptl)
f.publicKeys[b"ssh-rsa"] = keys.Key.fromFile("ssh-keys/ssh_host_rsa_key.pub")
f.privateKeys[b"ssh-rsa"] = keys.Key.fromFile("ssh-keys/ssh_host_rsa_key")
csvc = internet.TCPServer(args['ssh'], f)

m = service.MultiService()
Expand Down
25 changes: 18 additions & 7 deletions docs/conch/examples/demo_manhole.tac
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,34 @@

# You can run this .tac file directly with:
# twistd -ny demo_manhole.tac
#
# Re-using a private key is dangerous, generate one.
#
# For this example you can use:
#
# $ ckeygen -t rsa -f ssh-keys/ssh_host_rsa_key

"""An interactive Python interpreter with syntax coloring.
"""
An interactive Python interpreter with syntax coloring.
Nothing interesting is actually defined here. Two listening ports are
set up and attached to protocols which know how to properly set up a
ColoredManhole instance.
"""

from twisted.conch.manhole import ColoredManhole
from twisted.application import internet, service
from twisted.conch.insults import insults
from twisted.conch.telnet import TelnetTransport, TelnetBootstrapProtocol
from twisted.conch.manhole import ColoredManhole
from twisted.conch.manhole_ssh import ConchFactory, TerminalRealm

from twisted.internet import protocol
from twisted.application import internet, service
from twisted.conch.ssh import keys
from twisted.conch.telnet import TelnetTransport, TelnetBootstrapProtocol
from twisted.cred import checkers, portal
from twisted.internet import protocol



def makeService(args):
checker = checkers.InMemoryUsernamePasswordDatabaseDontUse(username="password")
checker = checkers.InMemoryUsernamePasswordDatabaseDontUse(username=b"password")

f = protocol.ServerFactory()
f.protocol = lambda: TelnetTransport(TelnetBootstrapProtocol,
Expand All @@ -41,6 +50,8 @@ def makeService(args):
rlm.chainedProtocolFactory = chainProtocolFactory
ptl = portal.Portal(rlm, [checker])
f = ConchFactory(ptl)
f.publicKeys[b"ssh-rsa"] = keys.Key.fromFile("ssh-keys/ssh_host_rsa_key.pub")
f.privateKeys[b"ssh-rsa"] = keys.Key.fromFile("ssh-keys/ssh_host_rsa_key")
csvc = internet.TCPServer(args['ssh'], f)

m = service.MultiService()
Expand Down
23 changes: 17 additions & 6 deletions docs/conch/examples/demo_recvline.tac
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@

# You can run this .tac file directly with:
# twistd -ny demo_recvline.tac
#
# Re-using a private key is dangerous, generate one.
#
# For this example you can use:
#
# $ ckeygen -t rsa -f ssh-keys/ssh_host_rsa_key

"""Demonstrates line-at-a-time handling with basic line-editing support.
"""
Demonstrates line-at-a-time handling with basic line-editing support.
This is a variation on the echo server. It sets up two listening
ports: one on 6022 which accepts ssh connections; one on 6023 which
Expand All @@ -18,14 +25,16 @@ HistoricRecvline, which the demo protocol subclasses, provides basic
line editing and input history features.
"""

from twisted.application import internet, service
from twisted.conch import recvline
from twisted.conch.insults import insults
from twisted.conch.telnet import TelnetTransport, TelnetBootstrapProtocol
from twisted.conch.manhole_ssh import ConchFactory, TerminalRealm

from twisted.internet import protocol
from twisted.application import internet, service
from twisted.conch.ssh import keys
from twisted.conch.telnet import TelnetTransport, TelnetBootstrapProtocol
from twisted.cred import checkers, portal
from twisted.internet import protocol



class DemoRecvLine(recvline.HistoricRecvLine):
"""Simple echo protocol.
Expand All @@ -43,7 +52,7 @@ class DemoRecvLine(recvline.HistoricRecvLine):
self.terminal.write(self.ps[self.pn])

def makeService(args):
checker = checkers.InMemoryUsernamePasswordDatabaseDontUse(username="password")
checker = checkers.InMemoryUsernamePasswordDatabaseDontUse(username=b"password")

f = protocol.ServerFactory()
f.protocol = lambda: TelnetTransport(TelnetBootstrapProtocol,
Expand All @@ -63,6 +72,8 @@ def makeService(args):
rlm.chainedProtocolFactory = chainProtocolFactory
ptl = portal.Portal(rlm, [checker])
f = ConchFactory(ptl)
f.publicKeys[b"ssh-rsa"] = keys.Key.fromFile("ssh-keys/ssh_host_rsa_key.pub")
f.privateKeys[b"ssh-rsa"] = keys.Key.fromFile("ssh-keys/ssh_host_rsa_key")
csvc = internet.TCPServer(args['ssh'], f)

m = service.MultiService()
Expand Down
Loading

0 comments on commit b341886

Please sign in to comment.