-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice.py
More file actions
53 lines (47 loc) · 1.13 KB
/
Copy pathservice.py
File metadata and controls
53 lines (47 loc) · 1.13 KB
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
52
53
#encoding=utf-8
import urllib, urllib2, json
import cookielib
from util import *
from Redis import *
import sys
from threading import Thread
import getopt
def Run(argv):
try:
opts, args = getopt.getopt(argv[1:], 'vm:', ['prefix=', 'mode=', 'culture='])
except getopt.GetoptError, err:
print str(err)
print "parameter error"
sys.exit(2)
if len(opts) < 1:
print "parameter numbers error [%s]" % len(opts)
sys.exit(2)
prefix=""
mode=""
culture="zh-CN"
for option, arg in opts:
if option in ('--prefix'):
prefix = arg
elif option in ('--mode'):
mode = arg
elif option in ('--culture'):
culture = arg
else :
print 'unhandled option'
sys.exit(3)
country="USA"
url_type="traveltochina"
print "prefix=%s, mode=%s, culture=%s" % (prefix, mode, culture)
redisdb=Redis(country=country, url_type=url_type, culture=culture)
ret=""
if mode == "airline" :
ret = redisdb.completeAirline(prefix)
elif mode == "city" :
ret = redisdb.complete(prefix)
else :
ret = redisdb.complete(prefix)
print "result=%s" % ret
if __name__ == '__main__':
reload(sys)
sys.setdefaultencoding('utf-8')
Run(sys.argv)