Beispiel #1
0
def balance_request(conn, netBuffer, myData, lock):
    #no need to lock: we are just reading a value from a dict, which is thread-safe
    values = unpack_xml(netBuffer)

    try:
        values['arg1'] = int(values['arg1'])
    except ValueError:
        general_failure(conn, 'balance', "invalid arguments")

    #get balance
    if (values['arg1'] >= 0 and values['arg1'] <= 100):
        act = values['arg1']
    else:
        general_failure(conn, 'balance', "invalid account number")
        return

    #get the current balance
    try:
        bal = myData[act]
    except KeyError:
        general_failure(conn, 'balance', "nonexistent account")
        return

    balance_success(conn, bal)

    return
def balance_request(conn,netBuffer,myData,lock):
    #no need to lock: we are just reading a value from a dict, which is thread-safe
    values = unpack_xml(netBuffer)

    try:
        values['arg1'] = int(values['arg1'])
    except ValueError:
        general_failure(conn, 'balance', "invalid arguments")

    #get balance
    if(values['arg1'] >= 0 and values['arg1'] <= 100):
        act = values['arg1']
    else:
        general_failure(conn,'balance',"invalid account number")
        return
    
    #get the current balance
    try:
        bal = myData[act]
    except KeyError:
        general_failure(conn,'balance',"nonexistent account")
        return

    balance_success(conn,bal)
    
    return
Beispiel #3
0
def balance_request(conn, json_data, myData, lock):
    acct_number = json_data['arguments']['acct_number']

    if acct_number < 0 or acct_number > 100:
        general_failure(conn, 'getBalance', "invalid account number")

    #no need to lock: we are just reading a value from a dict, which is thread-safe
    #get the current balance
    try:
        balance = myData[acct_number]
    except KeyError:
        general_failure(conn, 'getBalance', "nonexistent account")
        return

    balance_success(conn, balance)
    return
Beispiel #4
0
def balance_request(conn,json_data,myData,lock):
    acct_number = json_data['arguments']['acct_number']

    if acct_number < 0 or acct_number > 100:
        general_failure(conn,'getBalance',"invalid account number")

    #no need to lock: we are just reading a value from a dict, which is thread-safe
    #get the current balance
    try:
        balance = myData[acct_number]
    except KeyError:
        general_failure(conn,'getBalance',"nonexistent account")
        return

    balance_success(conn,balance)
    return
Beispiel #5
0
def balance_request(conn, message, myData, lock):
    #no need to lock: we are just reading a value from a dict, which is thread-safe
    values = repackage_message(message)

    #get balance
    if (values[0] >= 0 and values[0] <= 100):
        act = values[0]
    else:
        general_failure(conn, 'balance', "invalid account number")
        return

    #get the current balance
    try:
        bal = myData[act]
    except KeyError:
        general_failure(conn, 'balance', "nonexistent account")
        return

    balance_success(conn, bal)

    return
Beispiel #6
0
def balance_request(conn,message,myData,lock):
    #no need to lock: we are just reading a value from a dict, which is thread-safe
    values = repackage_message(message)

    #get balance
    if(values[0] >= 0 and values[0] <= 100):
        act = values[0]
    else:
        general_failure(conn,'balance',"invalid account number")
        return
    
    #get the current balance
    try:
        bal = myData[act]
    except KeyError:
        general_failure(conn,'balance',"nonexistent account")
        return

    balance_success(conn,bal)
    
    return
Beispiel #7
0
def balance_request(conn, xml, myData, lock):

    #no need to lock: we are just reading a value from a dict, which is thread-safe
    arguments = xml.find('arguments').findall('arg')
    act = int(arguments[0].text)

    #get balance
    if act <= 0 or act > 100:
        general_failure(conn, 'balance', "invalid account number")
        return

    #get the current balance
    try:
        bal = myData[act]
    except KeyError:
        general_failure(conn, 'balance', "nonexistent account")
        return

    balance_success(conn, bal)

    return
Beispiel #8
0
def balance_request(conn,xml,myData,lock):
    
    #no need to lock: we are just reading a value from a dict, which is thread-safe
    arguments = xml.find('arguments').findall('arg')
    act = int(arguments[0].text)

    #get balance
    if act <= 0 or act > 100:
        general_failure(conn,'balance',"invalid account number")
        return

    #get the current balance
    try:
        bal = myData[act]
    except KeyError:
        general_failure(conn,'balance',"nonexistent account")
        return

    balance_success(conn,bal)

    return