提交 7f3cfbce 编写于 作者: W wangguibao

Elastic CTR

上级 e561855c
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from __future__ import print_function
import json import json
import sys import sys
import os import os
...@@ -30,7 +31,7 @@ class ElasticCTRAPI(object): ...@@ -30,7 +31,7 @@ class ElasticCTRAPI(object):
def read_slots_conf(self, slots_conf_file): def read_slots_conf(self, slots_conf_file):
if not os.path.exists(slots_conf_file): if not os.path.exists(slots_conf_file):
print "Path %s not exist" % sltos_conf_file print("Path %s not exist" % sltos_conf_file)
return -1 return -1
with open(slots_conf_file, "r") as f: with open(slots_conf_file, "r") as f:
for line in f: for line in f:
...@@ -51,11 +52,11 @@ class ElasticCTRAPI(object): ...@@ -51,11 +52,11 @@ class ElasticCTRAPI(object):
def add_slot(self, instance, slot, feasigns): def add_slot(self, instance, slot, feasigns):
if not isinstance(instance, list): if not isinstance(instance, list):
print "add slot: parameter invalid: instance should be list" print("add slot: parameter invalid: instance should be list")
return -1 return -1
if not isinstance(feasigns, list): if not isinstance(feasigns, list):
print "add slot: value format invalid: feasigns should be list" print("add slot: value format invalid: feasigns should be list")
return -1 return -1
kv = [{"slot_name": slot, "feasigns": feasigns}] kv = [{"slot_name": slot, "feasigns": feasigns}]
...@@ -82,7 +83,7 @@ class ElasticCTRAPI(object): ...@@ -82,7 +83,7 @@ class ElasticCTRAPI(object):
response = self._conn.getresponse() response = self._conn.getresponse()
return response.read() return response.read()
except httplib.HTTPException as e: except httplib.HTTPException as e:
print e.reason print(e.reason)
elif sys.version_info[0] == 3: elif sys.version_info[0] == 3:
try: try:
self._conn.request( self._conn.request(
...@@ -91,4 +92,4 @@ class ElasticCTRAPI(object): ...@@ -91,4 +92,4 @@ class ElasticCTRAPI(object):
response = self._conn.getresponse() response = self._conn.getresponse()
return response.read() return response.read()
except http.clinet.HTTPException as e: except http.clinet.HTTPException as e:
print e.reason print(e.reason)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册