annotate Resources/SyncOrthancFolder.py @ 27:8f3137dc55c1

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 06 Jul 2020 21:33:11 +0200
parents 065bc476bcdc
children 1256194e1c08
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 #!/usr/bin/python
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 #
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 # This maintenance script updates the content of the "Orthanc" folder
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # to match the latest version of the Orthanc source code.
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 #
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 import multiprocessing
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 import os
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 import stat
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 import urllib2
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc')
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 PLUGIN_SDK_VERSION = [ '1.4.2' ]
20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 7
diff changeset
15 REPOSITORY = 'https://hg.orthanc-server.com/orthanc/raw-file'
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 FILES = [
24
065bc476bcdc use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
18 ('OrthancFramework/Resources/CMake/AutoGeneratedCode.cmake', 'CMake'),
065bc476bcdc use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
19 ('OrthancFramework/Resources/CMake/Compiler.cmake', 'CMake'),
065bc476bcdc use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
20 ('OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake', 'CMake'),
065bc476bcdc use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
21 ('OrthancFramework/Resources/CMake/DownloadPackage.cmake', 'CMake'),
065bc476bcdc use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
22 ('OrthancFramework/Resources/CMake/GoogleTestConfiguration.cmake', 'CMake'),
065bc476bcdc use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
23 ('OrthancFramework/Resources/EmbedResources.py', 'CMake'),
065bc476bcdc use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
24
22
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
25 ('OrthancFramework/Resources/Toolchains/LinuxStandardBaseToolchain.cmake', '.'),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
26 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain32.cmake', '.'),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
27 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain64.cmake', '.'),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
28 ('OrthancFramework/Resources/Toolchains/MinGWToolchain.cmake', '.'),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
29
24
065bc476bcdc use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
30 ('OrthancServer/Plugins/Samples/Common/ExportedSymbolsPlugins.list', 'Plugins'),
22
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
31 ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp', 'Plugins'),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
32 ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h', 'Plugins'),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
33 ('OrthancServer/Plugins/Samples/Common/OrthancPluginException.h', 'Plugins'),
24
065bc476bcdc use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
34 ('OrthancServer/Plugins/Samples/Common/OrthancPluginsExports.cmake', 'Plugins'),
065bc476bcdc use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 22
diff changeset
35 ('OrthancServer/Plugins/Samples/Common/VersionScriptPlugins.map', 'Plugins'),
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 ]
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 SDK = [
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 'orthanc/OrthancCPlugin.h',
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 ]
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 def Download(x):
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 branch = x[0]
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 source = x[1]
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 target = os.path.join(TARGET, x[2])
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 print target
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 try:
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 os.makedirs(os.path.dirname(target))
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 except:
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 pass
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 url = '%s/%s/%s' % (REPOSITORY, branch, source)
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 with open(target, 'w') as f:
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 f.write(urllib2.urlopen(url).read())
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 commands = []
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 for f in FILES:
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 commands.append([ 'default',
22
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
64 f[0],
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 20
diff changeset
65 os.path.join(f[1], os.path.basename(f[0])) ])
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
7
151e29acbb13 use orthanc sdk 1.4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
67 for version in PLUGIN_SDK_VERSION:
151e29acbb13 use orthanc sdk 1.4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
68 for f in SDK:
151e29acbb13 use orthanc sdk 1.4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
69 commands.append([
151e29acbb13 use orthanc sdk 1.4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
70 'Orthanc-%s' % version,
151e29acbb13 use orthanc sdk 1.4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
71 'Plugins/Include/%s' % f,
151e29acbb13 use orthanc sdk 1.4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
72 'Sdk-%s/%s' % (version, f)
151e29acbb13 use orthanc sdk 1.4.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
73 ])
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 pool = multiprocessing.Pool(10) # simultaneous downloads
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 pool.map(Download, commands)