annotate OrthancStone/Resources/SyncOrthancFolder.py @ 1515:b750b6eab453

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2020 20:52:35 +0200
parents 244ad1e4e76a
children e20a2381200d
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
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 #
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 # 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
5 # 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
6 #
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 import multiprocessing
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 import os
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 import stat
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 import urllib2
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc')
1504
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
14 PLUGIN_SDK_VERSION = '1.0.0'
1499
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
15 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
16
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 FILES = [
1508
dd1d1cc0575d use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1504
diff changeset
18 ('OrthancFramework/Resources/CMake/AutoGeneratedCode.cmake', 'CMake'),
dd1d1cc0575d use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1504
diff changeset
19 ('OrthancFramework/Resources/CMake/Compiler.cmake', 'CMake'),
dd1d1cc0575d use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1504
diff changeset
20 ('OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake', 'CMake'),
dd1d1cc0575d use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1504
diff changeset
21 ('OrthancFramework/Resources/CMake/DownloadPackage.cmake', 'CMake'),
dd1d1cc0575d use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1504
diff changeset
22 ('OrthancFramework/Resources/CMake/GoogleTestConfiguration.cmake', 'CMake'),
dd1d1cc0575d use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1504
diff changeset
23 ('OrthancFramework/Resources/EmbedResources.py', 'CMake'),
dd1d1cc0575d use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1504
diff changeset
24
dd1d1cc0575d use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1504
diff changeset
25 ('OrthancFramework/Resources/Toolchains/LinuxStandardBaseToolchain.cmake', 'Toolchains'),
dd1d1cc0575d use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1504
diff changeset
26 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain32.cmake', 'Toolchains'),
dd1d1cc0575d use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1504
diff changeset
27 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain64.cmake', 'Toolchains'),
dd1d1cc0575d use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1504
diff changeset
28 ('OrthancFramework/Resources/Toolchains/MinGWToolchain.cmake', 'Toolchains'),
1504
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
29
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
30 ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h',
1515
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
31 '../../../StoneWebViewer/Resources/Orthanc/Plugins'),
1504
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
32 ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp',
1515
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
33 '../../../StoneWebViewer/Resources/Orthanc/Plugins'),
1504
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
34 ('OrthancServer/Plugins/Samples/Common/OrthancPluginException.h',
1515
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
35 '../../../StoneWebViewer/Resources/Orthanc/Plugins'),
1508
dd1d1cc0575d use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1504
diff changeset
36 ('OrthancServer/Plugins/Samples/Common/ExportedSymbolsPlugins.list',
1515
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
37 '../../../StoneWebViewer/Resources/Orthanc/Plugins'),
1508
dd1d1cc0575d use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1504
diff changeset
38 ('OrthancServer/Plugins/Samples/Common/OrthancPluginsExports.cmake',
1515
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
39 '../../../StoneWebViewer/Resources/Orthanc/Plugins'),
1508
dd1d1cc0575d use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1504
diff changeset
40 ('OrthancServer/Plugins/Samples/Common/VersionScriptPlugins.map',
1515
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
41 '../../../StoneWebViewer/Resources/Orthanc/Plugins'),
1504
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
42 ]
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
43
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
44 SDK = [
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
45 'orthanc/OrthancCPlugin.h',
200
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 ]
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 def Download(x):
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 branch = x[0]
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 source = x[1]
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 target = os.path.join(TARGET, x[2])
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 print target
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 try:
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 os.makedirs(os.path.dirname(target))
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 except:
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 pass
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 url = '%s/%s/%s' % (REPOSITORY, branch, source)
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
212
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 208
diff changeset
62 with open(target, 'w') as f:
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 208
diff changeset
63 f.write(urllib2.urlopen(url).read())
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
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 commands = []
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 for f in FILES:
212
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 208
diff changeset
69 commands.append([ 'default',
1504
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
70 f[0],
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
71 os.path.join(f[1], os.path.basename(f[0])) ])
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
72
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
73 for f in SDK:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
74 commands.append([
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
75 'Orthanc-%s' % PLUGIN_SDK_VERSION,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
76 'Plugins/Include/%s' % f,
1515
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
77 '../../../StoneWebViewer/Resources/OrthancSdk-%s/%s' % (PLUGIN_SDK_VERSION, f)
1504
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1499
diff changeset
78 ])
200
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
03afbee0cc7b integration of Orthanc core into Stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 pool = multiprocessing.Pool(10) # simultaneous downloads
212
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 208
diff changeset
81 pool.map(Download, commands)