Mercurial > hg > orthanc-wsi
diff Resources/SyncOrthancFolder.py @ 241:5ed8d1cee52d
update SyncOrthancFolder.py to use Python 3
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 06 Dec 2021 13:24:33 +0100 |
parents | bab966288abe |
children | 71900ba9c8a9 |
line wrap: on
line diff
--- a/Resources/SyncOrthancFolder.py Wed Jun 23 09:12:29 2021 +0200 +++ b/Resources/SyncOrthancFolder.py Mon Dec 06 13:24:33 2021 +0100 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # This maintenance script updates the content of the "Orthanc" folder @@ -8,7 +8,7 @@ import multiprocessing import os import stat -import urllib2 +import urllib.request TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc') PLUGIN_SDK_VERSION = '1.0.0' @@ -54,7 +54,7 @@ branch = x[1] source = x[2] target = os.path.join(TARGET, x[3]) - print target + print(target) try: os.makedirs(os.path.dirname(target)) @@ -63,9 +63,9 @@ url = '%s/%s/%s' % (REPOSITORY % repository, branch, source) - with open(target, 'w') as f: + with open(target, 'wb') as f: try: - f.write(urllib2.urlopen(url).read()) + f.write(urllib.request.urlopen(url).read()) except: print('ERROR: %s' % url) raise