Mercurial > hg > orthanc-object-storage
comparison Common/Resources/SyncOrthancFolder.py @ 117:a3590caf93a3 2.3.0
sync orthanc folder
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 13 Nov 2023 20:56:41 +0100 |
parents | 37a4b8e2577f |
children | 40efe821932a |
comparison
equal
deleted
inserted
replaced
116:fdc007216fde | 117:a3590caf93a3 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/python3 |
2 | 2 |
3 # | 3 # |
4 # This maintenance script updates the content of the "Orthanc" folder | 4 # This maintenance script updates the content of the "Orthanc" folder |
5 # to match the latest version of the Orthanc source code. | 5 # to match the latest version of the Orthanc source code. |
6 # | 6 # |
7 | 7 |
8 import multiprocessing | 8 import multiprocessing |
9 import os | 9 import os |
10 import stat | 10 import stat |
11 import urllib2 | 11 import urllib.request |
12 | 12 |
13 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc') | 13 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc') |
14 PLUGIN_SDK_VERSION = '1.12.1' | 14 PLUGIN_SDK_VERSION = '1.12.1' |
15 REPOSITORY = 'https://hg.orthanc-server.com/orthanc/raw-file' | 15 REPOSITORY = 'https://orthanc.uclouvain.be/hg/orthanc/raw-file' |
16 | 16 |
17 FILES = [ | 17 FILES = [ |
18 ('OrthancFramework/Resources/CMake/AutoGeneratedCode.cmake', 'CMake'), | 18 ('OrthancFramework/Resources/CMake/AutoGeneratedCode.cmake', 'CMake'), |
19 ('OrthancFramework/Resources/CMake/Compiler.cmake', 'CMake'), | 19 ('OrthancFramework/Resources/CMake/Compiler.cmake', 'CMake'), |
20 ('OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake', 'CMake'), | 20 ('OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake', 'CMake'), |
40 | 40 |
41 def Download(x): | 41 def Download(x): |
42 branch = x[0] | 42 branch = x[0] |
43 source = x[1] | 43 source = x[1] |
44 target = os.path.join(TARGET, x[2]) | 44 target = os.path.join(TARGET, x[2]) |
45 print target | 45 print(target) |
46 | 46 |
47 try: | 47 try: |
48 os.makedirs(os.path.dirname(target)) | 48 os.makedirs(os.path.dirname(target)) |
49 except: | 49 except: |
50 pass | 50 pass |
51 | 51 |
52 url = '%s/%s/%s' % (REPOSITORY, branch, source) | 52 url = '%s/%s/%s' % (REPOSITORY, branch, source) |
53 | 53 |
54 with open(target, 'w') as f: | 54 with open(target, 'wb') as f: |
55 try: | 55 try: |
56 f.write(urllib2.urlopen(url).read()) | 56 f.write(urllib.request.urlopen(url).read()) |
57 except: | 57 except: |
58 print('ERROR %s' % url) | 58 print('ERROR %s' % url) |
59 raise | 59 raise |
60 | 60 |
61 | 61 |