comparison RenderingPlugin/Resources/SyncOrthancFolder.py @ 1877:a2955abe4c2e

skeleton for the RenderingPlugin
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Jan 2022 08:23:38 +0100
parents Applications/Resources/SyncOrthancFolder.py@7053b8a0aaec
children 6a96a1920fd8
comparison
equal deleted inserted replaced
1876:b1f510e601d2 1877:a2955abe4c2e
1 #!/usr/bin/python
2
3 # Stone of Orthanc
4 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
5 # Department, University Hospital of Liege, Belgium
6 # Copyright (C) 2017-2022 Osimis S.A., Belgium
7 # Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM 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 urllib2
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 ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h', 'Plugins'),
39 ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp', 'Plugins'),
40 ('OrthancServer/Plugins/Samples/Common/OrthancPluginException.h', 'Plugins'),
41 ('OrthancServer/Plugins/Samples/Common/ExportedSymbolsPlugins.list', 'Plugins'),
42 ('OrthancServer/Plugins/Samples/Common/OrthancPluginsExports.cmake', 'Plugins'),
43 ('OrthancServer/Plugins/Samples/Common/VersionScriptPlugins.map', 'Plugins'),
44 ]
45
46 SDK = [
47 'orthanc/OrthancCPlugin.h',
48 ]
49
50
51 def Download(x):
52 branch = x[0]
53 source = x[1]
54 target = os.path.join(TARGET, x[2])
55 print target
56
57 try:
58 os.makedirs(os.path.dirname(target))
59 except:
60 pass
61
62 url = '%s/%s/%s' % (REPOSITORY, branch, source)
63
64 with open(target, 'w') as f:
65 f.write(urllib2.urlopen(url).read())
66
67
68 commands = []
69
70 for f in FILES:
71 commands.append([ 'default',
72 f[0],
73 os.path.join(f[1], os.path.basename(f[0])) ])
74
75 for f in SDK:
76 commands.append([
77 'Orthanc-%s' % PLUGIN_SDK_VERSION,
78 'Plugins/Include/%s' % f,
79 'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f)
80 ])
81
82 pool = multiprocessing.Pool(10) # simultaneous downloads
83 pool.map(Download, commands)