Mercurial > hg > orthanc-tests
diff Tests/Toolbox.py @ 404:931be0125954
Tests/CheckZipStreams.py
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 03 Jun 2021 17:03:06 +0200 |
parents | 9528e2a03d3c |
children | e769bcf2b94f |
line wrap: on
line diff
--- a/Tests/Toolbox.py Wed Jun 02 17:42:20 2021 +0200 +++ b/Tests/Toolbox.py Thu Jun 03 17:03:06 2021 +0200 @@ -230,23 +230,19 @@ # http://www.pythonware.com/library/pil/handbook/introduction.htm return UncompressImage(DoGet(orthanc, uri, headers = headers)) -def GetArchive(orthanc, uri): +def ParseArchive(s): # http://stackoverflow.com/a/1313868/881731 - s = DoGet(orthanc, uri) - if (sys.version_info >= (3, 0)): return zipfile.ZipFile(BytesIO(s), "r") else: return zipfile.ZipFile(StringIO(s), "r") +def GetArchive(orthanc, uri): + return ParseArchive(DoGet(orthanc, uri)) + def PostArchive(orthanc, uri, body): # http://stackoverflow.com/a/1313868/881731 - s = DoPost(orthanc, uri, body) - - if (sys.version_info >= (3, 0)): - return zipfile.ZipFile(BytesIO(s), "r") - else: - return zipfile.ZipFile(StringIO(s), "r") + return ParseArchive(DoPost(orthanc, uri, body)) def IsDefinedInLua(orthanc, name): s = DoPost(orthanc, '/tools/execute-script', 'print(type(%s))' % name, 'application/lua')