changeset 71:ce0aee24667b

improvement to sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 09 Oct 2015 18:18:24 +0200
parents a9ee63815a8d
children 7479f1549b43
files Resources/SyncOrthancFolder.py
diffstat 1 files changed, 26 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/SyncOrthancFolder.py	Wed Oct 07 11:05:21 2015 +0200
+++ b/Resources/SyncOrthancFolder.py	Fri Oct 09 18:18:24 2015 +0200
@@ -6,15 +6,13 @@
 #
 
 import os
-import shutil
 import urllib2
+import multiprocessing
 
+TARGET = os.path.join(os.path.dirname(__file__), '..', 'Orthanc')
+BRANCH = 'default'
 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
-
 FILES = [
     'Plugins/Samples/Common/ExportedSymbols.list',
     'Plugins/Samples/Common/VersionScript.map',
@@ -39,23 +37,34 @@
     'orthanc/OrthancCppDatabasePlugin.h',
 ]
 
-for f in FILES:
-    source = os.path.join(SOURCE, f)
-    target = os.path.join(TARGET, f)
+
+
+def Download(x):
+    branch = x[0]
+    source = x[1]
+
+    target = os.path.join(TARGET, source)
+    print target
+
     try:
         os.makedirs(os.path.dirname(target))
     except:
         pass
 
-    shutil.copy(source, target)
+    url = 'https://bitbucket.org/sjodogne/orthanc/raw/%s/%s' % (branch, source)
+
+    with open(target, 'w') as f:
+        f.write(urllib2.urlopen(url).read())
+
+
+commands = []
+
+for f in FILES:
+    commands.append([ BRANCH, 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 ])
+
 
-    with open(target, 'w') as g:
-        g.write(urllib2.urlopen(source).read())
+pool = multiprocessing.Pool(10)  # simultaneous downloads
+pool.map(Download, commands)