(key, guess)
Tests if guess is a correct solution
Tests if guess is a correct solution
Tests if guess is a correct solution
def testSolution(key, guess):
    """
    Tests if guess is a correct solution
    """
    try:
        id, expiry, sig = _decodeKey(key)

        # test for timeout
        if time.time() > expiry:
            # sorry, timed out, too late
            _delImage(id)
            return False

        # test for past usage of this key

        path = _getImagePath(id)
        if not os.path.isfile(path):
            # no such key, fail out
            return False

        # test for correct word
        if _signChallenge(id, guess, expiry) != sig:
            # sorry, wrong word
            return False

        # successful
        _delImage(id) # image no longer needed
        return True
    except:
        #traceback.print_exc()
        return False
def testSolution ( key , guess ) : try : id , expiry , sig = _decodeKey ( key ) # test for timeout if time . time ( ) > expiry : # sorry, timed out, too late _delImage ( id ) return False # test for past usage of this key path = _getImagePath ( id ) if not os . path . isfile ( path ) : # no such key, fail out return False # test for correct word if _signChallenge ( id , guess , expiry ) != sig : # sorry, wrong word return False # successful _delImage ( id ) # image no longer needed return True except : #traceback.print_exc() return False