diff 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
line wrap: on
line diff
--- a/Resources/SyncOrthancFolder.py	Tue Oct 13 17:49:27 2015 +0200
+++ b/Resources/SyncOrthancFolder.py	Tue Oct 13 17:51:49 2015 +0200
@@ -5,15 +5,14 @@
 # to match the latest version of the Orthanc source code.
 #
 
+import multiprocessing
 import os
-import shutil
+import stat
 import urllib2
 
+TARGET = os.path.join(os.path.dirname(__file__), '..', 'Orthanc')
 PLUGIN_SDK_VERSION = '0.9.4'
-
-SOURCE = '/home/jodogne/Subversion/orthanc'
-TARGET = os.path.join(os.path.dirname(__file__), '..', 'Orthanc')
-REPOSITORY = 'https://bitbucket.org/sjodogne/orthanc/raw/Orthanc-%s/Plugins/Include' % PLUGIN_SDK_VERSION
+REPOSITORY = 'https://bitbucket.org/sjodogne/orthanc/raw'
 
 FILES = [
     'Core/ChunkedBuffer.cpp',
@@ -80,23 +79,46 @@
     'orthanc/OrthancCPlugin.h',
 ]   
 
-for f in FILES:
-    source = os.path.join(SOURCE, f)
-    target = os.path.join(TARGET, f)
+EXE = [
+    'Resources/EmbedResources.py',
+    'Resources/WindowsResources.py',
+]
+
+
+def Download(x):
+    branch = x[0]
+    source = x[1]
+    target = os.path.join(TARGET, x[2])
+    print target
+
     try:
         os.makedirs(os.path.dirname(target))
     except:
         pass
 
-    shutil.copy(source, target)
+    url = '%s/%s/%s' % (REPOSITORY, branch, source)
+
+    with open(target, 'w') as f:
+        f.write(urllib2.urlopen(url).read())
+
+
+commands = []
+
+for f in FILES:
+    commands.append([ 'default', f, f ])
 
 for f in SDK:
-    source = '%s/%s' % (REPOSITORY, f)
-    target = os.path.join(TARGET, 'Sdk-%s' % PLUGIN_SDK_VERSION, f)
-    try:
-        os.makedirs(os.path.dirname(target))
-    except:
-        pass
+    commands.append([ 'Orthanc-%s' % PLUGIN_SDK_VERSION, 
+                      'Plugins/Include/%s' % f,
+                      'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f) ])
+
 
-    with open(target, 'w') as g:
-        g.write(urllib2.urlopen(source).read())
+pool = multiprocessing.Pool(10)  # simultaneous downloads
+pool.map(Download, commands)
+
+
+for exe in EXE:
+    path = os.path.join(TARGET, exe)
+    st = os.stat(path)
+    os.chmod(path, st.st_mode | stat.S_IEXEC)
+