示例#1
0
 def __init__(self, pickle_file):
     self.doc = WordExtractor(pickle_file)
示例#2
0
import types

sys.path.append('gen-py')

from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol

from word import WordExtractor
from word.ttypes import *

transport = TSocket.TSocket('localhost', 9090)
transport = TTransport.TBufferedTransport(transport)

protocol = TBinaryProtocol.TBinaryProtocol(transport)

client = WordExtractor.Client(protocol)
transport.open()

#contents = ColumnDescriptor(name='cf:', maxVersions=1)
#client.createTable('test', [contents])
try:
    client.getWord(r"/home/hdp-guanggao-intern/user/tangweihan/t.d",r"/home/hdp-guanggao-intern/user/tangweihan/4.data")

except IOError, e:          
    print e.traceback()
    
transport.close()

示例#3
0
            flock.release()
            return "Threre's same file(s) running:" + fileDuplicate
        inputfil.add(source)
        flock.release()
        print 'Receiving word from:' + source
        print 'Target File at:' + fileTarget
        threading.Thread(target=dealWord,
                         args=(source, fileTarget, MailAddr)).start()
        return 'Request Acceptted'

    def getWordList(self, word):
        print 'Extracting word' + word
        wordlist = word.split(',')
        for i in range(len(wordlist)):
            wordlist[i] = doWord(wordlist[i])
        return '\n'.join(wordlist)


handler = WordExtractorHandler()

processor = WordExtractor.Processor(handler)
transport = TSocket.TServerSocket(port=sys.argv[1])
tfactory = TTransport.TBufferedTransportFactory()
pfactory = TBinaryProtocol.TBinaryProtocolFactory()

server = TServer.TThreadPoolServer(processor, transport, tfactory, pfactory)

print 'Starting the server...'
server.serve()
print 'done.'