| 37 | |
| 38 | @inlineCallbacks |
| 39 | def main(client): |
| 40 | yield client.ping() |
| 41 | print('ping()') |
| 42 | |
| 43 | sum = yield client.add(1, 1) |
| 44 | print(('1+1=%d' % (sum))) |
| 45 | |
| 46 | work = Work() |
| 47 | |
| 48 | work.op = Operation.DIVIDE |
| 49 | work.num1 = 1 |
| 50 | work.num2 = 0 |
| 51 | |
| 52 | try: |
| 53 | quotient = yield client.calculate(1, work) |
| 54 | print('Whoa? You know how to divide by zero?') |
| 55 | print('FYI the answer is %d' % quotient) |
| 56 | except InvalidOperation as e: |
| 57 | print(('InvalidOperation: %r' % e)) |
| 58 | |
| 59 | work.op = Operation.SUBTRACT |
| 60 | work.num1 = 15 |
| 61 | work.num2 = 10 |
| 62 | |
| 63 | diff = yield client.calculate(1, work) |
| 64 | print(('15-10=%d' % (diff))) |
| 65 | |
| 66 | log = yield client.getStruct(1) |
| 67 | print(('Check log: %s' % (log.value))) |
| 68 | reactor.stop() |
| 69 | |
| 70 | |
| 71 | if __name__ == '__main__': |