]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/tutorial/py.twisted/PythonServer.tac
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / tutorial / py.twisted / PythonServer.tac
CommitLineData
f67539c2
TL
1#!/usr/bin/env python
2
3#
4# Licensed to the Apache Software Foundation (ASF) under one
5# or more contributor license agreements. See the NOTICE file
6# distributed with this work for additional information
7# regarding copyright ownership. The ASF licenses this file
8# to you under the Apache License, Version 2.0 (the
9# "License"); you may not use this file except in compliance
10# with the License. You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing,
15# software distributed under the License is distributed on an
16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17# KIND, either express or implied. See the License for the
18# specific language governing permissions and limitations
19# under the License.
20#
21
22from twisted.application import internet, service
23from thrift.transport import TTwisted
24
25import glob
26import sys
27sys.path.append('gen-py.twisted')
28sys.path.insert(0, glob.glob('../../lib/py/build/lib*')[0])
29from tutorial import Calculator
30from PythonServer import CalculatorHandler
31from thrift.protocol import TBinaryProtocol
32
33
34def make_application():
35 application = service.Application('CalcServer')
36
37 handler = CalculatorHandler()
38 processor = Calculator.Processor(handler)
39
40 serverFactory = TTwisted.ThriftServerFactory(
41 processor,
42 TBinaryProtocol.TBinaryProtocolFactory())
43
44 calcService = internet.TCPServer(9090, serverFactory)
45
46 multiService = service.MultiService()
47 calcService.setServiceParent(multiService)
48 multiService.setServiceParent(application)
49
50 return application
51
52if __name__ == '__main__':
53 application = make_application()