Mercurial > hg > orthanc-stone
annotate OrthancStone/Resources/SyncOrthancFolder.py @ 1959:889892e51545
Fix handling of "token": The authorization header was not set in QIDO-RS requests
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 27 Oct 2022 17:09:28 +0200 |
parents | 7053b8a0aaec |
children | 1bb0a9716876 |
rev | line source |
---|---|
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/python |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 |
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1549
diff
changeset
|
3 # Stone of Orthanc |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1549
diff
changeset
|
4 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1549
diff
changeset
|
5 # Department, University Hospital of Liege, Belgium |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
6 # Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
7 # Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1549
diff
changeset
|
8 # |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1549
diff
changeset
|
9 # This program is free software: you can redistribute it and/or |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1589
diff
changeset
|
10 # modify it under the terms of the GNU Lesser General Public License |
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1549
diff
changeset
|
11 # as published by the Free Software Foundation, either version 3 of |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1549
diff
changeset
|
12 # the License, or (at your option) any later version. |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1549
diff
changeset
|
13 # |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1549
diff
changeset
|
14 # This program is distributed in the hope that it will be useful, but |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1549
diff
changeset
|
15 # WITHOUT ANY WARRANTY; without even the implied warranty of |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1589
diff
changeset
|
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1589
diff
changeset
|
17 # Lesser General Public License for more details. |
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1549
diff
changeset
|
18 # |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1589
diff
changeset
|
19 # You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1589
diff
changeset
|
20 # License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1589
diff
changeset
|
21 # <http://www.gnu.org/licenses/>. |
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1549
diff
changeset
|
22 |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1549
diff
changeset
|
23 |
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 # |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 # This maintenance script updates the content of the "Orthanc" folder |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 # to match the latest version of the Orthanc source code. |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 # |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 import multiprocessing |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 import os |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 import stat |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 import urllib2 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc') |
1499 | 35 REPOSITORY = 'https://hg.orthanc-server.com/orthanc/raw-file' |
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 FILES = [ |
1540
e20a2381200d
cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1515
diff
changeset
|
38 ('OrthancFramework/Resources/CMake/AutoGeneratedCode.cmake', 'CMake'), |
e20a2381200d
cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1515
diff
changeset
|
39 ('OrthancFramework/Resources/CMake/Compiler.cmake', 'CMake'), |
1508
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1504
diff
changeset
|
40 ('OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake', 'CMake'), |
1540
e20a2381200d
cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1515
diff
changeset
|
41 ('OrthancFramework/Resources/CMake/DownloadPackage.cmake', 'CMake'), |
1549
a48ae10857b1
packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1540
diff
changeset
|
42 ('OrthancFramework/Resources/CMake/EmscriptenParameters.cmake', 'CMake'), |
1540
e20a2381200d
cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1515
diff
changeset
|
43 ('OrthancFramework/Resources/CMake/GoogleTestConfiguration.cmake', 'CMake'), |
e20a2381200d
cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1515
diff
changeset
|
44 ('OrthancFramework/Resources/EmbedResources.py', 'CMake'), |
1508
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1504
diff
changeset
|
45 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1504
diff
changeset
|
46 ('OrthancFramework/Resources/Toolchains/LinuxStandardBaseToolchain.cmake', 'Toolchains'), |
1540
e20a2381200d
cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1515
diff
changeset
|
47 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain32.cmake', 'Toolchains'), |
e20a2381200d
cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1515
diff
changeset
|
48 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain64.cmake', 'Toolchains'), |
e20a2381200d
cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1515
diff
changeset
|
49 ('OrthancFramework/Resources/Toolchains/MinGWToolchain.cmake', 'Toolchains'), |
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 ] |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 def Download(x): |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 branch = x[0] |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 source = x[1] |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 target = os.path.join(TARGET, x[2]) |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 print target |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 try: |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 os.makedirs(os.path.dirname(target)) |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 except: |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 pass |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 url = '%s/%s/%s' % (REPOSITORY, branch, source) |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
66 with open(target, 'w') as f: |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
67 f.write(urllib2.urlopen(url).read()) |
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 commands = [] |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 |
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 for f in FILES: |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
73 commands.append([ 'default', |
1504 | 74 f[0], |
75 os.path.join(f[1], os.path.basename(f[0])) ]) | |
76 | |
200
03afbee0cc7b
integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 pool = multiprocessing.Pool(10) # simultaneous downloads |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
78 pool.map(Download, commands) |