annotate OrthancStone/Resources/SyncOrthancFolder.py @ 2070:82dbe2729b69 deep-learning

separation of deep learning resources
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 19 May 2023 17:19:50 +0200
parents 6a96a1920fd8
children 07964689cb0b
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
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
2002
1bb0a9716876 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
32 import sys
1bb0a9716876 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
33
1bb0a9716876 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
34 if sys.version_info[0] < 3:
2004
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2002
diff changeset
35 from urllib2 import urlopen
2002
1bb0a9716876 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
36 else:
1bb0a9716876 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
37 from urllib.request import urlopen
1bb0a9716876 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
38
200
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc')
1499
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
41 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
42
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 FILES = [
1540
e20a2381200d cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1515
diff changeset
44 ('OrthancFramework/Resources/CMake/AutoGeneratedCode.cmake', 'CMake'),
e20a2381200d cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1515
diff changeset
45 ('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
46 ('OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake', 'CMake'),
1540
e20a2381200d cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1515
diff changeset
47 ('OrthancFramework/Resources/CMake/DownloadPackage.cmake', 'CMake'),
1549
a48ae10857b1 packaging of the WebAssembly module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1540
diff changeset
48 ('OrthancFramework/Resources/CMake/EmscriptenParameters.cmake', 'CMake'),
1540
e20a2381200d cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1515
diff changeset
49 ('OrthancFramework/Resources/CMake/GoogleTestConfiguration.cmake', 'CMake'),
e20a2381200d cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1515
diff changeset
50 ('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
51
dd1d1cc0575d use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1504
diff changeset
52 ('OrthancFramework/Resources/Toolchains/LinuxStandardBaseToolchain.cmake', 'Toolchains'),
1540
e20a2381200d cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1515
diff changeset
53 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain32.cmake', 'Toolchains'),
e20a2381200d cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1515
diff changeset
54 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain64.cmake', 'Toolchains'),
e20a2381200d cleaning OrthancStone/Resources/SyncOrthancFolder.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1515
diff changeset
55 ('OrthancFramework/Resources/Toolchains/MinGWToolchain.cmake', 'Toolchains'),
200
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 ]
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
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 def Download(x):
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 branch = x[0]
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 source = x[1]
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 target = os.path.join(TARGET, x[2])
2002
1bb0a9716876 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
63 print(target)
200
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 try:
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 os.makedirs(os.path.dirname(target))
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 except:
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 pass
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 url = '%s/%s/%s' % (REPOSITORY, branch, source)
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
2002
1bb0a9716876 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
72 with open(target, 'wb') as f:
1bb0a9716876 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
73 f.write(urlopen(url).read())
200
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 commands = []
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 for f in FILES:
212
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 208
diff changeset
79 commands.append([ 'default',
1504
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
80 f[0],
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
81 os.path.join(f[1], os.path.basename(f[0])) ])
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
82
200
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 pool = multiprocessing.Pool(10) # simultaneous downloads
212
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 208
diff changeset
84 pool.map(Download, commands)