Browse Source

Initial commit, atm simulation. server and client, 20 & 50 $ notes only.

master
Erle Pereira 6 years ago
parent
commit
e36ec129f6
11 changed files with 1136 additions and 0 deletions
  1. +37
    -0
      atm simulation/atmcode/atmclient.py
  2. +157
    -0
      atm simulation/atmcode/atmserver.py
  3. +19
    -0
      atm simulation/atmservice.thrift
  4. +1
    -0
      atm simulation/gen-py/atmservice/__init__.py
  5. BIN
      atm simulation/gen-py/atmservice/__init__.pyc
  6. +102
    -0
      atm simulation/gen-py/atmservice/atmService-remote
  7. +545
    -0
      atm simulation/gen-py/atmservice/atmService.py
  8. BIN
      atm simulation/gen-py/atmservice/atmService.pyc
  9. +11
    -0
      atm simulation/gen-py/atmservice/constants.py
  10. +264
    -0
      atm simulation/gen-py/atmservice/ttypes.py
  11. BIN
      atm simulation/gen-py/atmservice/ttypes.pyc

+ 37
- 0
atm simulation/atmcode/atmclient.py View File

@ -0,0 +1,37 @@
#!/usr/bin/env python
import sys
sys.path.append('../gen-py')
from atmservice import atmService
from atmservice.ttypes import *
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
if len(sys.argv) <= 1 or sys.argv[1] == '--help':
print ''
print 'Usage: ' + sys.argv[0] + ' <amount to withdraw>'
print ''
sys.exit(0)
amt = int(sys.argv[1])
try:
transport = TSocket.TSocket('localhost', 8082)
transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
user = atmService.Client(protocol)
transport.open()
user.active()
result = user.atmserve(amt)
print result
transport.close()
except Thrift.TException, tx:
print "%s" % (tx.message)

+ 157
- 0
atm simulation/atmcode/atmserver.py View File

