-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
34 lines (28 loc) · 964 Bytes
/
Copy pathserver.py
File metadata and controls
34 lines (28 loc) · 964 Bytes
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
# server.py
import Ice
import sys
Ice.loadSlice('Calculator.ice')
import Demo
class CalculatorI(Demo.Calculator):
def sum(self, op1, op2, current=None):
return op1 + op2
def sub(self, op1, op2, current=None):
return op1 - op2
def mult(self, op1, op2, current=None):
return op1 * op2
def div(self, op1, op2, current=None):
if op2 == 0.0:
raise Demo.DivisionByZero(reason="Division by zero")
return op1 / op2
class Server(Ice.Application):
def run(self, argv):
adapter = self.communicator().createObjectAdapterWithEndpoints(
"CalculatorAdapter", "default -p 10000")
adapter.add(CalculatorI(), self.communicator().stringToIdentity("calculator"))
adapter.activate()
print("Calculator service running...")
self.communicator().waitForShutdown()
return 0
if __name__ == "__main__":
app = Server()
sys.exit(app.main(sys.argv))