Mercurial > hg > orthanc-client
comparison Resources/SyncOrthancFolder.py @ 13:a07ee8b6946e
cleanup
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 04 Jan 2016 14:04:43 +0100 |
parents | 2531a6a6c053 |
children | f7379096e014 |
comparison
equal
deleted
inserted
replaced
12:e59bf2554e59 | 13:a07ee8b6946e |
---|---|
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 | |
9 import urllib2 | |
8 import os | 10 import os |
9 import shutil | 11 import shutil |
10 | 12 |
11 SOURCE = '/home/jodogne/Subversion/Orthanc' | |
12 TARGET = os.path.join(os.path.dirname(__file__), '..', 'Orthanc') | 13 TARGET = os.path.join(os.path.dirname(__file__), '..', 'Orthanc') |
14 REPOSITORY = 'https://bitbucket.org/sjodogne/orthanc/raw' | |
13 | 15 |
14 FILES = [ | 16 FILES = [ |
15 'Core/ChunkedBuffer.cpp', | 17 'Core/ChunkedBuffer.cpp', |
16 'Core/ChunkedBuffer.h', | 18 'Core/ChunkedBuffer.h', |
17 'Core/Enumerations.cpp', | 19 'Core/Enumerations.cpp', |
18 'Core/HttpClient.cpp', | 20 'Core/HttpClient.cpp', |
19 'Core/HttpClient.h', | 21 'Core/HttpClient.h', |
20 'Core/ICommand.h', | 22 'Core/ICommand.h', |
21 'Core/IDynamicObject.h', | 23 'Core/IDynamicObject.h', |
22 'Core/ImageFormats/ImageAccessor.cpp', | 24 'Core/Images/ImageAccessor.cpp', |
23 'Core/ImageFormats/ImageAccessor.h', | 25 'Core/Images/ImageAccessor.h', |
24 'Core/ImageFormats/PngReader.cpp', | 26 'Core/Images/PngReader.cpp', |
25 'Core/ImageFormats/PngReader.h', | 27 'Core/Images/PngReader.h', |
26 'Core/MultiThreading/SharedMessageQueue.cpp', | 28 'Core/MultiThreading/SharedMessageQueue.cpp', |
27 'Core/MultiThreading/SharedMessageQueue.h', | 29 'Core/MultiThreading/SharedMessageQueue.h', |
28 'Core/OrthancException.cpp', | |
29 'Core/OrthancException.h', | 30 'Core/OrthancException.h', |
30 'Core/PrecompiledHeaders.h', | 31 'Core/PrecompiledHeaders.h', |
31 'Core/Toolbox.cpp', | 32 'Core/Toolbox.cpp', |
32 'Core/Toolbox.h', | 33 'Core/Toolbox.h', |
33 'Resources/CMake/BoostConfiguration.cmake', | 34 'Resources/CMake/BoostConfiguration.cmake', |
53 'Resources/ThirdParty/minizip/zip.h', | 54 'Resources/ThirdParty/minizip/zip.h', |
54 'Resources/ThirdParty/VisualStudio/stdint.h', | 55 'Resources/ThirdParty/VisualStudio/stdint.h', |
55 'Core/Enumerations.h', | 56 'Core/Enumerations.h', |
56 ] | 57 ] |
57 | 58 |
58 for f in FILES: | 59 EXE = [ ] |
59 source = os.path.join(SOURCE, f) | 60 |
60 target = os.path.join(TARGET, f) | 61 |
62 def Download(x): | |
63 branch = x[0] | |
64 source = x[1] | |
65 target = os.path.join(TARGET, x[2]) | |
66 print target | |
67 | |
61 try: | 68 try: |
62 os.makedirs(os.path.dirname(target)) | 69 os.makedirs(os.path.dirname(target)) |
63 except: | 70 except: |
64 pass | 71 pass |
65 | 72 |
66 shutil.copy(source, target) | 73 url = '%s/%s/%s' % (REPOSITORY, branch, source) |
74 | |
75 with open(target, 'w') as f: | |
76 f.write(urllib2.urlopen(url).read()) | |
77 | |
78 | |
79 commands = [] | |
80 | |
81 for f in FILES: | |
82 commands.append([ 'default', f, f ]) | |
83 | |
84 pool = multiprocessing.Pool(10) # simultaneous downloads | |
85 pool.map(Download, commands) | |
86 | |
87 for exe in EXE: | |
88 path = os.path.join(TARGET, exe) | |
89 st = os.stat(path) | |
90 os.chmod(path, st.st_mode | stat.S_IEXEC) |