@ -0,0 +1,157 @@
#!/usr/bin/env python
import sys, unittest
sys.path.append('../gen-py')
from atmservice import atmService
from atmservice.ttypes import *
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.server import TServer
import socket
if len(sys.argv) <= 2 or sys.argv[1] == '--help':
print ''
print 'Usage: ' + sys.argv[0] + ' <number of 20$ notes> <number of 50$ notes>'
print ''
sys.exit(0)
amt20 = int(sys.argv[1])
amt50 = int(sys.argv[2])
class atmHandler:
def __init__(self):
self.denom = [ 20, 50 ];
self.denom_amts = [ amt20, amt50 ];
self.vault = self.denom[0] * self.denom_amts[0] + self.denom[1] * self.denom_amts[1]
self.note20 = 0
self.note50 = 0
self.log = {}
def active(self):
print "active()"
def amountquery(self):
return self.vault
def statusquery(self):
return str(self.vault) + " - " + str(self.denom_amts[0]) + " in 20$ bills," + str(self.denom_amts[1]) + " in 50$ bills"
def atmloader(self, loadamount):
self.vault += loadamount
return "active: amount reserve is $" + str(loadamount)
def atmserve(self, number):
if self.validcombo(number) != None:
print "withdraw " + str(number)
self.vault -= number
print "left is " + str(self.vault)
else:
return "Invalid Amount"
return str(number) + " - " + str(self.note20) + " in 20$ bills," + str(self.note50) + " in 50$ bills"
return str(number)
def commandfailure(self, ouch):
ouch = "Something bad happended, amount not loaded"
return ouch
def transactionfailure (self, uhoh):
uhoh = "Sorry, we cannot process this amount"
return uhoh
def validcombo(self, number):
self.note50 = 0
self.note20 = 0
if number > 0 and number <= self.vault and len(str(number)) <= 3:
print str(number) +" requested"
while number >= 50:
self.note50 += 1
number -= 50
#print number
while number >= 20:
self.note20 += 1
number -= 20
#print number
if number != 0:
return None
self.denom_amts[0] -= self.note20
self.denom_amts[1] -= self.note50
return number
else:
return None
def selftesting(atmtesting):
case = unittest.TestLoader().loadTestsFromTestCase(atmtesting)
result = unittest.TestResult()
case(result)
if result.wasSuccessful():
return True
else:
print("Some tests failed!")
for test, err in result.failures + result.errors:
print(test)
print(err)
return False
class selfTest(unittest.TestCase):
def setUp(self):
self.testhandler = atmHandler()
def tearDown(self):
self.testhandler = None
def test_loader(self):
print self.testhandler.statusquery()
pass
def test_statusquery(self):
print "for Vault Amount :"
self.assertEqual(self.testhandler.vault, self.testhandler.amountquery())
print " ok "
def test_withdraw_inlimit(self):
print "for Withdrawl :"
self.testhandler.atmserve(20)
self.assertEqual((self.testhandler.vault ), self.testhandler.amountquery(), "First Withdrawal Failure")
def test_withdraw_outlimit(self):
print "for Exceeded Withdrawl Limit :"
value = self.testhandler.vault
self.testhandler.atmserve(self.testhandler.vault * 10)
self.assertEqual(value, self.testhandler.amountquery(), "Withdrawl Failure: Amount too large")
print " ok "
def test_invalidamount(self):
print "for Withdrawl Invalid Amount:"
value = self.testhandler.vault
print "value" + str(self.testhandler.vault)
self.testhandler.atmserve(21)
self.assertEqual(value, self.testhandler.amountquery(), "Wrong Amount Withdrawal Failure")
print " ok "
print "Running self test..."
if not(selftesting(selfTest)):
print "Init Tests Failed"
sys.exit()
print "Tests OK: resetting for use"
handler = atmHandler()
#re-init
handler.denom_amts = [ amt20, amt50 ];
handler.vault = handler.denom[0] * handler.denom_amts[0] + handler.denom[1] * handler.denom_amts[1]
print handler.statusquery()
processor = atmService.Processor(handler)
transport = TSocket.TServerSocket(port=8082)
tfactory = TTransport.TBufferedTransportFactory()
pfactory = TBinaryProtocol.TBinaryProtocolFactory()
server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)
print "Starting atmServer......"
server.serve()
print "done!"

+ 19
- 0
atm simulation/atmservice.thrift View File

@ -0,0 +1,19 @@
struct load {
1:i32 number=6
}
exception commandfailure {
1: string errormessage
}
struct withdraw {
1:i32 number=3
}
exception transactionfailure {
1: string errormessage
}
service atmService {
void active(),
string atmloader(1:i32 load) throws (1:commandfailure ouch);
string atmserve(1:i32 withdraw) throws (1:transactionfailure uhoh);
}

+ 1
- 0
atm simulation/gen-py/atmservice/__init__.py View File

@ -0,0 +1 @@
__all__ = ['ttypes', 'constants', 'atmService']

BIN
atm simulation/gen-py/atmservice/__init__.pyc View File


+ 102
- 0
atm simulation/gen-py/atmservice/atmService-remote View File

