comparison Resources/SyncOrthancFolder.py @ 85:581937911d14

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 13 Oct 2015 17:51:49 +0200
parents 02708dbbe449 16e247e407d9
children dbe7c97b6b4a
comparison
equal deleted inserted replaced
84:02708dbbe449 85:581937911d14
3 # 3 #
4 # This maintenance script updates the content of the "Orthanc" folder 4 # This maintenance script updates the content of the "Orthanc" folder
5 # to match the latest version of the Orthanc source code. 5 # to match the latest version of the Orthanc source code.
6 # 6 #
7 7
8 import multiprocessing
8 import os 9 import os
9 import shutil 10 import stat
10 import urllib2 11 import urllib2
11 12
13 TARGET = os.path.join(os.path.dirname(__file__), '..', 'Orthanc')
12 PLUGIN_SDK_VERSION = '0.9.4' 14 PLUGIN_SDK_VERSION = '0.9.4'
13 15 REPOSITORY = 'https://bitbucket.org/sjodogne/orthanc/raw'
14 SOURCE = '/home/jodogne/Subversion/orthanc'
15 TARGET = os.path.join(os.path.dirname(__file__), '..', 'Orthanc')
16 REPOSITORY = 'https://bitbucket.org/sjodogne/orthanc/raw/Orthanc-%s/Plugins/Include' % PLUGIN_SDK_VERSION
17 16
18 FILES = [ 17 FILES = [
19 'Core/ChunkedBuffer.cpp', 18 'Core/ChunkedBuffer.cpp',
20 'Core/ChunkedBuffer.h', 19 'Core/ChunkedBuffer.h',
21 'Core/Enumerations.cpp', 20 'Core/Enumerations.cpp',
78 77
79 SDK = [ 78 SDK = [
80 'orthanc/OrthancCPlugin.h', 79 'orthanc/OrthancCPlugin.h',
81 ] 80 ]
82 81
83 for f in FILES: 82 EXE = [
84 source = os.path.join(SOURCE, f) 83 'Resources/EmbedResources.py',
85 target = os.path.join(TARGET, f) 84 'Resources/WindowsResources.py',
85 ]
86
87
88 def Download(x):
89 branch = x[0]
90 source = x[1]
91 target = os.path.join(TARGET, x[2])
92 print target
93
86 try: 94 try:
87 os.makedirs(os.path.dirname(target)) 95 os.makedirs(os.path.dirname(target))
88 except: 96 except:
89 pass 97 pass
90 98
91 shutil.copy(source, target) 99 url = '%s/%s/%s' % (REPOSITORY, branch, source)
100
101 with open(target, 'w') as f:
102 f.write(urllib2.urlopen(url).read())
103
104
105 commands = []
106
107 for f in FILES:
108 commands.append([ 'default', f, f ])
92 109
93 for f in SDK: 110 for f in SDK:
94 source = '%s/%s' % (REPOSITORY, f) 111 commands.append([ 'Orthanc-%s' % PLUGIN_SDK_VERSION,
95 target = os.path.join(TARGET, 'Sdk-%s' % PLUGIN_SDK_VERSION, f) 112 'Plugins/Include/%s' % f,
96 try: 113 'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f) ])
97 os.makedirs(os.path.dirname(target))
98 except:
99 pass
100 114
101 with open(target, 'w') as g: 115
102 g.write(urllib2.urlopen(source).read()) 116 pool = multiprocessing.Pool(10) # simultaneous downloads
117 pool.map(Download, commands)
118
119
120 for exe in EXE:
121 path = os.path.join(TARGET, exe)
122 st = os.stat(path)
123 os.chmod(path, st.st_mode | stat.S_IEXEC)
124