File: client.py

package info (click to toggle)
pyro4 4.82-2
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 2,528 kB
  • sloc: python: 17,736; makefile: 169; sh: 113; javascript: 62
file content (51 lines) | stat: -rw-r--r-- 1,423 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from __future__ import print_function
import sys

import Pyro4


test = Pyro4.core.Proxy("PYRONAME:example.exceptions")

print(test.div(2.0, 9.0))
try:
    print(2 // 0)
except ZeroDivisionError as x:
    print("DIVIDE BY ZERO: %s" % x)
try:
    print(test.div(2, 0))
except ZeroDivisionError as x:
    print("DIVIDE BY ZERO: %s" % x)
try:
    result = test.error()
    print("%r, %s" % (result, result))
except ValueError as x:
    print("VALUERROR: %s" % x)
try:
    result = test.error2()
    print("%r, %s" % (result, result))
except ValueError as x:
    print("VALUERROR: %s" % x)
try:
    result = test.othererr()
    print("%r, %s" % (result, result))
except Exception as x:
    print("ANOTHER ERROR: %s" % x)
try:
    result = test.unserializable()
    print("%r, %s" % (result, result))
except Exception as x:
    print("UNSERIALIZABLE ERROR: %s" % x)

print("\n*** invoking server method that crashes, catching traceback ***")
try:
    print(test.complexerror())
except Exception as x:
    print("CAUGHT ERROR  >>> %s" % x)
    print("Printing Pyro traceback >>>>>>")
    print("".join(Pyro4.util.getPyroTraceback()))
    print("<<<<<<< end of Pyro traceback")

print("\n*** installing pyro's excepthook")
sys.excepthook = Pyro4.util.excepthook
print("*** invoking server method that crashes, not catching anything ***")
print(test.complexerror())  # due to the excepthook, the exception will show the pyro error