Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into 8346-rodrigc-pep3113
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkowl committed Jun 11, 2016
2 parents 0e8bfbf + 63f143b commit 6f67bb0
Show file tree
Hide file tree
Showing 136 changed files with 1,244 additions and 946 deletions.
41 changes: 41 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
language: python
sudo: false

branches:
only:
- trunk

addons:
apt:
packages:
- libssl-dev
- libssl1.0.0

cache:
directories:
- $HOME/.cache/pip

python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"

env:
global:
- TRIAL_REPORTER=text

install:
- pip install tox tox-travis


# FIXME: https://twistedmatrix.com/trac/ticket/8373
# By default, Travis only clones one branch.
# Some tests require the presence of the `trunk` branch so here we are, also
# fetching `trunk` for each test.
before_script:
- git remote set-branches --add origin trunk
- git fetch origin trunk

script:
- tox
7 changes: 6 additions & 1 deletion CONTRIBUTING
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ https://twistedmatrix.com/trac/wiki/ContributingToTwistedLabs

Twisted has a Code of Conduct, available at code_of_conduct.md.

**Warning: pull requests are ignored!** File a ticket at:
**Warning: pull requests are ignored** unless they have an associated ticket in trac.

File a ticket at:

https://twistedmatrix.com/trac/newticket

Twisted uses Trac to keep track of bugs, feature requests, and associated
patches because GitHub doesn't provide adequate tooling for its community.

For a PR to be accepted it needs to have at least all Travis CI tests passing.
The Travis CI tests currently represent only a subset of the all the platforms Twisted supports, so the buildbot tests are still the actual gate for PR acceptance.
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Twisted 16.2.0

|pypi|
|coverage|
|travis|

.. code::
Expand Down Expand Up @@ -103,3 +104,6 @@ Again, see the included `LICENSE <LICENSE>`_ file for specific legal details.

.. |pypi| image:: http://img.shields.io/pypi/v/twisted.svg
.. _pypi: https://pypi.python.org/pypi/twisted

.. |travis| image:: https://travis-ci.org/twisted/twisted.svg?branch=trunk
.. _travis https://travis-ci.org/twisted/twisted
22 changes: 22 additions & 0 deletions bin/admin/check-topfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

"""
Check that the current commits since branching have a topfile.
"""

from __future__ import absolute_import, division, print_function

import sys, os
extra = os.path.dirname(os.path.dirname(sys.argv[0]))
sys.path.insert(0, extra)
try:
import _preamble
except ImportError:
sys.exc_clear()
sys.path.remove(extra)

from twisted.python._release import CheckTopfileScript

