r47048 - twistedchecker + cleanups

hawkowl-TA+aISz0psMTMxyoc4vAAJOcrHinNvQL0E9HWUfgJXw@public.gmane.org Mon, 21 Mar 2016 21:37:37 -0600 (MDT)
Newsgroups gmane.comp.python.twisted.commits
Message-ID <[email protected]>
Author: hawkowl
Date: Mon Mar 21 21:37:33 2016
New Revision: 47048

Modified:
   branches/conch-transport-py3-8232-2/twisted/conch/ssh/factory.py
   branches/conch-transport-py3-8232-2/twisted/conch/ssh/service.py
   branches/conch-transport-py3-8232-2/twisted/conch/test/test_transport.py

Log:
twistedchecker + cleanups

Modified: branches/conch-transport-py3-8232-2/twisted/conch/ssh/factory.py
==============================================================================
--- branches/conch-transport-py3-8232-2/twisted/conch/ssh/factory.py	(original)
+++ branches/conch-transport-py3-8232-2/twisted/conch/ssh/factory.py	Mon Mar 21 21:37:33 2016
@@ -10,6 +10,8 @@
 
 from __future__ import absolute_import, division
 
+import random
+
 from functools import cmp_to_key
 
 from twisted.internet import protocol
@@ -19,30 +21,33 @@
 from twisted.conch import error
 from twisted.conch.ssh import _kex, transport, userauth, connection
 
-import random
 
 
 class SSHFactory(protocol.Factory):
     """
     A Factory for SSH servers.
+
+    @ivar services: THe services this factory offers.
+    @type services: L{dict} with L{str} keys and
+        L{twisted.conch.ssh.service.SSHService} values.
     """
     protocol = transport.SSHServerTransport
 
     services = {
-        'ssh-userauth':userauth.SSHUserAuthServer,
-        'ssh-connection':connection.SSHConnection
+        'ssh-userauth': userauth.SSHUserAuthServer,
+        'ssh-connection': connection.SSHConnection
     }
     def startFactory(self):
         """
         Check for public and private keys.
         """
-        if not hasattr(self,'publicKeys'):
+        if not hasattr(self, 'publicKeys'):
             self.publicKeys = self.getPublicKeys()
-        if not hasattr(self,'privateKeys'):
+        if not hasattr(self, 'privateKeys'):
             self.privateKeys = self.getPrivateKeys()
         if not self.publicKeys or not self.privateKeys:
             raise error.ConchError('no host keys, failing')
-        if not hasattr(self,'primes'):
+        if not hasattr(self, 'primes'):
             self.primes = self.getPrimes()
 
 
@@ -108,7 +113,8 @@
         @rtype:     C{tuple}
         """
         primesKeys = list(self.primes.keys())
-        primesKeys.sort(key=cmp_to_key(lambda x, y: cmp(abs(x - bits),  abs(y - bits))))
+        primesKeys.sort(key=cmp_to_key(
+            lambda x, y: cmp(abs(x - bits), abs(y - bits))))
         realBits = primesKeys[0]
         return random.choice(self.primes[realBits])
 

Modified: branches/conch-transport-py3-8232-2/twisted/conch/ssh/service.py
==============================================================================
--- branches/conch-transport-py3-8232-2/twisted/conch/ssh/service.py	(original)
+++ branches/conch-transport-py3-8232-2/twisted/conch/ssh/service.py	Mon Mar 21 21:37:33 2016
@@ -37,10 +37,9 @@
         """
         called when we receive a packet on the transport
         """
-        #print self.protocolMessages
         if messageNum in self.protocolMessages:
             messageType = self.protocolMessages[messageNum]
-            f = getattr(self,'ssh_%s' % messageType[4:],
+            f = getattr(self, 'ssh_%s' % messageType[4:],
                         None)
             if f is not None:
                 return f(packet)

Modified: branches/conch-transport-py3-8232-2/twisted/conch/test/test_transport.py
==============================================================================
--- branches/conch-transport-py3-8232-2/twisted/conch/test/test_transport.py	(original)
+++ branches/conch-transport-py3-8232-2/twisted/conch/test/test_transport.py	Mon Mar 21 21:37:33 2016
@@ -255,7 +255,8 @@
     A mocked-up factory based on twisted.conch.ssh.factory.SSHFactory.
     """
     services = {
-        'ssh-userauth': MockService}
+        'ssh-userauth': MockService
+    }
 
 
     def getPublicKeys(self):