Subversion Repositories SmartDukaan

Rev

Rev 866 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
777 rajveer 1
#
2
# Autogenerated by Thrift
3
#
4
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
#
6
 
7
from thrift.Thrift import *
8
from ttypes import *
9
from thrift.Thrift import TProcessor
10
from thrift.transport import TTransport
11
from thrift.protocol import TBinaryProtocol
12
try:
13
  from thrift.protocol import fastbinary
14
except:
15
  fastbinary = None
16
 
17
 
18
class Iface:
19
  def sayHello(self, message):
20
    """
21
    Parameters:
22
     - message
23
    """
24
    pass
25
 
26
  def getUser(self, id):
27
    """
28
    Parameters:
29
     - id
30
    """
31
    pass
32
 
33
  def createUser(self, name):
34
    """
35
    Parameters:
36
     - name
37
    """
38
    pass
39
 
40
  def closeSession(self, ):
41
    pass
42
 
43
 
44
class Client(Iface):
45
  def __init__(self, iprot, oprot=None):
46
    self._iprot = self._oprot = iprot
47
    if oprot != None:
48
      self._oprot = oprot
49
    self._seqid = 0
50
 
51
  def sayHello(self, message):
52
    """
53
    Parameters:
54
     - message
55
    """
56
    self.send_sayHello(message)
57
    self.recv_sayHello()
58
 
59
  def send_sayHello(self, message):
60
    self._oprot.writeMessageBegin('sayHello', TMessageType.CALL, self._seqid)
61
    args = sayHello_args()
62
    args.message = message
63
    args.write(self._oprot)
64
    self._oprot.writeMessageEnd()
65
    self._oprot.trans.flush()
66
 
67
  def recv_sayHello(self, ):
68
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
69
    if mtype == TMessageType.EXCEPTION:
70
      x = TApplicationException()
71
      x.read(self._iprot)
72
      self._iprot.readMessageEnd()
73
      raise x
74
    result = sayHello_result()
75
    result.read(self._iprot)
76
    self._iprot.readMessageEnd()
77
    return
78
 
79
  def getUser(self, id):
80
    """
81
    Parameters:
82
     - id
83
    """
84
    self.send_getUser(id)
85
    return self.recv_getUser()
86
 
87
  def send_getUser(self, id):
88
    self._oprot.writeMessageBegin('getUser', TMessageType.CALL, self._seqid)
89
    args = getUser_args()
90
    args.id = id
91
    args.write(self._oprot)
92
    self._oprot.writeMessageEnd()
93
    self._oprot.trans.flush()
94
 
95
  def recv_getUser(self, ):
96
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
97
    if mtype == TMessageType.EXCEPTION:
98
      x = TApplicationException()
99
      x.read(self._iprot)
100
      self._iprot.readMessageEnd()
101
      raise x
102
    result = getUser_result()
103
    result.read(self._iprot)
104
    self._iprot.readMessageEnd()
105
    if result.success != None:
106
      return result.success
107
    raise TApplicationException(TApplicationException.MISSING_RESULT, "getUser failed: unknown result");
108
 
109
  def createUser(self, name):
110
    """
111
    Parameters:
112
     - name
113
    """
114
    self.send_createUser(name)
115
    self.recv_createUser()
116
 
117
  def send_createUser(self, name):
118
    self._oprot.writeMessageBegin('createUser', TMessageType.CALL, self._seqid)
119
    args = createUser_args()
120
    args.name = name
121
    args.write(self._oprot)
122
    self._oprot.writeMessageEnd()
123
    self._oprot.trans.flush()
124
 
125
  def recv_createUser(self, ):
126
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
127
    if mtype == TMessageType.EXCEPTION:
128
      x = TApplicationException()
129
      x.read(self._iprot)
130
      self._iprot.readMessageEnd()
131
      raise x
132
    result = createUser_result()
133
    result.read(self._iprot)
134
    self._iprot.readMessageEnd()
135
    return
136
 
137
  def closeSession(self, ):
138
    self.send_closeSession()
139
    self.recv_closeSession()
140
 
141
  def send_closeSession(self, ):
142
    self._oprot.writeMessageBegin('closeSession', TMessageType.CALL, self._seqid)
143
    args = closeSession_args()
144
    args.write(self._oprot)
145
    self._oprot.writeMessageEnd()
146
    self._oprot.trans.flush()
147
 
148
  def recv_closeSession(self, ):
