comparison Resources/SyncOrthancFolder.py @ 0:39585ba26f20

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 15 Jun 2023 09:48:46 +0200
parents
children 1bda8ea224de
comparison
equal deleted inserted replaced
-1:000000000000 0:39585ba26f20
1 #!/usr/bin/python3
2
3 # SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 # OHIF plugin for Orthanc
7 # Copyright (C) 2023 Sebastien Jodogne, UCLouvain, Belgium
8 #
9 # This program is free software: you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation, either version 3 of the
12 # License, or (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
22
23 #
24 # This maintenance script updates the content of the "Orthanc" folder
25 # to match the latest version of the Orthanc source code.
26 #
27
28 import multiprocessing
29 import os
30 import stat
31 import urllib.request
32
33 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc')
34 PLUGIN_SDK_VERSION = '1.0.0'
35 REPOSITORY = 'https://hg.orthanc-server.com/orthanc/raw-file'
36
37 FILES = [
38 ('OrthancFramework/Resources/CMake/AutoGeneratedCode.cmake', 'CMake'),
39 ('OrthancFramework/Resources/CMake/Compiler.cmake', 'CMake'),
40 ('OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake', 'CMake'),
41 ('OrthancFramework/Resources/CMake/DownloadPackage.cmake', 'CMake'),
42 ('OrthancFramework/Resources/EmbedResources.py', 'CMake'),
43 ('OrthancFramework/Resources/Toolchains/LinuxStandardBaseToolchain.cmake', 'Toolchains'),
44 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain32.cmake', 'Toolchains'),
45 ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain64.cmake', 'Toolchains'),
46 ('OrthancFramework/Resources/Toolchains/MinGWToolchain.cmake', 'Toolchains'),
47 ('OrthancServer/Plugins/Samples/Common/ExportedSymbolsPlugins.list', 'Plugins'),
48 ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp', 'Plugins'),
49 ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h', 'Plugins'),
50 ('OrthancServer/Plugins/Samples/Common/OrthancPluginException.h', 'Plugins'),
51 ('OrthancServer/Plugins/Samples/Common/OrthancPluginsExports.cmake', 'Plugins'),
52 ('OrthancServer/Plugins/Samples/Common/VersionScriptPlugins.map', 'Plugins'),
53 ]
54
55 SDK = [
56 'orthanc/OrthancCPlugin.h',
57 ]
58
59
60 def Download(x):
61 branch = x[0]
62 source = x[1]
63 target = os.path.join(TARGET, x[2])
64 print(target)
65
66 try:
67 os.makedirs(os.path.dirname(target))
68 except:
69 pass
70
71 url = '%s/%s/%s' % (REPOSITORY, branch, source)
72
73 with open(target, 'wb') as f:
74 try:
75 f.write(urllib.request.urlopen(url).read())
76 except:
77 print('ERROR %s' % url)
78 raise
79
80
81 commands = []
82
83 for f in FILES:
84 commands.append([ 'default',
85 f[0],
86 os.path.join(f[1], os.path.basename(f[0])) ])
87
88 for f in SDK:
89 commands.append([
90 'Orthanc-%s' % PLUGIN_SDK_VERSION,
91 'Plugins/Include/%s' % f,
92 'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f)
93 ])
94
95
96 pool = multiprocessing.Pool(10) # simultaneous downloads
97 pool.map(Download, commands)