Commit 4f240989c893ea9efdc5d37a1dc46bece590d7cc

Authored by Nadya Sutjiadi
Committed by GitHub
1 parent c9bf043e

Delete Poll.py

Showing 1 changed file with 0 additions and 53 deletions
LINETCR/Api/Poll.py deleted
1   -import os, sys, time
2   -path = os.path.join(os.path.dirname(__file__), '../lib/')
3   -sys.path.insert(0, path)
4   -
5   -from thrift.transport import THttpClient
6   -from thrift.protocol import TCompactProtocol
7   -
8   -from curve import LineService
9   -from curve.ttypes import *
10   -
11   -class Poll:
12   -
13   - client = None
14   -
15   - auth_query_path = "/api/v4/TalkService.do";
16   - http_query_path = "/S4";
17   - polling_path = "/P4";
18   - host = "gd2.line.naver.jp";
19   - port = 443;
20   -
21   - UA = "Line/1.4.17"
22   - LA = "IOSIPAD\x097.14.0\x09iPhone_OS\x0910.12.0"
23   -
24   - rev = 0
25   -
26   - def __init__(self, authToken):
27   - self.transport = THttpClient.THttpClient('https://gd2.line.naver.jp:443'+ self.http_query_path)
28   - self.transport.setCustomHeaders({
29   - "User-Agent" : self.UA,
30   - "X-Line-Application" : self.LA,
31   - "X-Line-Access": authToken
32   - });
33   - self.protocol = TCompactProtocol.TCompactProtocol(self.transport);
34   - self.client = LineService.Client(self.protocol)
35   - self.rev = self.client.getLastOpRevision()
36   - self.transport.path = self.polling_path
37   - self.transport.open()
38   -
39   - def stream(self, sleep=50000):
40   - #usleep = lambda x: time.sleep(x/1000000.0)
41   - while True:
42   - try:
43   - Ops = self.client.fetchOps(self.rev, 5)
44   - except EOFError:
45   - raise Exception("It might be wrong revision\n" + str(self.rev))
46   -
47   - for Op in Ops:
48   - # print Op.type
49   - if (Op.type != OpType.END_OF_OPERATION):
50   - self.rev = max(self.rev, Op.revision)
51   - return Op
52   -
53   - #usleep(sleep)