149
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
150
    if mtype == TMessageType.EXCEPTION:
151
      x = TApplicationException()
152
      x.read(self._iprot)
153
      self._iprot.readMessageEnd()
154
      raise x
155
    result = closeSession_result()
156
    result.read(self._iprot)
157
    self._iprot.readMessageEnd()
158
    return
159
 
160
 
161
class Processor(Iface, TProcessor):
162
  def __init__(self, handler):
163
    self._handler = handler
164
    self._processMap = {}
165
    self._processMap["sayHello"] = Processor.process_sayHello
166
    self._processMap["getUser"] = Processor.process_getUser
167
    self._processMap["createUser"] = Processor.process_createUser
168
    self._processMap["closeSession"] = Processor.process_closeSession
169
 
170
  def process(self, iprot, oprot):
171
    (name, type, seqid) = iprot.readMessageBegin()
172
    if name not in self._processMap:
173
      iprot.skip(TType.STRUCT)
174
      iprot.readMessageEnd()
175
      x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name))
176
      oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid)
177
      x.write(oprot)
178
      oprot.writeMessageEnd()
179
      oprot.trans.flush()
180
      return
181
    else:
182
      self._processMap[name](self, seqid, iprot, oprot)
183
    return True
184
 
185
  def process_sayHello(self, seqid, iprot, oprot):
186
    args = sayHello_args()
187
    args.read(iprot)
188
    iprot.readMessageEnd()
189
    result = sayHello_result()
190
    self._handler.sayHello(args.message)
191
    oprot.writeMessageBegin("sayHello", TMessageType.REPLY, seqid)
192
    result.write(oprot)
193
    oprot.writeMessageEnd()
194
    oprot.trans.flush()
195
 
196
  def process_getUser(self, seqid, iprot, oprot):
197
    args = getUser_args()
198
    args.read(iprot)
199
    iprot.readMessageEnd()
200
    result = getUser_result()
201
    result.success = self._handler.getUser(args.id)
202
    oprot.writeMessageBegin("getUser", TMessageType.REPLY, seqid)
203
    result.write(oprot)
204
    oprot.writeMessageEnd()
205
    oprot.trans.flush()
206
 
207
  def process_createUser(self, seqid, iprot, oprot):
208
    args = createUser_args()
209
    args.read(iprot)
210
    iprot.readMessageEnd()
211
    result = createUser_result()
212
    self._handler.createUser(args.name)
213
    oprot.writeMessageBegin("createUser", TMessageType.REPLY, seqid)
214
    result.write(oprot)
215
    oprot.writeMessageEnd()
216
    oprot.trans.flush()
217
 
218
  def process_closeSession(self, seqid, iprot, oprot):
219
    args = closeSession_args()
220
    args.read(iprot)
221
    iprot.readMessageEnd()
222
    result = closeSession_result()
223
    self._handler.closeSession()
224
    oprot.writeMessageBegin("closeSession", TMessageType.REPLY, seqid)
225
    result.write(oprot)
226
    oprot.writeMessageEnd()
227
    oprot.trans.flush()
228
 
229
 
230
# HELPER FUNCTIONS AND STRUCTURES
231
 
232
class sayHello_args:
233
  """
234
  Attributes:
235
   - message
236
  """
237
 
238
  thrift_spec = (
239
    None, # 0
240
    (1, TType.STRING, 'message', None, None, ), # 1
241
  )
242
 
243
  def __init__(self, message=None,):
244
    self.message = message
245
 
246
  def read(self, iprot):
247
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
248
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
249
      return
250
    iprot.readStructBegin()
251
    while True:
252
      (fname, ftype, fid) = iprot.readFieldBegin()
253
      if ftype == TType.STOP:
254
        break
255
      if fid == 1:
256
        if ftype == TType.STRING:
257
          self.message = iprot.readString();
258
        else:
259
          iprot.skip(ftype)
260
      else:
261
        iprot.skip(ftype)
262
      iprot.readFieldEnd()
263
    iprot.readStructEnd()
264
 
265
  def write(self, oprot):
266
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
267
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
268
      return
269
    oprot.writeStructBegin('sayHello_args')
270
    if self.message != None:
271
      oprot.writeFieldBegin('message', TType.STRING, 1)
272
      oprot.writeString(self.message)
273
      oprot.writeFieldEnd()
274
    oprot.writeFieldStop()
275
    oprot.writeStructEnd()
