diff Resources/SyncOrthancFolder.py @ 187:d08d75fc6d6a java-code-model

synchronization of the code model with orthanc-java project
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 02 Jul 2024 17:02:11 +0200
parents c012edac593e
children 0c5da632f34d
line wrap: on
line diff
--- a/Resources/SyncOrthancFolder.py	Tue Jul 02 16:10:35 2024 +0200
+++ b/Resources/SyncOrthancFolder.py	Tue Jul 02 17:02:11 2024 +0200
@@ -12,8 +12,10 @@
 import urllib.request
 
 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc')
+ORTHANC_JAVA_VERSION = '1.0'
 PLUGIN_SDK_VERSION = '1.10.0'
-REPOSITORY = 'https://orthanc.uclouvain.be/hg/orthanc/raw-file'
+ORTHANC_CORE_REPOSITORY = 'https://orthanc.uclouvain.be/hg/orthanc/raw-file'
+ORTHANC_JAVA_REPOSITORY = 'https://orthanc.uclouvain.be/hg/orthanc-java/raw-file'
 
 FILES = [
     ('OrthancFramework/Resources/CMake/AutoGeneratedCode.cmake', 'CMake'),
@@ -34,15 +36,12 @@
     ('OrthancServer/Plugins/Samples/Common/VersionScriptPlugins.map', 'Plugins'),
 ]
 
-SDK = [
-    'orthanc/OrthancCPlugin.h',
-]
-
 
 def Download(x):
-    branch = x[0]
-    source = x[1]
-    target = os.path.join(TARGET, x[2])
+    repository = x[0]
+    branch = x[1]
+    source = x[2]
+    target = os.path.join(TARGET, x[3])
     print(target)
 
     try:
@@ -50,7 +49,7 @@
     except:
         pass
 
-    url = '%s/%s/%s' % (REPOSITORY, branch, source)
+    url = '%s/%s/%s' % (repository, branch, source)
 
     with open(target, 'wb') as f:
         try:
@@ -63,26 +62,37 @@
 commands = []
 
 for f in FILES:
-    commands.append([ 'default',
-                      f[0],
-                      os.path.join(f[1], os.path.basename(f[0])) ])
+    commands.append([
+        ORTHANC_CORE_REPOSITORY,
+        'default',
+        f[0],
+        os.path.join(f[1], os.path.basename(f[0]))
+    ])
+
+
+commands.append([
+    ORTHANC_JAVA_REPOSITORY,
+    'OrthancJava-%s' % ORTHANC_JAVA_VERSION,
+    'Resources/Orthanc/Sdk-%s/orthanc/OrthancCPlugin.h' % PLUGIN_SDK_VERSION,
+    'Sdk-%s/orthanc/OrthancCPlugin.h' % PLUGIN_SDK_VERSION,
+])
 
-for f in SDK:
-    commands.append([
-        'Orthanc-%s' % PLUGIN_SDK_VERSION, 
-        'OrthancServer/Plugins/Include/%s' % f,
-        'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f) 
-    ])
+
+commands.append([
+    ORTHANC_JAVA_REPOSITORY,
+    'OrthancJava-%s' % ORTHANC_JAVA_VERSION,
+    'CodeGeneration/CodeModel.json',
+    'Sdk-%s/CodeModel.json' % PLUGIN_SDK_VERSION,
+])
+
+
+commands.append([
+    ORTHANC_JAVA_REPOSITORY,
+    'OrthancJava-%s' % ORTHANC_JAVA_VERSION,
+    'CodeGeneration/CodeModel.json.license',
+    'Sdk-%s/CodeModel.json.license' % PLUGIN_SDK_VERSION,
+])
 
 
 pool = multiprocessing.Pool(10)  # simultaneous downloads
 pool.map(Download, commands)
-
-# Patch the SDK, if need be
-patch = os.path.join(os.path.abspath(os.path.dirname(__file__)),
-                     'OrthancCPlugin-%s.patch' % PLUGIN_SDK_VERSION)
-if os.path.exists(patch):
-    subprocess.check_call([ 'patch', '-p0', '-i', patch ],
-                          cwd = os.path.join(os.path.dirname(__file__),
-                                             'Orthanc',
-                                             'Sdk-%s' % PLUGIN_SDK_VERSION, 'orthanc'))