annotate OrthancStone/Resources/SyncOrthancFolder.py @ 1730:af4a2d08549c

preparing for release
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 02 Dec 2020 12:47:05 +0100
parents 8563ea5d8ae4
children 9ac2a65d4172
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
6 # Copyright (C) 2017-2020 Osimis S.A., Belgium
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
7 #
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
8 # 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
9 # 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
10 # 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
11 # the License, or (at your option) any later version.
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
12 #
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
13 # 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
14 # 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
15 # 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
16 # Lesser General Public License for more details.
1589
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
17 #
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
18 # 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
19 # 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
20 # <http://www.gnu.org/licenses/>.
1589
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
21
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
22
200
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 # 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
25 # 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
26 #
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 import multiprocessing
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 import os
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 import stat
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 import urllib2
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc')
1499
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
34 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
35
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 FILES = [
1540
e20a2381200d cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1515
diff changeset
37 ('OrthancFramework/Resources/CMake/AutoGeneratedCode.cmake', 'CMake'),
e20a2381200d cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1515
diff changeset
38 ('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
39 ('OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake', 'CMake'),
1540
e20a2381200d cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1515
diff changeset
40 ('OrthancFramework/Resources/CMake/DownloadPackage.cmake', 'CMake'),
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1540
diff changeset
41 ('OrthancFramework/Resources/CMake/EmscriptenParameters.cmake', 'CMake'),
1540
e20a2381200d cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1515
diff changeset
42 ('OrthancFramework/Resources/CMake/GoogleTestConfiguration.cmake', 'CMake'),
e20a2381200d cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1515
diff changeset
43 ('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
44
dd1d1cc0575d use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1504
diff changeset
45 ('OrthancFramework/Resources/Toolchains/LinuxStandardBaseToolchain.cmake', 'Toolchains'),
1540
e20a2381200d cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1515
diff changeset
46 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain32.cmake', 'Toolchains'),
e20a2381200d cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1515
diff changeset
47 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain64.cmake', 'Toolchains'),
e20a2381200d cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1515
diff changeset
48 ('OrthancFramework/Resources/Toolchains/MinGWToolchain.cmake', 'Toolchains'),
200
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 ]
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 def Download(x):
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 branch = x[0]
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 source = x[1]
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 target = os.path.join(TARGET, x[2])
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 print target
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 try:
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 os.makedirs(os.path.dirname(target))
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 except:
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 pass
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 url = '%s/%s/%s' % (REPOSITORY, branch, source)
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
212
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 208
diff changeset
65 with open(target, 'w') as f:
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 208
diff changeset
66 f.write(urllib2.urlopen(url).read())
200
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
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 commands = []
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 for f in FILES:
212
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 208
diff changeset
72 commands.append([ 'default',
1504
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
73 f[0],
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
74 os.path.join(f[1], os.path.basename(f[0])) ])
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
75
200
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 pool = multiprocessing.Pool(10) # simultaneous downloads
212
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 208
diff changeset
77 pool.map(Download, commands)