@ -0,0 +1,102 @@
#!/usr/bin/env python
#
# Autogenerated by Thrift Compiler (0.9.1)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
# options string: py
#
import sys
import pprint
from urlparse import urlparse
from thrift.transport import TTransport
from thrift.transport import TSocket
from thrift.transport import THttpClient
from thrift.protocol import TBinaryProtocol
from atmservice import atmService
from atmservice.ttypes import *
if len(sys.argv) <= 1 or sys.argv[1] == '--help':
print ''
print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
print ''
print 'Functions:'
print ' void active()'
print ' string atmloader(i32 load)'
print ' string atmserve(i32 withdraw)'
print ''
sys.exit(0)
pp = pprint.PrettyPrinter(indent = 2)
host = 'localhost'
port = 9090
uri = ''
framed = False
http = False
argi = 1
if sys.argv[argi] == '-h':
parts = sys.argv[argi+1].split(':')
host = parts[0]
if len(parts) > 1:
port = int(parts[1])
argi += 2
if sys.argv[argi] == '-u':
url = urlparse(sys.argv[argi+1])
parts = url[1].split(':')
host = parts[0]
if len(parts) > 1:
port = int(parts[1])
else:
port = 80
uri = url[2]
if url[4]:
uri += '?%s' % url[4]
http = True
argi += 2
if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
framed = True
argi += 1
cmd = sys.argv[argi]
args = sys.argv[argi+1:]
if http:
transport = THttpClient.THttpClient(host, port, uri)
else:
socket = TSocket.TSocket(host, port)
if framed:
transport = TTransport.TFramedTransport(socket)
else:
transport = TTransport.TBufferedTransport(socket)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = atmService.Client(protocol)
transport.open()
if cmd == 'active':
if len(args) != 0:
print 'active requires 0 args'
sys.exit(1)
pp.pprint(client.active())
elif cmd == 'atmloader':
if len(args) != 1:
print 'atmloader requires 1 args'
sys.exit(1)
pp.pprint(client.atmloader(eval(args[0]),))
elif cmd == 'atmserve':
if len(args) != 1:
print 'atmserve requires 1 args'
sys.exit(1)
pp.pprint(client.atmserve(eval(args[0]),))
else:
print 'Unrecognized method %s' % cmd
sys.exit(1)
transport.close()

+ 545
- 0
atm simulation/gen-py/atmservice/atmService.py View File

