annotate OrthancFramework/Resources/WindowsResources.py @ 5853:4d932683049d get-scu tip

very first implementation of C-Get SCU
author Alain Mazy <am@orthanc.team>
date Tue, 29 Oct 2024 17:25:49 +0100
parents f7adfb22e20e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 #!/usr/bin/python
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 # Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1471
diff changeset
4 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # Department, University Hospital of Liege, Belgium
5640
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
6 # Copyright (C) 2017-2023 Osimis S.A., Belgium
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
7 # Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
8 # Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 #
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 # This program is free software: you can redistribute it and/or
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
11 # modify it under the terms of the GNU Lesser General Public License
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
12 # as published by the Free Software Foundation, either version 3 of
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
13 # the License, or (at your option) any later version.
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 #
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 # This program is distributed in the hope that it will be useful, but
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
18 # Lesser General Public License for more details.
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 #
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
20 # You should have received a copy of the GNU Lesser General Public
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
21 # License along with this program. If not, see
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
22 # <http://www.gnu.org/licenses/>.
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 import os
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 import sys
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 import datetime
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 if len(sys.argv) != 5:
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 sys.stderr.write('Usage: %s <Version> <ProductName> <Filename> <Description>\n\n' % sys.argv[0])
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 sys.stderr.write('Example: %s 0.9.1 Orthanc Orthanc.exe "Lightweight, RESTful DICOM server for medical imaging"\n' % sys.argv[0])
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 sys.exit(-1)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 SOURCE = os.path.join(os.path.dirname(__file__), 'WindowsResources.rc')
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 VERSION = sys.argv[1]
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 PRODUCT = sys.argv[2]
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 FILENAME = sys.argv[3]
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 DESCRIPTION = sys.argv[4]
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 if VERSION == 'mainline':
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 VERSION = '999.999.999'
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 RELEASE = 'This is a mainline build, not an official release'
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 else:
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 RELEASE = 'Release %s' % VERSION
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 v = VERSION.split('.')
1470
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1467
diff changeset
48 if len(v) != 2 and len(v) != 3:
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 sys.stderr.write('Bad version number: %s\n' % VERSION)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 sys.exit(-1)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
1470
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1467
diff changeset
52 if len(v) == 2:
1471
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1470
diff changeset
53 v.append('0')
1470
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1467
diff changeset
54
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 extension = os.path.splitext(FILENAME)[1]
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 if extension.lower() == '.dll':
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 BLOCK = '040904E4'
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 TYPE = 'VFT_DLL'
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 elif extension.lower() == '.exe':
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 #BLOCK = '040904B0' # LANG_ENGLISH/SUBLANG_ENGLISH_US,
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 BLOCK = '040904E4' # Lang=US English, CharSet=Windows Multilingual
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 TYPE = 'VFT_APP'
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 else:
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 sys.stderr.write('Unsupported extension (.EXE or .DLL only): %s\n' % extension)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 sys.exit(-1)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 with open(SOURCE, 'r') as source:
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 content = source.read()
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 content = content.replace('${VERSION_MAJOR}', v[0])
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 content = content.replace('${VERSION_MINOR}', v[1])
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 content = content.replace('${VERSION_PATCH}', v[2])
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 content = content.replace('${RELEASE}', RELEASE)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 content = content.replace('${DESCRIPTION}', DESCRIPTION)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 content = content.replace('${PRODUCT}', PRODUCT)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 content = content.replace('${FILENAME}', FILENAME)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 content = content.replace('${YEAR}', str(datetime.datetime.now().year))
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 content = content.replace('${BLOCK}', BLOCK)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 content = content.replace('${TYPE}', TYPE)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 sys.stdout.write(content)