Skip to content

Commit cad56d7

Browse files
committed
Merge pull request #9 from rosette-api/0.7.0
Merge 0.7.0 to master
2 parents f1998df + e0a2482 commit cad56d7

File tree

9 files changed

+41
-1045
lines changed

9 files changed

+41
-1045
lines changed

examples/run_all.sh

100755100644
File mode changed.

rosette/api.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from socket import gethostbyname, gaierror
2828
from datetime import datetime
2929

30-
_ACCEPTABLE_SERVER_VERSION = "0.5"
30+
_BINDING_VERSION = "0.7"
3131
_GZIP_BYTEARRAY = bytearray([0x1F, 0x8b, 0x08])
3232
N_RETRIES = 3
3333
HTTP_CONNECTION = None
@@ -516,6 +516,23 @@ def info(self):
516516
r = _get_http(url, headers=headers)
517517
return self.__finish_result(r, "info")
518518

519+
def checkVersion(self):
520+
"""Issues a special "info" request to the L{EndpointCaller}'s specific endpoint.
521+
@return: A dictionary containing server version as well as version check"""
522+
if self.suburl is not None:
523+
self.checker()
524+
url = self.service_url + '/' + self.suburl + "/info?clientVersion=" + _BINDING_VERSION
525+
else:
526+
url = self.service_url + "/info?clientVersion=" + _BINDING_VERSION
527+
if self.debug:
528+
url = add_query(url, "debug", "true")
529+
self.logger.info('info: ' + url)
530+
headers = {'Accept': 'application/json'}
531+
if self.user_key is not None:
532+
headers["user_key"] = self.user_key
533+
r = _post_http(url, None, headers=headers)
534+
return self.__finish_result(r, "info")
535+
519536
def ping(self):
520537
"""Issues a "ping" request to the L{EndpointCaller}'s (server-wide) endpoint.
521538
@return: A dictionary if OK. If the server cannot be reached,
@@ -619,10 +636,10 @@ def check_version(self):
619636
if self.version_checked:
620637
return True
621638
op = EndpointCaller(self, None)
622-
result = op.info()
639+
result = op.checkVersion()
623640
version = ".".join(result["version"].split(".")[0:2])
624-
if version != _ACCEPTABLE_SERVER_VERSION:
625-
raise RosetteException("incompatibleVersion", "The server version is not " + _ACCEPTABLE_SERVER_VERSION,
641+
if result['versionChecked'] is False:
642+
raise RosetteException("incompatibleVersion", "The server version is not compatible with binding version " + _BINDING_VERSION,
626643
version)
627644
self.version_checked = True
628645
return True

0 commit comments

Comments
 (0)