def deposit_request(conn, netBuffer, myData, lock): values = unpack_xml(netBuffer) lock.acquire() try: try: values['arg1'] = int(values['arg1']) # withdraw amount values['arg2'] = int(values['arg2']) # account_number except ValueError: general_failure(conn, 'deposit', "invalid arguments") #get account number if (values['arg2'] >= 0 and values['arg2'] <= 100): act = values['arg2'] else: general_failure(conn, 'deposit', "invalid account number") return #check for existence of account if act not in myData: general_failure(conn, 'deposit', "nonexistent account number") return #check for a valid deposit amount if values['arg1'] > 0: bal = values['arg1'] else: general_failure(conn, 'deposit', "nonsense deposit amount") return curr_bal = myData[act] #check that the new balance won't overflow if bal < sys.maxint - curr_bal - 1: myData[act] = curr_bal + bal else: general_failure(conn, 'deposit', "account overflow... damn you are rich") return deposit_success(conn, curr_bal + bal) finally: lock.release() print myData return
def deposit_request(conn,netBuffer,myData,lock): values = unpack_xml(netBuffer) lock.acquire() try: try: values['arg1'] = int(values['arg1']) # withdraw amount values['arg2'] = int(values['arg2']) # account_number except ValueError: general_failure(conn, 'deposit', "invalid arguments") #get account number if(values['arg2'] >= 0 and values['arg2'] <= 100): act = values['arg2'] else: general_failure(conn,'deposit',"invalid account number") return #check for existence of account if act not in myData: general_failure(conn,'deposit',"nonexistent account number") return #check for a valid deposit amount if values['arg1'] > 0: bal = values['arg1'] else: general_failure(conn,'deposit',"nonsense deposit amount") return curr_bal = myData[act] #check that the new balance won't overflow if bal < sys.maxint - curr_bal - 1: myData[act] = curr_bal + bal else: general_failure(conn,'deposit',"account overflow... damn you are rich") return deposit_success(conn, curr_bal + bal) finally: lock.release() print myData return
def deposit_request(conn,json_data,myData,lock): amount, acct_number = json_data['arguments']['amount'], json_data['arguments']['acct_number'] lock.acquire() try: if amount < 0: general_failure(conn, 'deposit', "invalid deposit amount") elif acct_number < 0 or acct_number > 100: general_failure(conn, 'deposit', "invalid account number") elif acct_number not in myData: general_failure(conn, 'deposit', "nonexistent account number") else: if amount < sys.maxint - myData[acct_number] - 1: myData[acct_number] += amount deposit_success(conn, myData[acct_number]) else: general_failure(conn,'deposit',"account overflow... damn you are rich") finally: lock.release() print myData return
def deposit_request(conn, xml, myData, lock): # get arguments from xml arguments = xml.find('arguments').findall('arg') act = int(arguments[0].text) bal = int(arguments[1].text) lock.acquire() try: # get account number if act <= 0 or act > 100: general_failure(conn, 'deposit', "invalid account number") return # check for existence of account if act not in myData: general_failure(conn, 'deposit', "nonexistent account number") return # check for a valid deposit amount if bal <= 0: general_failure(conn, 'deposit', "nonsense deposit amount") return curr_bal = myData[act] # check that the new balance won't overflow if bal < sys.maxint - curr_bal - 1: myData[act] = curr_bal + bal else: general_failure(conn, 'deposit', "account overflow... damn you are rich") return deposit_success(conn, curr_bal + bal) finally: lock.release() print myData return
def deposit_request(conn,xml,myData,lock): # get arguments from xml arguments = xml.find('arguments').findall('arg') act = int(arguments[0].text) bal = int(arguments[1].text) lock.acquire() try: # get account number if act <= 0 or act > 100: general_failure(conn,'deposit',"invalid account number") return # check for existence of account if act not in myData: general_failure(conn,'deposit',"nonexistent account number") return # check for a valid deposit amount if bal <= 0: general_failure(conn,'deposit',"nonsense deposit amount") return curr_bal = myData[act] # check that the new balance won't overflow if bal < sys.maxint - curr_bal - 1: myData[act] = curr_bal + bal else: general_failure(conn,'deposit',"account overflow... damn you are rich") return deposit_success(conn, curr_bal + bal) finally: lock.release() print myData return
def deposit_request(conn, message, myData, lock): values = repackage_message(message) lock.acquire() try: #get account number if (values[0] >= 0 and values[0] <= 100): act = values[0] else: general_failure(conn, 'deposit', "invalid account number") return #check for existence of account if act not in myData: general_failure(conn, 'deposit', "nonexistent account number") return #check for a valid deposit amount if values[1] > 0: bal = values[1] else: general_failure(conn, 'deposit', "nonsense deposit amount") return curr_bal = myData[act] #check that the new balance won't overflow if bal < sys.maxint - curr_bal - 1: myData[act] = curr_bal + bal else: general_failure(conn, 'deposit', "account overflow... damn you are rich") return deposit_success(conn, curr_bal + bal) finally: lock.release() print myData return
def deposit_request(conn,message,myData,lock): values = repackage_message(message) lock.acquire() try: #get account number if(values[0] >= 0 and values[0] <= 100): act = values[0] else: general_failure(conn,'deposit',"invalid account number") return #check for existence of account if act not in myData: general_failure(conn,'deposit',"nonexistent account number") return #check for a valid deposit amount if values[1] > 0: bal = values[1] else: general_failure(conn,'deposit',"nonsense deposit amount") return curr_bal = myData[act] #check that the new balance won't overflow if bal < sys.maxint - curr_bal - 1: myData[act] = curr_bal + bal else: general_failure(conn,'deposit',"account overflow... damn you are rich") return deposit_success(conn, curr_bal + bal) finally: lock.release() print myData return
def deposit_request(conn, json_data, myData, lock): amount, acct_number = json_data['arguments']['amount'], json_data[ 'arguments']['acct_number'] lock.acquire() try: if amount < 0: general_failure(conn, 'deposit', "invalid deposit amount") elif acct_number < 0 or acct_number > 100: general_failure(conn, 'deposit', "invalid account number") elif acct_number not in myData: general_failure(conn, 'deposit', "nonexistent account number") else: if amount < sys.maxint - myData[acct_number] - 1: myData[acct_number] += amount deposit_success(conn, myData[acct_number]) else: general_failure(conn, 'deposit', "account overflow... damn you are rich") finally: lock.release() print myData return