276
 
277
  def __repr__(self):
278
    L = ['%s=%r' % (key, value)
279
      for key, value in self.__dict__.iteritems()]
280
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
281
 
282
  def __eq__(self, other):
283
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
284
 
285
  def __ne__(self, other):
286
    return not (self == other)
287
 
288
class sayHello_result:
289
 
290
  thrift_spec = (
291
  )
292
 
293
  def read(self, iprot):
294
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
295
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
296
      return
297
    iprot.readStructBegin()
298
    while True:
299
      (fname, ftype, fid) = iprot.readFieldBegin()
300
      if ftype == TType.STOP:
301
        break
302
      else:
303
        iprot.skip(ftype)
304
      iprot.readFieldEnd()
305
    iprot.readStructEnd()
306
 
307
  def write(self, oprot):
308
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
309
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
310
      return
311
    oprot.writeStructBegin('sayHello_result')
312
    oprot.writeFieldStop()
313
    oprot.writeStructEnd()
314
 
315
  def __repr__(self):
316
    L = ['%s=%r' % (key, value)
317
      for key, value in self.__dict__.iteritems()]
318
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
319
 
320
  def __eq__(self, other):
321
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
322
 
323
  def __ne__(self, other):
324
    return not (self == other)
325
 
326
class getUser_args:
327
  """
328
  Attributes:
329
   - id
330
  """
331
 
332
  thrift_spec = (
333
    None, # 0
334
    (1, TType.I64, 'id', None, None, ), # 1
335
  )
336
 
337
  def __init__(self, id=None,):
338
    self.id = id
339
 
340
  def read(self, iprot):
341
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
342
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
343
      return
344
    iprot.readStructBegin()
345
    while True:
346
      (fname, ftype, fid) = iprot.readFieldBegin()
347
      if ftype == TType.STOP:
348
        break
349
      if fid == 1:
350
        if ftype == TType.I64:
351
          self.id = iprot.readI64();
352
        else:
353
          iprot.skip(ftype)
354
      else:
355
        iprot.skip(ftype)
356
      iprot.readFieldEnd()
357
    iprot.readStructEnd()
358
 
359
  def write(self, oprot):
360
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
361
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
362
      return
363
    oprot.writeStructBegin('getUser_args')
364
    if self.id != None:
365
      oprot.writeFieldBegin('id', TType.I64, 1)
366
      oprot.writeI64(self.id)
367
      oprot.writeFieldEnd()
368
    oprot.writeFieldStop()
369
    oprot.writeStructEnd()
370
 
371
  def __repr__(self):
372
    L = ['%s=%r' % (key, value)
373
      for key, value in self.__dict__.iteritems()]
374
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
375
 
376
  def __eq__(self, other):
377
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
378
 
379
  def __ne__(self, other):
380
    return not (self == other)
381
 
382
class getUser_result:
383
  """
384
  Attributes:
385
   - success
386
  """
387
 
388
  thrift_spec = (
389
    (0, TType.STRING, 'success', None, None, ), # 0
390
  )
391
 
392
  def __init__(self, success=None,):
393
    self.success = success
394
 
395
  def read(self, iprot):
396
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
397
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
398
      return
399
    iprot.readStructBegin()
400
    while True:
401
      (fname, ftype, fid) = iprot.readFieldBegin()
402
      if ftype == TType.STOP:
403
        break
404
      if fid == 0:
405
        if ftype == TType.STRING:
406
          self.success = iprot.readString();
407
        else:
408
          iprot.skip(ftype)
409
      else:
410
        iprot.skip(ftype)
411
      iprot.readFieldEnd()
412
    iprot.readStructEnd()
413
 
414
  def write(self, oprot):
415
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
416
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
417
      return
418
    oprot.writeStructBegin('getUser_result')
419
    if self.success != None:
420
      oprot.writeFieldBegin('success', TType.STRING, 0)
421
      oprot.writeString(self.success)
422
      oprot.writeFieldEnd()
423
    oprot.writeFieldStop()
424
    oprot.writeStructEnd()
425
 
426
  def __repr__(self):
427
    L = ['%s=%r' % (key, value)
428
      for key, value in self.__dict__.iteritems()]
429
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
430
 
431
  def __eq__(self, other):
432
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
433
 
434
  def __ne__(self, other):
435
    return not (self == other)
436
 
437
class createUser_args:
438
  """
439
  Attributes:
440
   - name
441
  """
