~ubuntu-branches/ubuntu/wily/orthanc-postgresql/wily

« back to all changes in this revision

Viewing changes to Orthanc/Resources/WindowsResources.py

  • Committer: Package Import Robot
  • Author(s): Sebastien Jodogne, Sebastien Jodogne, Karsten Hilbert
  • Date: 2015-08-03 09:23:28 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20150803092328-swn3mnpj0fz34v42
Tags: 1.2-1
[ Sebastien Jodogne ]
* New upstream version

[ Karsten Hilbert ]
* Enhancements for README.Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
# Orthanc - A Lightweight, RESTful DICOM Store
 
4
# Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
 
5
# Department, University Hospital of Liege, Belgium
 
6
#
 
7
# This program is free software: you can redistribute it and/or
 
8
# modify it under the terms of the GNU General Public License as
 
9
# published by the Free Software Foundation, either version 3 of the
 
10
# License, or (at your option) any later version.
 
11
#
 
12
# In addition, as a special exception, the copyright holders of this
 
13
# program give permission to link the code of its release with the
 
14
# OpenSSL project's "OpenSSL" library (or with modified versions of it
 
15
# that use the same license as the "OpenSSL" library), and distribute
 
16
# the linked executables. You must obey the GNU General Public License
 
17
# in all respects for all of the code used other than "OpenSSL". If you
 
18
# modify file(s) with this exception, you may extend this exception to
 
19
# your version of the file(s), but you are not obligated to do so. If
 
20
# you do not wish to do so, delete this exception statement from your
 
21
# version. If you delete this exception statement from all source files
 
22
# in the program, then also delete it here.
 
23
 
24
# This program is distributed in the hope that it will be useful, but
 
25
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
26
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
27
# General Public License for more details.
 
28
#
 
29
# You should have received a copy of the GNU General Public License
 
30
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
31
 
 
32
 
 
33
import os
 
34
import sys
 
35
import datetime
 
36
 
 
37
if len(sys.argv) != 5:
 
38
    sys.stderr.write('Usage: %s <Version> <ProductName> <Filename> <Description>\n\n' % sys.argv[0])
 
39
    sys.stderr.write('Example: %s 0.9.1 Orthanc Orthanc.exe "Lightweight, RESTful DICOM server for medical imaging"\n' % sys.argv[0])
 
40
    sys.exit(-1)
 
41
 
 
42
SOURCE = os.path.join(os.path.dirname(__file__), 'WindowsResources.rc')
 
43
 
 
44
VERSION = sys.argv[1]
 
45
PRODUCT = sys.argv[2]
 
46
FILENAME = sys.argv[3]
 
47
DESCRIPTION = sys.argv[4]
 
48
 
 
49
if VERSION == 'mainline':
 
50
    VERSION = '999.999.999'
 
51
    RELEASE = 'This is a mainline build, not an official release'
 
52
else:
 
53
    RELEASE = 'Release %s' % VERSION
 
54
 
 
55
v = VERSION.split('.')
 
56
if len(v) != 2 and len(v) != 3:
 
57
    sys.stderr.write('Bad version number: %s\n' % VERSION)
 
58
    sys.exit(-1)
 
59
 
 
60
if len(v) == 2:
 
61
    v.append('0')
 
62
 
 
63
extension = os.path.splitext(FILENAME)[1]
 
64
if extension.lower() == '.dll':
 
65
    BLOCK = '040904E4'
 
66
    TYPE = 'VFT_DLL'
 
67
elif extension.lower() == '.exe':
 
68
    #BLOCK = '040904B0'   # LANG_ENGLISH/SUBLANG_ENGLISH_US,
 
69
    BLOCK = '040904E4'   # Lang=US English, CharSet=Windows Multilingual
 
70
    TYPE = 'VFT_APP'
 
71
else:
 
72
    sys.stderr.write('Unsupported extension (.EXE or .DLL only): %s\n' % extension)
 
73
    sys.exit(-1)
 
74
 
 
75
 
 
76
with open(SOURCE, 'r') as source:
 
77
    content = source.read()
 
78
    content = content.replace('${VERSION_MAJOR}', v[0])
 
79
    content = content.replace('${VERSION_MINOR}', v[1])
 
80
    content = content.replace('${VERSION_PATCH}', v[2])
 
81
    content = content.replace('${RELEASE}', RELEASE)
 
82
    content = content.replace('${DESCRIPTION}', DESCRIPTION)
 
83
    content = content.replace('${PRODUCT}', PRODUCT)   
 
84
    content = content.replace('${FILENAME}', FILENAME)   
 
85
    content = content.replace('${YEAR}', str(datetime.datetime.now().year))
 
86
    content = content.replace('${BLOCK}', BLOCK)
 
87
    content = content.replace('${TYPE}', TYPE)
 
88
 
 
89
    sys.stdout.write(content)