annotate Resources/SyncOrthancFolder.py @ 258:9856290c3cfd

todo
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 16 Apr 2021 17:45:11 +0200
parents 23cf7def8e44
children c7dc70a0a477
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 #!/usr/bin/python
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 #
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 # This maintenance script updates the content of the "Orthanc" folder
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # to match the latest version of the Orthanc source code.
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 #
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 import multiprocessing
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 import os
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 import stat
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 import urllib2
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc')
123
121ab36c87bd updating to Orthanc SDK 1.5.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 94
diff changeset
14 PLUGIN_SDK_VERSION = [ '0.9.5', '1.4.0', '1.5.2', '1.5.4' ]
149
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 123
diff changeset
15 REPOSITORY = 'https://hg.orthanc-server.com/orthanc/raw-file'
0
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 FILES = [
155
23cf7def8e44 use of OrthancPluginsExports.cmake, avoid race conditions with EmbedResources.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 152
diff changeset
18 ('OrthancFramework/Resources/CMake/AutoGeneratedCode.cmake', 'CMake'),
23cf7def8e44 use of OrthancPluginsExports.cmake, avoid race conditions with EmbedResources.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 152
diff changeset
19 ('OrthancFramework/Resources/CMake/Compiler.cmake', 'CMake'),
23cf7def8e44 use of OrthancPluginsExports.cmake, avoid race conditions with EmbedResources.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 152
diff changeset
20 ('OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake', 'CMake'),
23cf7def8e44 use of OrthancPluginsExports.cmake, avoid race conditions with EmbedResources.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 152
diff changeset
21 ('OrthancFramework/Resources/CMake/DownloadPackage.cmake', 'CMake'),
23cf7def8e44 use of OrthancPluginsExports.cmake, avoid race conditions with EmbedResources.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 152
diff changeset
22 ('OrthancFramework/Resources/CMake/GoogleTestConfiguration.cmake', 'CMake'),
23cf7def8e44 use of OrthancPluginsExports.cmake, avoid race conditions with EmbedResources.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 152
diff changeset
23 ('OrthancFramework/Resources/EmbedResources.py', '.'),
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 149
diff changeset
24 ('OrthancFramework/Resources/Toolchains/LinuxStandardBaseToolchain.cmake', '.'),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 149
diff changeset
25 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain32.cmake', '.'),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 149
diff changeset
26 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain64.cmake', '.'),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 149
diff changeset
27 ('OrthancFramework/Resources/Toolchains/MinGWToolchain.cmake', '.'),
155
23cf7def8e44 use of OrthancPluginsExports.cmake, avoid race conditions with EmbedResources.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 152
diff changeset
28 ('OrthancServer/Plugins/Samples/Common/ExportedSymbolsPlugins.list', 'Plugins'),
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 149
diff changeset
29 ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp', 'Plugins'),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 149
diff changeset
30 ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h', 'Plugins'),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 149
diff changeset
31 ('OrthancServer/Plugins/Samples/Common/OrthancPluginException.h', 'Plugins'),
155
23cf7def8e44 use of OrthancPluginsExports.cmake, avoid race conditions with EmbedResources.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 152
diff changeset
32 ('OrthancServer/Plugins/Samples/Common/OrthancPluginsExports.cmake', 'Plugins'),
23cf7def8e44 use of OrthancPluginsExports.cmake, avoid race conditions with EmbedResources.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 152
diff changeset
33 ('OrthancServer/Plugins/Samples/Common/VersionScriptPlugins.map', 'Plugins'),
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 149
diff changeset
34 ('OrthancServer/Sources/Search/DatabaseConstraint.cpp', 'Databases'),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 149
diff changeset
35 ('OrthancServer/Sources/Search/DatabaseConstraint.h', 'Databases'),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 149
diff changeset
36 ('OrthancServer/Sources/Search/ISqlLookupFormatter.cpp', 'Databases'),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 149
diff changeset
37 ('OrthancServer/Sources/Search/ISqlLookupFormatter.h', 'Databases'),
0
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 ]
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 SDK = [
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 'orthanc/OrthancCPlugin.h',
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 'orthanc/OrthancCDatabasePlugin.h',
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 ]
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 def Download(x):
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 branch = x[0]
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 source = x[1]
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 target = os.path.join(TARGET, x[2])
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 print target
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 try:
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 os.makedirs(os.path.dirname(target))
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 except:
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 pass
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 url = '%s/%s/%s' % (REPOSITORY, branch, source)
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 with open(target, 'w') as f:
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 f.write(urllib2.urlopen(url).read())
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 commands = []
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 for f in FILES:
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 commands.append([ 'default',
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 149
diff changeset
67 f[0],
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 149
diff changeset
68 os.path.join(f[1], os.path.basename(f[0])) ])
0
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
28
c0cb5d2cd696 checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
70 for version in PLUGIN_SDK_VERSION:
c0cb5d2cd696 checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
71 for f in SDK:
c0cb5d2cd696 checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
72 commands.append([
c0cb5d2cd696 checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
73 'Orthanc-%s' % version,
c0cb5d2cd696 checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
74 'Plugins/Include/%s' % f,
c0cb5d2cd696 checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
75 'Sdk-%s/%s' % (version, f)
c0cb5d2cd696 checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
76 ])
0
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 pool = multiprocessing.Pool(10) # simultaneous downloads
7cea966b6829 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 pool.map(Download, commands)