442
 
443
  thrift_spec = (
444
    None, # 0
445
    (1, TType.STRING, 'name', None, None, ), # 1
446
  )
447
 
448
  def __init__(self, name=None,):
449
    self.name = name
450
 
451
  def read(self, iprot):
452
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
453
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
454
      return
455
    iprot.readStructBegin()
456
    while True:
457
      (fname, ftype, fid) = iprot.readFieldBegin()
458
      if ftype == TType.STOP:
459
        break
460
      if fid == 1:
461
        if ftype == TType.STRING:
462
          self.name = iprot.readString();
463
        else:
464
          iprot.skip(ftype)
465
      else:
466
        iprot.skip(ftype)
467
      iprot.readFieldEnd()
468
    iprot.readStructEnd()
469
 
470
  def write(self, oprot):
471
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
472
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
473
      return
474
    oprot.writeStructBegin('createUser_args')
475
    if self.name != None:
476
      oprot.writeFieldBegin('name', TType.STRING, 1)
477
      oprot.writeString(self.name)
478
      oprot.writeFieldEnd()
479
    oprot.writeFieldStop()
480
    oprot.writeStructEnd()
481
 
482
  def __repr__(self):
483
    L = ['%s=%r' % (key, value)
484
      for key, value in self.__dict__.iteritems()]
485
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
486
 
487
  def __eq__(self, other):
488
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
489
 
490
  def __ne__(self, other):
491
    return not (self == other)
492
 
493
class createUser_result:
494
 
495
  thrift_spec = (
496
  )
497
 
498
  def read(self, iprot):
499
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
500
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
501
      return
502
    iprot.readStructBegin()
503
    while True:
504
      (fname, ftype, fid) = iprot.readFieldBegin()
505
      if ftype == TType.STOP:
506
        break
507
      else:
508
        iprot.skip(ftype)
509
      iprot.readFieldEnd()
510
    iprot.readStructEnd()
511
 
512
  def write(self, oprot):
513
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
514
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
515
      return
516
    oprot.writeStructBegin('createUser_result')
517
    oprot.writeFieldStop()
518
    oprot.writeStructEnd()
519
 
520
  def __repr__(self):
521
    L = ['%s=%r' % (key, value)
522
      for key, value in self.__dict__.iteritems()]
523
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
524
 
525
  def __eq__(self, other):
526
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
527
 
528
  def __ne__(self, other):
529
    return not (self == other)
530
 
531
class closeSession_args:
532
 
533
  thrift_spec = (
534
  )
535
 
536
  def read(self, iprot):
537
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
538
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
539
      return
540
    iprot.readStructBegin()
541
    while True:
542
      (fname, ftype, fid) = iprot.readFieldBegin()
543
      if ftype == TType.STOP:
544
        break
545
      else:
546
        iprot.skip(ftype)
547
      iprot.readFieldEnd()
548
    iprot.readStructEnd()
549
 
550
  def write(self, oprot):
551
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
552
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
553
      return
554
    oprot.writeStructBegin('closeSession_args')
555
    oprot.writeFieldStop()
556
    oprot.writeStructEnd()
557
 
558
  def __repr__(self):
559
    L = ['%s=%r' % (key, value)
560
      for key, value in self.__dict__.iteritems()]
561
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
562
 
563
  def __eq__(self, other):
564
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
565
 
566
  def __ne__(self, other):
567
    return not (self == other)
568
 
569
class closeSession_result:
570
 
571
  thrift_spec = (
572
  )
573
 
574
  def read(self, iprot):
575
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
576
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
577
      return
578
    iprot.readStructBegin()
579
    while True:
580
      (fname, ftype, fid) = iprot.readFieldBegin()
581
      if ftype == TType.STOP:
582
        break
583
      else:
584
        iprot.skip(ftype)
585
      iprot.readFieldEnd()
586
    iprot.readStructEnd()
587
 
588
  def write(self, oprot):
589
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
590
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
591
      return
592
    oprot.writeStructBegin('closeSession_result')
593
    oprot.writeFieldStop()
594
    oprot.writeStructEnd()
595
 
596
  def __repr__(self):
597
    L = ['%s=%r' % (key, value)
598
      for key, value in self.__dict__.iteritems()]
599
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
600
 
601
  def __eq__(self, other):
602
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
603
 
604
  def __ne__(self, other):
605
    return not (self == other)
606
 
607