version.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Thu, 01 Jun 2017 14:37:14 +0300
changeset 1686 85fdcc04da25
parent 1680 6db967480b7d
child 1692 9cb4d1392baf
permissions -rw-r--r--
disallow setting IEC location addresses for TIME, DATE, DT and TOD variables

Size of these types is not defined and depends on the implementation
(IEC 61131-3 2.3.1).
1565
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
     1
#!/usr/bin/env python
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
     2
# -*- coding: utf-8 -*-
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
     3
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
     4
# This file is part of Beremiz, a Integrated Development Environment for
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
     5
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
     6
#
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
     7
# Copyright (C) 2016: Andrey Skvortsov
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
     8
#
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
     9
# See COPYING file for copyrights details.
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    10
#
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    11
# This program is free software; you can redistribute it and/or
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    12
# modify it under the terms of the GNU General Public License
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    13
# as published by the Free Software Foundation; either version 2
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    14
# of the License, or (at your option) any later version.
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    15
#
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    16
# This program is distributed in the hope that it will be useful,
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    19
# GNU General Public License for more details.
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    20
#
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    21
# You should have received a copy of the GNU General Public License
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    22
# along with this program; if not, write to the Free Software
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    23
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    24
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    25
1561
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    26
import subprocess, os
1680
6db967480b7d make run Beremiz and PLCOpen Editor, if full path contain non-lating
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1569
diff changeset
    27
import util.paths as paths
1561
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    28
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    29
def GetAppRevision():
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    30
    rev = None
1680
6db967480b7d make run Beremiz and PLCOpen Editor, if full path contain non-lating
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1569
diff changeset
    31
    app_dir=paths.AbsDir(__file__)
1561
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    32
    try:
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    33
        pipe = subprocess.Popen(
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    34
            ["hg", "id", "-i"],
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    35
            stdout = subprocess.PIPE,
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    36
            cwd = app_dir
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    37
        )
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    38
        rev = pipe.communicate()[0]
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    39
        if pipe.returncode != 0:
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    40
            rev = None
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    41
    except:
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    42
        pass
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    43
    
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    44
    # if this is not mercurial repository
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    45
    # try to read revision from file
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    46
    if rev is None:
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    47
        try:
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    48
            f = open(os.path.join(app_dir,"revision"))
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    49
            rev = f.readline()
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    50
        except:
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    51
            pass
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    52
    return rev
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    53
1565
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    54
def GetAboutDialogInfo():
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    55
    import wx
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    56
    info = wx.AboutDialogInfo()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    57
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    58
    info.Name = "Beremiz"
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    59
    info.Version = app_version
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    60
    
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    61
    info.Copyright  = "(C) 2016 Andrey Skvortsov\n"
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    62
    info.Copyright += "(C) 2008-2015 Eduard Tisserant\n"
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    63
    info.Copyright += "(C) 2008-2015 Laurent Bessard"
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    64
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    65
    info.WebSite = ("http://beremiz.org", "beremiz.org")
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    66
    
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    67
    info.Description = _("Open Source framework for automation, "
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    68
                             "implemented IEC 61131 IDE with constantly growing set of extensions "
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    69
                             "and flexible PLC runtime.")
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    70
    
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    71
    info.Developers = ("Andrey Skvortsov <andrej.skvortzov@gmail.com>",
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    72
		       "Sergey Surkov <surkov.sv@summatechnology.ru>",
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    73
		       "Edouard Tisserant <edouard.tisserant@gmail.com>",
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    74
		       "Laurent Bessard <laurent.bessard@gmail.com>")
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    75
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    76
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    77
    info.License = ('\n This program is free software; you can redistribute it and/or\n'
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    78
    ' modify it under the terms of the GNU General Public License\n'
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    79
    ' as published by the Free Software Foundation; either version 2\n'
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    80
    ' of the License, or (at your option) any later version.\n'
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    81
    '\n'
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    82
    ' This program is distributed in the hope that it will be useful,\n'
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    83
    ' but WITHOUT ANY WARRANTY; without even the implied warranty of\n'
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    84
    ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n'
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    85
    ' GNU General Public License below for more details.\n'
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    86
    '\n'
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    87
    '\n'
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    88
    '\n'
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    89
    '')
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    90
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    91
    # read license file
1680
6db967480b7d make run Beremiz and PLCOpen Editor, if full path contain non-lating
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1569
diff changeset
    92
    path=paths.AbsDir(__file__)
6db967480b7d make run Beremiz and PLCOpen Editor, if full path contain non-lating
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1569
diff changeset
    93
    license_path = os.path.join(path, "COPYING")
1565
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    94
    license=''
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    95
    if os.path.exists(license_path):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    96
        with open(license_path) as f:
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    97
            info.License += f.read()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    98
1569
06632b380d2a remove old debug code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1565
diff changeset
    99
    info.Icon = wx.Icon(os.path.join(path, "images", "about_brz_logo.png"), wx.BITMAP_TYPE_PNG)
1565
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
   100
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
   101
    info.Translators = ("Russian\t- Andrey Skvortsov <andrej.skvortzov@gmail.com>",
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
   102
	                "Korean\t- Reinhard Lee <lij3105@gmail.com>",
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
   103
	                "German\t- Mark Muzenhardt <mark.muzenhardt@gmail.com>",
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
   104
	                "French\t- Laurent Bessard <laurent.bessard@gmail.com>")
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
   105
    return info
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
   106
1561
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   107
app_version =  "1.2"
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   108
rev = GetAppRevision()
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   109
if rev is not None:
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   110
    app_version = app_version + "-" + rev.rstrip()
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   111
    
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   112
        
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   113