CheckTopfileScript(print).main(sys.argv[1:])
3 changes: 2 additions & 1 deletion docs/conch/benchmarks/buffering_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
L{BufferingMixin<twisted.conch.mixin.BufferingMixin>} mixed in to perform
Nagle-like write coalescing.
"""
from __future__ import print_function

from sys import stdout
from pprint import pprint
Expand Down Expand Up @@ -170,7 +171,7 @@ def main(args=None):
def cbBenchmark(result):
pprint(result)
def ebBenchmark(err):
print err.getTraceback()
print(err.getTraceback())
d.addCallbacks(cbBenchmark, ebBenchmark)
def stopReactor(ign):
reactor.stop()
Expand Down
21 changes: 11 additions & 10 deletions docs/conch/examples/sshsimpleclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
from __future__ import print_function

from twisted.conch.ssh import transport, userauth, connection, common, keys, channel
from twisted.internet import defer, protocol, reactor
Expand Down Expand Up @@ -35,11 +36,11 @@

class SimpleTransport(transport.SSHClientTransport):
def verifyHostKey(self, hostKey, fingerprint):
print 'Server host key fingerprint: %s' % fingerprint
print('Server host key fingerprint: %s' % fingerprint)
if SERVER_FINGERPRINT == fingerprint:
return defer.succeed(True)
else:
print 'Bad host key. Expecting: %s' % SERVER_FINGERPRINT
print('Bad host key. Expecting: %s' % SERVER_FINGERPRINT)
return defer.fail(Exception('Bad server key'))

def connectionSecure(self):
Expand All @@ -53,8 +54,8 @@ def getPassword(self):
return defer.succeed(getpass.getpass("%s@%s's password: " % (USER, HOST)))

def getGenericAnswers(self, name, instruction, questions):
print name
print instruction
print(name)
print(instruction)
answers = []
for prompt, echo in questions:
if echo:
Expand Down Expand Up @@ -96,35 +97,35 @@ class TrueChannel(channel.SSHChannel):
name = 'session' # needed for commands

def openFailed(self, reason):
print 'true failed', reason
print('true failed', reason)

def channelOpen(self, ignoredData):
self.conn.sendRequest(self, 'exec', common.NS('true'))

def request_exit_status(self, data):
status = struct.unpack('>L', data)[0]
print 'true status was: %s' % status
print('true status was: %s' % status)
self.loseConnection()

class FalseChannel(channel.SSHChannel):
name = 'session'

def openFailed(self, reason):
print 'false failed', reason
print('false failed', reason)

def channelOpen(self, ignoredData):
self.conn.sendRequest(self, 'exec', common.NS('false'))

def request_exit_status(self, data):
status = struct.unpack('>L', data)[0]
print 'false status was: %s' % status
print('false status was: %s' % status)
self.loseConnection()

class CatChannel(channel.SSHChannel):
name = 'session'

def openFailed(self, reason):
print 'echo failed', reason
print('echo failed', reason)

def channelOpen(self, ignoredData):
self.data = ''
Expand All @@ -139,7 +140,7 @@ def dataReceived(self, data):
self.data += data

def closed(self):
print 'got data from cat: %s' % repr(self.data)
print('got data from cat: %s' % repr(self.data))
self.loseConnection()
reactor.stop()

Expand Down
4 changes: 2 additions & 2 deletions docs/conch/examples/sshsimpleserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
# Avoid 1024 bit primes https://weakdh.org
#
PRIMES = {
2048: [(2L, 24265446577633846575813468889658944748236936003103970778683933705240497295505367703330163384138799145013634794444597785054574812547990300691956176233759905976222978197624337271745471021764463536913188381724789737057413943758936963945487690939921001501857793275011598975080236860899147312097967655185795176036941141834185923290769258512343298744828216530595090471970401506268976911907264143910697166165795972459622410274890288999065530463691697692913935201628660686422182978481412651196163930383232742547281180277809475129220288755541335335798837173315854931040199943445285443708240639743407396610839820418936574217939L)],
4096: [(2L, 889633836007296066695655481732069270550615298858522362356462966213994239650370532015908457586090329628589149803446849742862797136176274424808060302038380613106889959709419621954145635974564549892775660764058259799708313210328185716628794220535928019146593583870799700485371067763221569331286080322409646297706526831155237865417316423347898948704639476720848300063714856669054591377356454148165856508207919637875509861384449885655015865507939009502778968273879766962650318328175030623861285062331536562421699321671967257712201155508206384317725827233614202768771922547552398179887571989441353862786163421248709273143039795776049771538894478454203924099450796009937772259125621285287516787494652132525370682385152735699722849980820612370907638783461523042813880757771177423192559299945620284730833939896871200164312605489165789501830061187517738930123242873304901483476323853308396428713114053429620808491032573674192385488925866607192870249619437027459456991431298313382204980988971292641217854130156830941801474940667736066881036980286520892090232096545650051755799297658390763820738295370567143697617670291263734710392873823956589171067167839738896249891955689437111486748587887718882564384870583135509339695096218451174112035938859L)],
2048: [(2, 24265446577633846575813468889658944748236936003103970778683933705240497295505367703330163384138799145013634794444597785054574812547990300691956176233759905976222978197624337271745471021764463536913188381724789737057413943758936963945487690939921001501857793275011598975080236860899147312097967655185795176036941141834185923290769258512343298744828216530595090471970401506268976911907264143910697166165795972459622410274890288999065530463691697692913935201628660686422182978481412651196163930383232742547281180277809475129220288755541335335798837173315854931040199943445285443708240639743407396610839820418936574217939)],
4096: [(2, 889633836007296066695655481732069270550615298858522362356462966213994239650370532015908457586090329628589149803446849742862797136176274424808060302038380613106889959709419621954145635974564549892775660764058259799708313210328185716628794220535928019146593583870799700485371067763221569331286080322409646297706526831155237865417316423347898948704639476720848300063714856669054591377356454148165856508207919637875509861384449885655015865507939009502778968273879766962650318328175030623861285062331536562421699321671967257712201155508206384317725827233614202768771922547552398179887571989441353862786163421248709273143039795776049771538894478454203924099450796009937772259125621285287516787494652132525370682385152735699722849980820612370907638783461523042813880757771177423192559299945620284730833939896871200164312605489165789501830061187517738930123242873304901483476323853308396428713114053429620808491032573674192385488925866607192870249619437027459456991431298313382204980988971292641217854130156830941801474940667736066881036980286520892090232096545650051755799297658390763820738295370567143697617670291263734710392873823956589171067167839738896249891955689437111486748587887718882564384870583135509339695096218451174112035938859)],
}


Expand Down
2 changes: 1 addition & 1 deletion docs/conch/howto/conch_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ The Channel
self.catData += data
def closed(self):
print 'We got this from "cat":', self.catData
print('We got this from "cat":', self.catData)
Expand Down
5 changes: 3 additions & 2 deletions docs/conch/howto/listings/echoclient_shared_ssh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
from __future__ import print_function

if __name__ == '__main__':
import sys
Expand All @@ -19,11 +20,11 @@

class PrinterProtocol(Protocol):
def dataReceived(self, data):
print "Got some data:", data,
print("Got some data:", data, end=' ')


def connectionLost(self, reason):
print "Lost my connection"
print("Lost my connection")
self.factory.done.callback(None)


Expand Down
3 changes: 2 additions & 1 deletion docs/conch/howto/listings/echoclient_ssh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
from __future__ import print_function

if __name__ == '__main__':
import sys
Expand Down Expand Up @@ -57,7 +58,7 @@ def sendNoise(self):


def dataReceived(self, data):
print "Server says:", data
print("Server says:", data)
self.sendNoise()


Expand Down
5 changes: 5 additions & 0 deletions docs/core/development/policy/code-dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,9 @@ you are interested in this, you are on your own. See `stdeb <http://github.com/
this.


Travis CI integration
---------------------

Travis CI is configured to run a subset of the official Buildbot builders for each push to a PR or to ``trunk``

The tests are executed using ``tox-travis``. See the ``tox.ini`` file for the actual configuration.
2 changes: 1 addition & 1 deletion docs/core/development/policy/coding-standard.rst
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ C Code
C code must be optional, and work across multiple platforms (MSVC++9/10/14 for Pythons 2.7, 3.3/3.4, and 3.5 on Windows, as well as recent GCCs and Clangs for Linux, OS X, and FreeBSD).

C code should be kept in external bindings packages which Twisted depends on.
If creating new C extension modules, using `cffi <https://cffi.readthedocs.org/en/latest/>`_ is highly encouraged, as it will perform well on PyPy and CPython, and be easier to use on Python 2 and 3.
If creating new C extension modules, using `cffi <https://cffi.readthedocs.io/en/latest/>`_ is highly encouraged, as it will perform well on PyPy and CPython, and be easier to use on Python 2 and 3.
Consider optimizing for `PyPy <http://pypy.org/performance.html>`_ instead of creating bespoke C code.


Expand Down
2 changes: 1 addition & 1 deletion docs/core/examples/bananabench.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def runTests(self, testData):
bench.runTests(testData)
testData = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"]
bench.runTests(testData)
testData = [1l, 2l, 3l, 4l, 5l, 6l, 7l, 8l, 9l, 10l]
testData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
bench.runTests(testData)
testData = [1, 2, [3, 4], [30.5, 40.2], 5, ["six", "seven", ["eight", 9]], [10], []]
bench.runTests(testData)
Expand Down
2 changes: 1 addition & 1 deletion docs/core/examples/pbbenchserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def printCallsPerSec(self):
reactor.callLater(1, self.printCallsPerSec)

def perspective_complexTypes(self):
return ['a', 1, 1l, 1.0, [], ()]
return ['a', 1, 1, 1.0, [], ()]


class SimpleRealm:
Expand Down
18 changes: 9 additions & 9 deletions docs/core/howto/clients.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,17 @@ Here is an example of a simple ``ClientFactory`` that uses the ``Echo`` protocol
class EchoClientFactory(ClientFactory):
def startedConnecting(self, connector):
print 'Started to connect.'
print('Started to connect.')
def buildProtocol(self, addr):
print 'Connected.'
print('Connected.')
return Echo()
def clientConnectionLost(self, connector, reason):
print 'Lost connection. Reason:', reason
print('Lost connection. Reason:', reason)
def clientConnectionFailed(self, connector, reason):
print 'Connection failed. Reason:', reason
print('Connection failed. Reason:', reason)
To connect this ``EchoClientFactory`` to a server, you could use
this code:
Expand Down Expand Up @@ -232,20 +232,20 @@ a ``ReconnectingClientFactory`` :
class EchoClientFactory(ReconnectingClientFactory):
def startedConnecting(self, connector):
print 'Started to connect.'
print('Started to connect.')
def buildProtocol(self, addr):
print 'Connected.'
print 'Resetting reconnection delay'
print('Connected.')
print('Resetting reconnection delay')
self.resetDelay()
return Echo()
def clientConnectionLost(self, connector, reason):
print 'Lost connection. Reason:', reason
print('Lost connection. Reason:', reason)
ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
def clientConnectionFailed(self, connector, reason):
print 'Connection failed. Reason:', reason
print('Connection failed. Reason:', reason)
ReconnectingClientFactory.clientConnectionFailed(self, connector,
reason)
Expand Down
8 changes: 4 additions & 4 deletions docs/core/howto/components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ For example:
class HairDryer:
def plug(self, socket):
if socket.voltage() == 120:
print "I was plugged in properly and am operating."
print("I was plugged in properly and am operating.")
else:
print "I was plugged in improperly and "
print "now you have no hair dryer any more."
print("I was plugged in improperly and ")
print("now you have no hair dryer any more.")
class AmericanSocket:
def voltage(self):
Expand Down Expand Up @@ -310,7 +310,7 @@ So, we could write a new "smart" ``HairDryer`` which automatically looked up an
def plug(self, socket):
adapted = IAmericanSocket(socket)
assert adapted.voltage() == 120, "BOOM"
print "I was plugged in properly and am operating"
print("I was plugged in properly and am operating")
Now, if we create an instance of our new "smart" ``HairDryer`` and attempt to plug it in to various sockets, the ``HairDryer`` will adapt itself automatically depending on the type of socket it is plugged in to:

Expand Down
4 changes: 2 additions & 2 deletions docs/core/howto/cred.rst
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,11 @@ Twisted's Perspective Broker protocol) is implemented:
class SimplePerspective(pb.Avatar):
def perspective_echo(self, text):
print 'echoing',text
print('echoing',text)
return text
def logout(self):
print self, "logged out"
print(self, "logged out")
class SimpleRealm:
Expand Down
2 changes: 1 addition & 1 deletion docs/core/howto/defer-intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Sometimes it leads us to encode the order when we don't need to, as in this exam
total = 0
for account in accounts:
total += account.get_balance()
print "Total balance $%s" % (total,)
print("Total balance $%s" % (total,))

But that's normally not such a big deal.

Expand Down
Loading

0 comments on commit 6f67bb0

Please sign in to comment.