Ticket #5385: patch_5385.2.patch

File patch_5385.2.patch, 19.2 KB (added by moijes12, 3 years ago)
  • twisted/test/test_compat.py

     
    8080        self.assertEqual(lst1, lst2) 
    8181 
    8282    def testIsinstance(self): 
    83         self.assert_(isinstance(u'hi', types.StringTypes)) 
    84         self.assert_(isinstance(self, unittest.TestCase)) 
    85         # I'm pretty sure it's impossible to implement this 
    86         # without replacing isinstance on 2.2 as well :( 
    87         # self.assert_(isinstance({}, dict)) 
     83        """ 
     84        The current object is an instance of 
     85        unittest.TestCase. 
     86        """ 
     87        self.assertTrue(isinstance(self, unittest.TestCase)) 
    8888 
     89 
    8990    def testStrip(self): 
    9091        self.assertEqual(' x '.lstrip(' '), 'x ') 
    9192        self.assertEqual(' x x'.lstrip(' '), 'x x') 
  • twisted/test/test_defgen.py

     
    1 from __future__ import generators, nested_scopes 
     1""" 
     2__future__.nested_scopes is not imported anymore. nested_scopes was used to add 
     3Python 2.1 support (see http://www.python.org/dev/peps/pep-0227/). Twisted does 
     4not support Python 2.1. 
    25 
     6__future__.generators is not imported anymore as it is Python 2.2 specific. 
     7Twisted no longer supports Python 2.2. 
     8""" 
     9 
    310import sys 
    411 
    512from twisted.internet import reactor 
  • twisted/python/filepath.py

     
    873873 
    874874    def getInodeNumber(self): 
    875875        """ 
    876         Retrieve the file serial number, also called inode number, which  
     876        Retrieve the file serial number, also called inode number, which 
    877877        distinguishes this file from all other files on the same device. 
    878878 
    879879        @raise: NotImplementedError if the platform is Windows, since the 
     
    10461046        """ 
    10471047        Returns whether the underlying path is a block device. 
    10481048 
    1049         @return: C{True} if it is a block device, C{False} otherwise  
     1049        @return: C{True} if it is a block device, C{False} otherwise 
    10501050        @rtype: C{bool} 
    10511051        @since: 11.1 
    10521052        """ 
     
    10631063        """ 
    10641064        Returns whether the underlying path is a socket. 
    10651065 
    1066         @return: C{True} if it is a socket, C{False} otherwise  
     1066        @return: C{True} if it is a socket, C{False} otherwise 
    10671067        @rtype: C{bool} 
    10681068        @since: 11.1 
    10691069        """ 
     
    12541254        os.rename(sib.path, self.path) 
    12551255 
    12561256 
    1257     # new in 2.2.0 
    1258  
    12591257    def __cmp__(self, other): 
    12601258        if not isinstance(other, FilePath): 
    12611259            return NotImplemented 
  • twisted/protocols/ident.py

     
    55""" 
    66Ident protocol implementation. 
    77 
     8__future__.generators is not imported anymore as it is Python 2.2 specific. 
     9Twisted no longer supports Python 2.2. 
     10 
    811@author: Jean-Paul Calderone 
    912""" 
    1013 
    11 from __future__ import generators 
    12  
    1314import struct 
    1415 
    1516from twisted.internet import defer 
  • twisted/protocols/htb.py

     
    99Patterned after U{Martin Devera's Hierarchical Token Bucket traffic 
    1010shaper for the Linux kernel<http://luxik.cdi.cz/~devik/qos/htb/>}. 
    1111 
     12__future__.nested_scopes is not imported anymore. nested_scopes was used to add 
     13Python 2.1 support (see http://www.python.org/dev/peps/pep-0227/). Twisted does 
     14not support Python 2.1. 
     15 
    1216@seealso: U{HTB Linux queuing discipline manual - user guide 
    1317  <http://luxik.cdi.cz/~devik/qos/htb/manual/userg.htm>} 
    1418@seealso: U{Token Bucket Filter in Linux Advanced Routing & Traffic Control 
     
    1620@author: Kevin Turner 
    1721""" 
    1822 
    19 from __future__ import nested_scopes 
    2023 
    2124__version__ = '$Revision: 1.5 $'[11:-2] 
    2225 
  • twisted/topfiles/5385.misc

     
     1twisted no longer supports Python 2.2. 
  • twisted/scripts/tkunzip.py

     
    33# See LICENSE for details. 
    44 
    55""" 
    6 Post-install GUI to compile to pyc and unpack twisted doco 
     6Post-install GUI to compile to pyc and unpack twisted doco. 
     7 
     8__future__.generators is not imported anymore as it is Python 2.2 specific. 
     9Twisted no longer supports Python 2.2. 
    710""" 
    811 
    9 from __future__ import generators 
    10  
    1112import sys 
    1213import zipfile 
    1314import py_compile 
     
    1516# we're going to ignore failures to import tkinter and fall back 
    1617# to using the console if the required dll is not found 
    1718 
    18 # Scary kludge to work around tk84.dll bug:  
     19# Scary kludge to work around tk84.dll bug: 
    1920# https://sourceforge.net/tracker/index.php?func=detail&aid=814654&group_id=5470&atid=105470 
    2021# Without which(): you get a windows missing-dll popup message 
    2122from twisted.python.procutils import which 
     
    7172 
    7273    def pack(self, *args, **kwargs): 
    7374        self.frame.pack(*args, **kwargs) 
    74      
     75 
    7576    def updateProgress(self, newValue, newMax=None): 
    7677        if newMax: 
    7778            self.max = newMax 
     
    9192              float(value) / self.max * self.width, self.height) 
    9293        else: 
    9394            self.canvas.coords(self.scale, 0, 
    94                                self.height - (float(value) /  
     95                               self.height - (float(value) / 
    9596                                              self.max*self.height), 
    9697                               self.width, self.height) 
    9798        # Now update the colors 
     
    101102        if self.doLabel: 
    102103            if value: 
    103104                if value >= 0: 
    104                     pvalue = int((float(value) / float(self.max)) *  
     105                    pvalue = int((float(value) / float(self.max)) * 
    105106                                   100.0) 
    106107                else: 
    107108                    pvalue = 0 
     
    133134    def setIterator(self, iterator): 
    134135        self.iterator=iterator 
    135136        return self 
    136      
     137 
    137138    def updateBar(self, deferred): 
    138139        b=self.bar 
    139140        try: 
     
    156157        if self.stopping: 
    157158            deferred.callback(self.root) 
    158159            return 
    159          
     160 
    160161        try: 
    161162            self.remaining=self.iterator.next() 
    162163        except StopIteration: 
    163             self.stopping=1             
     164            self.stopping=1 
    164165        except: 
    165166            deferred.errback(failure.Failure()) 
    166          
     167 
    167168        if self.remaining%10==0: 
    168169            reactor.callLater(0, self.updateBar, deferred) 
    169170        if self.remaining%100==0: 
     
    218219 
    219220    if opt['use-console']: 
    220221        # this should come before shell-exec to prevent infinite loop 
    221         return doItConsolicious(opt)               
     222        return doItConsolicious(opt) 
    222223    if opt['shell-exec'] or not 'Tkinter' in sys.modules: 
    223224        from distutils import sysconfig 
    224225        from twisted.scripts import tkunzip 
     
    240241            if n % 1000 == 0: 
    241242                print 
    242243        print 'Done unpacking.' 
    243          
     244 
    244245    if opt['compiledir']: 
    245246        print 'Compiling to pyc...' 
    246247        import compileall 
     
    253254    root.title('One Moment.') 
    254255    root.protocol('WM_DELETE_WINDOW', reactor.stop) 
    255256    tksupport.install(root) 
    256      
     257 
    257258    prog=ProgressBar(root, value=0, labelColor="black", width=200) 
    258259    prog.pack() 
    259260 
     
    265266        return root 
    266267 
    267268    d.addCallback(deiconify) 
    268      
     269 
    269270    if opt['zipfile']: 
    270271        uz=Progressor('Unpacking documentation...') 
    271272        max=zipstream.countZipFileChunks(opt['zipfile'], 4096) 
  • twisted/internet/_threadedselect.py

     
    33# Copyright (c) Twisted Matrix Laboratories. 
    44# See LICENSE for details. 
    55 
    6 from __future__ import generators 
    7  
    86""" 
    97Threaded select reactor 
    108 
     
    5452loop.  Shutdown functions that could be used in place of 
    5553"foreignEventloopStop" would be the ExitMainLoop method of the wxApp instance 
    5654with wxPython, or the PyObjCTools.AppHelper.stopEventLoop function. 
     55 
     56__future__.generators is not imported anymore as it is Python 2.2 specific. 
     57Twisted no longer supports Python 2.2. 
    5758""" 
    5859 
    5960from threading import Thread 
  • twisted/conch/scripts/tkconch.py

     
    55# 
    66# $Id: tkconch.py,v 1.6 2003/02/22 08:10:15 z3p Exp $ 
    77 
    8 """ Implementation module for the `tkconch` command. 
    98""" 
     9Implementation module for the `tkconch` command. 
    1010 
    11 from __future__ import nested_scopes 
     11__future__.nested_scopes is not imported anymore. nested_scopes was used to add 
     12Python 2.1 support (see http://www.python.org/dev/peps/pep-0227/). Twisted does 
     13not support Python 2.1. 
     14""" 
    1215 
    1316import Tkinter, tkFileDialog, tkFont, tkMessageBox, string 
    1417from twisted.conch.ui import tkvt100 
     
    8689        self.grid_columnconfigure(2, weight=1, minsize=2) 
    8790 
    8891        self.master.protocol("WM_DELETE_WINDOW", sys.exit) 
    89          
    9092 
     93 
    9194    def getIdentityFile(self): 
    9295        r = tkFileDialog.askopenfilename() 
    9396        if r: 
     
    160163            finished = 0 
    161164        if finished: 
    162165            self.master.quit() 
    163             self.master.destroy()         
     166            self.master.destroy() 
    164167            if options['log']: 
    165168                realout = sys.stdout 
    166169                log.startLogging(sys.stderr) 
     
    337340    raise 
    338341 
    339342class SSHClientFactory(protocol.ClientFactory): 
    340     noisy = 1  
     343    noisy = 1 
    341344 
    342345    def stopFactory(self): 
    343346        reactor.stop() 
     
    379382                host = options['host'] 
    380383                khHost = options['host'] 
    381384            else: 
    382                 host = '%s (%s)' % (options['host'],  
     385                host = '%s (%s)' % (options['host'], 
    383386                                    self.transport.getPeer()[1]) 
    384                 khHost = '%s,%s' % (options['host'],  
     387                khHost = '%s,%s' % (options['host'], 
    385388                                    self.transport.getPeer()[1]) 
    386389            keyType = common.getNS(pubKey)[0] 
    387390            ques = """The authenticity of host '%s' can't be established.\r 
    388 %s key fingerprint is %s.""" % (host,  
    389                                 {'ssh-dss':'DSA', 'ssh-rsa':'RSA'}[keyType],  
    390                                 fingerprint)  
     391%s key fingerprint is %s.""" % (host, 
     392                                {'ssh-dss':'DSA', 'ssh-rsa':'RSA'}[keyType], 
     393                                fingerprint) 
    391394            ques+='\r\nAre you sure you want to continue connecting (yes/no)? ' 
    392395            return deferredAskFrame(ques, 1).addCallback(self._cbVerifyHostKey, pubKey, khHost, keyType) 
    393396 
     
    405408            known_hosts.close() 
    406409        except: 
    407410            log.deferr() 
    408             raise error.ConchError  
     411            raise error.ConchError 
    409412 
    410413    def connectionSecure(self): 
    411414        if options['user']: 
     
    420423    def getPassword(self, prompt = None): 
    421424        if not prompt: 
    422425            prompt = "%s@%s's password: " % (self.user, options['host']) 
    423         return deferredAskFrame(prompt,0)  
     426        return deferredAskFrame(prompt,0) 
    424427 
    425428    def getPublicKey(self): 
    426429        files = [x for x in options.identitys if x not in self.usedFiles] 
     
    429432        file = files[0] 
    430433        log.msg(file) 
    431434        self.usedFiles.append(file) 
    432         file = os.path.expanduser(file)  
     435        file = os.path.expanduser(file) 
    433436        file += '.pub' 
    434437        if not os.path.exists(file): 
    435438            return 
    436439        try: 
    437             return keys.Key.fromFile(file).blob()  
     440            return keys.Key.fromFile(file).blob() 
    438441        except: 
    439442            return self.getPublicKey() # try again 
    440      
     443 
    441444    def getPrivateKey(self): 
    442445        file = os.path.expanduser(self.usedFiles[-1]) 
    443446        if not os.path.exists(file): 
     
    467470        if options.localForwards: 
    468471            for localPort, hostport in options.localForwards: 
    469472                reactor.listenTCP(localPort, 
    470                             forwarding.SSHListenForwardingFactory(self,  
     473                            forwarding.SSHListenForwardingFactory(self, 
    471474                                hostport, 
    472475                                forwarding.SSHListenClientForwardingChannel)) 
    473476        if options.remoteForwards: 
     
    482485class SSHSession(channel.SSHChannel): 
    483486 
    484487    name = 'session' 
    485      
     488 
    486489    def channelOpen(self, foo): 
    487490        #global globalSession 
    488491        #globalSession = self 
     
    505508                #winsz = fcntl.ioctl(fd, tty.TIOCGWINSZ, '12345678') 
    506509                winSize = (25,80,0,0) #struct.unpack('4H', winsz) 
    507510                ptyReqData = session.packRequest_pty_req(term, winSize, '') 
    508                 self.conn.sendRequest(self, 'pty-req', ptyReqData)                 
     511                self.conn.sendRequest(self, 'pty-req', ptyReqData) 
    509512            self.conn.sendRequest(self, 'exec', \ 
    510513                common.NS(options['command'])) 
    511514        else: 
  • twisted/words/im/pbsupport.py

     
    22# See LICENSE for details. 
    33 
    44 
    5 """L{twisted.words} support for Instance Messenger.""" 
     5""" 
     6L{twisted.words} support for Instance Messenger. 
    67 
    7 from __future__ import nested_scopes 
     8__future__.nested_scopes is not imported anymore. nested_scopes was used to add 
     9Python 2.1 support (see http://www.python.org/dev/peps/pep-0227/). Twisted does 
     10not support Python 2.1. 
     11""" 
    812 
    913from twisted.internet import defer 
    1014from twisted.internet import error 
  • twisted/trial/test/detests.py

     
    1 from __future__ import generators 
     1""" 
     2__future__.generators is not imported anymore as it is Python 2.2 specific. 
     3Twisted no longer supports Python 2.2. 
     4""" 
     5 
    26from twisted.trial import unittest 
    37from twisted.internet import defer, threads, reactor 
    48 
     
    1822 
    1923class DeferredSetUpFail(unittest.TestCase): 
    2024    testCalled = False 
    21      
     25 
    2226    def setUp(self): 
    2327        return defer.fail(unittest.FailTest('i fail')) 
    2428 
     
    2933 
    3034class DeferredSetUpCallbackFail(unittest.TestCase): 
    3135    testCalled = False 
    32      
     36 
    3337    def setUp(self): 
    3438        d = defer.succeed('value') 
    3539        d.addCallback(self._cb_setUpCalled) 
     
    4145    def test_ok(self): 
    4246        DeferredSetUpCallbackFail.testCalled = True 
    4347 
    44      
     48 
    4549class DeferredSetUpError(unittest.TestCase): 
    4650    testCalled = False 
    47      
     51 
    4852    def setUp(self): 
    4953        return defer.fail(RuntimeError('deliberate error')) 
    5054 
     
    5458 
    5559class DeferredSetUpNeverFire(unittest.TestCase): 
    5660    testCalled = False 
    57      
     61 
    5862    def setUp(self): 
    5963        return defer.Deferred() 
    6064 
     
    6468 
    6569class DeferredSetUpSkip(unittest.TestCase): 
    6670    testCalled = False 
    67      
     71 
    6872    def setUp(self): 
    6973        d = defer.succeed('value') 
    7074        d.addCallback(self._cb1) 
     
    7983 
    8084class DeferredTests(unittest.TestCase): 
    8185    touched = False 
    82      
     86 
    8387    def _cb_fail(self, reason): 
    8488        self.fail(reason) 
    8589 
     
    134138 
    135139class TimeoutTests(unittest.TestCase): 
    136140    timedOut = None 
    137      
     141 
    138142    def test_pass(self): 
    139143        d = defer.Deferred() 
    140144        reactor.callLater(0, d.callback, 'hoorj!') 
     
    159163        return defer.Deferred() 
    160164    test_expectedFailure.timeout = 0.1 
    161165    test_expectedFailure.todo = "i will get it right, eventually" 
    162      
     166 
    163167    def test_skip(self): 
    164168        return defer.Deferred() 
    165169    test_skip.timeout = 0.1 
  • twisted/spread/ui/gtk2util.py

     
    22# Copyright (c) Twisted Matrix Laboratories. 
    33# See LICENSE for details. 
    44 
     5""" 
     6__future__.nested_scopes is not imported anymore. nested_scopes was used to add 
     7Python 2.1 support (see http://www.python.org/dev/peps/pep-0227/). Twisted does 
     8not support Python 2.1. 
     9""" 
    510 
    6 from __future__ import nested_scopes 
    7  
    811import gtk 
    912 
    1013from twisted import copyright 
  • doc/core/examples/threadedselect/pygamedemo.py

     
    1 from __future__ import generators 
     1""" 
     2__future__.generators is not imported anymore as it is Python 2.2 specific. 
     3Twisted no longer supports Python 2.2. 
     4""" 
    25 
    36# import Twisted and install 
    47from twisted.internet import _threadedselect 
     
    7174            reactor.stop() 
    7275        elif event.type == KEYDOWN and event.key == K_ESCAPE: 
    7376            reactor.stop() 
    74                  
     77 
    7578    pygame.quit() 
    7679 
    7780if __name__ == '__main__': 
  • doc/core/examples/pbgtk2.py

     
    11# Copyright (c) Twisted Matrix Laboratories. 
    22# See LICENSE for details. 
    33 
     4""" 
     5__future__.nested_scopes is not imported anymore. nested_scopes was used to add 
     6Python 2.1 support (see http://www.python.org/dev/peps/pep-0227/). Twisted does 
     7not support Python 2.1. 
     8""" 
    49 
    5 from __future__ import nested_scopes 
    6  
    710from twisted.internet import gtk2reactor 
    811gtk2reactor.install() 
    912 
     
    6770        reactor.connectTCP(host, port, client_factory) 
    6871        creds = UsernamePassword(userName, password) 
    6972        client_factory.login(creds).addCallbacks(self._cbGotPerspective, self._ebFailedLogin) 
    70          
     73 
    7174        self.statusMsg("Contacting server...") 
    7275 
    7376    def _cbGotPerspective(self, perspective): 
     
    8083            text = str(reason.value) 
    8184        else: 
    8285            text = str(reason) 
    83              
     86 
    8487        self.statusMsg(text) 
    8588        msg = gtk.MessageDialog(self._loginDialog, 
    8689                                gtk.DIALOG_DESTROY_WITH_PARENT, 
  • doc/core/examples/longex2.py

     
    3939Multiplying zero numbers is a perfectly sensible operation, and the 
    4040result is 1. In that, this example departs from doc/examples/longex.py, 
    4141which errors out when trying to do this. 
     42 
     43__future__.generators is not imported anymore as it is Python 2.2 specific. 
     44Twisted no longer supports Python 2.2. 
    4245""" 
    43 from __future__ import generators 
     46 
    4447from twisted.protocols import basic 
    4548from twisted.internet import defer, protocol 
    4649