@ -0,0 +1,545 @@
#
# Autogenerated by Thrift Compiler (0.9.1)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
# options string: py
#
from thrift.Thrift import TType, TMessageType, TException, TApplicationException
from ttypes import *
from thrift.Thrift import TProcessor
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol, TProtocol
try:
from thrift.protocol import fastbinary
except:
fastbinary = None
class Iface:
def active(self):
pass
def atmloader(self, load):
"""
Parameters:
- load
"""
pass
def atmserve(self, withdraw):
"""
Parameters:
- withdraw
"""
pass
class Client(Iface):
def __init__(self, iprot, oprot=None):
self._iprot = self._oprot = iprot
if oprot is not None:
self._oprot = oprot
self._seqid = 0
def active(self):
self.send_active()
self.recv_active()
def send_active(self):
self._oprot.writeMessageBegin('active', TMessageType.CALL, self._seqid)
args = active_args()
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def recv_active(self):
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(self._iprot)
self._iprot.readMessageEnd()
raise x
result = active_result()
result.read(self._iprot)
self._iprot.readMessageEnd()
return
def atmloader(self, load):
"""
Parameters:
- load
"""
self.send_atmloader(load)
return self.recv_atmloader()
def send_atmloader(self, load):
self._oprot.writeMessageBegin('atmloader', TMessageType.CALL, self._seqid)
args = atmloader_args()
args.load = load
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def recv_atmloader(self):
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(self._iprot)
self._iprot.readMessageEnd()
raise x
result = atmloader_result()
result.read(self._iprot)
self._iprot.readMessageEnd()
if result.success is not None:
return result.success
if result.ouch is not None:
raise result.ouch
raise TApplicationException(TApplicationException.MISSING_RESULT, "atmloader failed: unknown result");
def atmserve(self, withdraw):
"""
Parameters:
- withdraw
"""
self.send_atmserve(withdraw)
return self.recv_atmserve()
def send_atmserve(self, withdraw):
self._oprot.writeMessageBegin('atmserve', TMessageType.CALL, self._seqid)
args = atmserve_args()
args.withdraw = withdraw
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def recv_atmserve(self):
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
if mtype == TMessageType.EXCEPTION:
x = TApplicationException()
x.read(self._iprot)
self._iprot.readMessageEnd()
raise x
result = atmserve_result()
result.read(self._iprot)
self._iprot.readMessageEnd()
if result.success is not None:
return result.success
if result.uhoh is not None:
raise result.uhoh
raise TApplicationException(TApplicationException.MISSING_RESULT, "atmserve failed: unknown result");
class Processor(Iface, TProcessor):
def __init__(self, handler):
self._handler = handler
self._processMap = {}
self._processMap["active"] = Processor.process_active
self._processMap["atmloader"] = Processor.process_atmloader
self._processMap["atmserve"] = Processor.process_atmserve
def process(self, iprot, oprot):
(name, type, seqid) = iprot.readMessageBegin()
if name not in self._processMap:
iprot.skip(TType.STRUCT)
iprot.readMessageEnd()
x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name))
oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid)
x.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
return
else:
self._processMap[name](self, seqid, iprot, oprot)
return True
def process_active(self, seqid, iprot, oprot):
args = active_args()
args.read(iprot)
iprot.readMessageEnd()
result = active_result()
self._handler.active()
oprot.writeMessageBegin("active", TMessageType.REPLY, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
def process_atmloader(self, seqid, iprot, oprot):
args = atmloader_args()
args.read(iprot)
iprot.readMessageEnd()
result = atmloader_result()
try:
result.success = self._handler.atmloader(args.load)
except commandfailure, ouch:
result.ouch = ouch
oprot.writeMessageBegin("atmloader", TMessageType.REPLY, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
def process_atmserve(self, seqid, iprot, oprot):
args = atmserve_args()
args.read(iprot)
iprot.readMessageEnd()
result = atmserve_result()
try:
result.success = self._handler.atmserve(args.withdraw)
except transactionfailure, uhoh:
result.uhoh = uhoh
oprot.writeMessageBegin("atmserve", TMessageType.REPLY, seqid)
result.write(oprot)
oprot.writeMessageEnd()
oprot.trans.flush()
# HELPER FUNCTIONS AND STRUCTURES
class active_args:
thrift_spec = (
)
def read(self, iprot):
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
def write(self, oprot):
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
return
oprot.writeStructBegin('active_args')
oprot.writeFieldStop()
oprot.writeStructEnd()
def validate(self):
return
def __repr__(self):
L = ['%s=%r' % (key, value)
for key, value in self.__dict__.iteritems()]
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
def __eq__(self, other):
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
def __ne__(self, other):
return not (self == other)
class active_result:
thrift_spec = (
)
def read(self, iprot):
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
def write(self, oprot):
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
return
oprot.writeStructBegin('active_result')
oprot.writeFieldStop()
oprot.writeStructEnd()
def validate(self):
return
def __repr__(self):
L = ['%s=%r' % (key, value)
for key, value in self.__dict__.iteritems()]
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
def __eq__(self, other):
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
def __ne__(self, other):
return not (self == other)
class atmloader_args:
"""
Attributes:
- load
"""
thrift_spec = (
None, # 0
(1, TType.I32, 'load', None, None, ), # 1
)
def __init__(self, load=None,):
self.load = load
def read(self, iprot):
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 1:
if ftype == TType.I32:
self.load = iprot.readI32();
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
def write(self, oprot):
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
return
oprot.writeStructBegin('atmloader_args')
if self.load is not None:
oprot.writeFieldBegin('load', TType.I32, 1)
oprot.writeI32(self.load)
oprot.writeFieldEnd()
oprot.writeFieldStop()
oprot.writeStructEnd()
def validate(self):
return
def __repr__(self):
L = ['%s=%r' % (key, value)
for key, value in self.__dict__.iteritems()]
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
def __eq__(self, other):
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
def __ne__(self, other):
return not (self == other)
class atmloader_result:
"""
Attributes:
- success
- ouch
"""
thrift_spec = (
(0, TType.STRING, 'success', None, None, ), # 0
(1, TType.STRUCT, 'ouch', (commandfailure, commandfailure.thrift_spec), None, ), # 1
)
def __init__(self, success=None, ouch=None,):
self.success = success
self.ouch = ouch
def read(self, iprot):
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 0:
if ftype == TType.STRING:
self.success = iprot.readString();
else:
iprot.skip(ftype)
elif fid == 1:
if ftype == TType.STRUCT:
self.ouch = commandfailure()
self.ouch.read(iprot)
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
def write(self, oprot):
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
return
oprot.writeStructBegin('atmloader_result')
if self.success is not None:
oprot.writeFieldBegin('success', TType.STRING, 0)
oprot.writeString(self.success)
oprot.writeFieldEnd()
if self.ouch is not None:
oprot.writeFieldBegin('ouch', TType.STRUCT, 1)
self.ouch.write(oprot)
oprot.writeFieldEnd()
oprot.writeFieldStop()
oprot.writeStructEnd()
def validate(self):
return
def __repr__(self):
L = ['%s=%r' % (key, value)
for key, value in self.__dict__.iteritems()]
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
def __eq__(self, other):
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
def __ne__(self, other):
return not (self == other)
class atmserve_args:
"""
Attributes:
- withdraw
"""
thrift_spec = (
None, # 0
(1, TType.I32, 'withdraw', None, None, ), # 1
)
def __init__(self, withdraw=None,):
self.withdraw = withdraw
def read(self, iprot):
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 1:
if ftype == TType.I32:
self.withdraw = iprot.readI32();
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
def write(self, oprot):
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
return
oprot.writeStructBegin('atmserve_args')
if self.withdraw is not None:
oprot.writeFieldBegin('withdraw', TType.I32, 1)
oprot.writeI32(self.withdraw)
oprot.writeFieldEnd()
oprot.writeFieldStop()
oprot.writeStructEnd()
def validate(self):
return
def __repr__(self):
L = ['%s=%r' % (key, value)
for key, value in self.__dict__.iteritems()]
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
def __eq__(self, other):
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
def __ne__(self, other):
return not (self == other)
class atmserve_result:
"""
Attributes:
- success
- uhoh
"""
thrift_spec = (
(0, TType.STRING, 'success', None, None, ), # 0
(1, TType.STRUCT, 'uhoh', (transactionfailure, transactionfailure.thrift_spec), None, ), # 1
)
def __init__(self, success=None, uhoh=None,):
self.success = success
self.uhoh = uhoh
def read(self, iprot):
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 0:
if ftype == TType.STRING:
self.success = iprot.readString();
else:
iprot.skip(ftype)
elif fid == 1:
if ftype == TType.STRUCT:
self.uhoh = transactionfailure()
self.uhoh.read(iprot)
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
def write(self, oprot):
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
return
oprot.writeStructBegin('atmserve_result')
if self.success is not None:
oprot.writeFieldBegin('success', TType.STRING, 0)
oprot.writeString(self.success)
oprot.writeFieldEnd()
if self.uhoh is not None:
oprot.writeFieldBegin('uhoh', TType.STRUCT, 1)
self.uhoh.write(oprot)
oprot.writeFieldEnd()
oprot.writeFieldStop()
oprot.writeStructEnd()
def validate(self):
return
def __repr__(self):
L = ['%s=%r' % (key, value)
for key, value in self.__dict__.iteritems()]
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
def __eq__(self, other):
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
def __ne__(self, other):
return not (self == other)

BIN
atm simulation/gen-py/atmservice/atmService.pyc View File


+ 11
- 0
atm simulation/gen-py/atmservice/constants.py View File

@ -0,0 +1,11 @@
#
# Autogenerated by Thrift Compiler (0.9.1)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
# options string: py
#
from thrift.Thrift import TType, TMessageType, TException, TApplicationException
from ttypes import *

+ 264
- 0
atm simulation/gen-py/atmservice/ttypes.py View File

@ -0,0 +1,264 @@
#
# Autogenerated by Thrift Compiler (0.9.1)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
# options string: py
#
from thrift.Thrift import TType, TMessageType, TException, TApplicationException
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol, TProtocol
try:
from thrift.protocol import fastbinary
except:
fastbinary = None
class load:
"""
Attributes:
- number
"""
thrift_spec = (
None, # 0
(1, TType.I32, 'number', None, 6, ), # 1
)
def __init__(self, number=thrift_spec[1][4],):
self.number = number
def read(self, iprot):
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 1:
if ftype == TType.I32:
self.number = iprot.readI32();
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
def write(self, oprot):
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
return
oprot.writeStructBegin('load')
if self.number is not None:
oprot.writeFieldBegin('number', TType.I32, 1)
oprot.writeI32(self.number)
oprot.writeFieldEnd()
oprot.writeFieldStop()
oprot.writeStructEnd()
def validate(self):
return
def __repr__(self):
L = ['%s=%r' % (key, value)
for key, value in self.__dict__.iteritems()]
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
def __eq__(self, other):
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
def __ne__(self, other):
return not (self == other)
class commandfailure(TException):
"""
Attributes:
- errormessage
"""
thrift_spec = (
None, # 0
(1, TType.STRING, 'errormessage', None, None, ), # 1
)
def __init__(self, errormessage=None,):
self.errormessage = errormessage
def read(self, iprot):
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 1:
if ftype == TType.STRING:
self.errormessage = iprot.readString();
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
def write(self, oprot):
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
return
oprot.writeStructBegin('commandfailure')
if self.errormessage is not None:
oprot.writeFieldBegin('errormessage', TType.STRING, 1)
oprot.writeString(self.errormessage)
oprot.writeFieldEnd()
oprot.writeFieldStop()
oprot.writeStructEnd()
def validate(self):
return
def __str__(self):
return repr(self)
def __repr__(self):
L = ['%s=%r' % (key, value)
for key, value in self.__dict__.iteritems()]
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
def __eq__(self, other):
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
def __ne__(self, other):
return not (self == other)
class withdraw:
"""
Attributes:
- number
"""
thrift_spec = (
None, # 0
(1, TType.I32, 'number', None, 3, ), # 1
)
def __init__(self, number=thrift_spec[1][4],):
self.number = number
def read(self, iprot):
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 1:
if ftype == TType.I32:
self.number = iprot.readI32();
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
def write(self, oprot):
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
return
oprot.writeStructBegin('withdraw')
if self.number is not None:
oprot.writeFieldBegin('number', TType.I32, 1)
oprot.writeI32(self.number)
oprot.writeFieldEnd()
oprot.writeFieldStop()
oprot.writeStructEnd()
def validate(self):
return
def __repr__(self):
L = ['%s=%r' % (key, value)
for key, value in self.__dict__.iteritems()]
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
def __eq__(self, other):
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
def __ne__(self, other):
return not (self == other)
class transactionfailure(TException):
"""
Attributes:
- errormessage
"""
thrift_spec = (
None, # 0
(1, TType.STRING, 'errormessage', None, None, ), # 1
)
def __init__(self, errormessage=None,):
self.errormessage = errormessage
def read(self, iprot):
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 1:
if ftype == TType.STRING:
self.errormessage = iprot.readString();
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
def write(self, oprot):
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
return
oprot.writeStructBegin('transactionfailure')
if self.errormessage is not None:
oprot.writeFieldBegin('errormessage', TType.STRING, 1)
oprot.writeString(self.errormessage)
oprot.writeFieldEnd()
oprot.writeFieldStop()
oprot.writeStructEnd()
def validate(self):
return
def __str__(self):
return repr(self)
def __repr__(self):
L = ['%s=%r' % (key, value)
for key, value in self.__dict__.iteritems()]
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
def __eq__(self, other):
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
def __ne__(self, other):
return not (self == other)

BIN
atm simulation/gen-py/atmservice/ttypes.pyc View File


Loading…
Cancel
Save