view Resources/SyncOrthancFolder.py @ 17:ae34bde412ae default tip

note
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 21 Dec 2016 11:05:16 +0100
parents f7379096e014
children
line wrap: on
line source

#!/usr/bin/python

#
# This maintenance script updates the content of the "Orthanc" folder
# to match the latest version of the Orthanc source code.
#

import multiprocessing
import urllib2
import os
import shutil

TARGET = os.path.join(os.path.dirname(__file__), '..', 'Orthanc')
REPOSITORY = 'https://bitbucket.org/sjodogne/orthanc/raw'

FILES = [
    'Core/ChunkedBuffer.cpp',
    'Core/ChunkedBuffer.h',
    'Core/Enumerations.h',
    'Core/Enumerations.cpp',
    'Core/HttpClient.cpp',
    'Core/HttpClient.h',
    'Core/ICommand.h',
    'Core/IDynamicObject.h',
    'Core/Images/ImageAccessor.cpp',
    'Core/Images/ImageAccessor.h',
    'Core/Images/PngReader.cpp',
    'Core/Images/PngReader.h',
    'Core/Logging.h',
    'Core/MultiThreading/SharedMessageQueue.cpp',
    'Core/MultiThreading/SharedMessageQueue.h',
    'Core/OrthancException.h',
    'Core/PrecompiledHeaders.h',
    'Core/Toolbox.cpp',
    'Core/Toolbox.h',
    'Resources/CMake/BoostConfiguration.cmake',
    'Resources/CMake/Compiler.cmake',
    'Resources/CMake/DownloadPackage.cmake',
    'Resources/CMake/GoogleTestConfiguration.cmake',
    'Resources/CMake/JsonCppConfiguration.cmake',
    'Resources/CMake/LibCurlConfiguration.cmake',
    'Resources/CMake/LibPngConfiguration.cmake',
    'Resources/CMake/OpenSslConfiguration.cmake',
    'Resources/CMake/Uninstall.cmake.in',
    'Resources/CMake/ZlibConfiguration.cmake',
    'Resources/OrthancLogoDocumentation.png',
    'Resources/ThirdParty/VisualStudio/stdint.h',
    'Core/Enumerations.h',
]

EXE = [ ]


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

    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 ])

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)