version.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Thu, 09 Mar 2017 17:29:17 +0300
changeset 1658 ba6a6d6e989c
parent 1569 06632b380d2a
child 1680 6db967480b7d
permissions -rw-r--r--
fix twice shown error message box, when wrong non-valid IEC identifier entered

It happens when non-valid name for variable name or name of field in
structure entered. This issue is described in details here:
http://trac.wxwidgets.org/ticket/16333
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
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    27
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    28
def GetAppRevision():
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    29
    rev = None
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    30
    app_dir=os.path.dirname(os.path.realpath(__file__))    
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    31
    try:
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    32
        pipe = subprocess.Popen(
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    33
            ["hg", "id", "-i"],
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    34
            stdout = subprocess.PIPE,
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    35
            cwd = app_dir
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    36
        )
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    37
        rev = pipe.communicate()[0]
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    38
        if pipe.returncode != 0:
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    39
            rev = None
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    40
    except:
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    41
        pass
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    42
    
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    43
    # if this is not mercurial repository
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    44
    # try to read revision from file
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    45
    if rev is None:
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    46
        try:
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    47
            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
    48
            rev = f.readline()
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    49
        except:
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    50
            pass
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    51
    return rev
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    52
1565
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    53
def GetAboutDialogInfo():
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    54
    import wx
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    55
    info = wx.AboutDialogInfo()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    56
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    57
    info.Name = "Beremiz"
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    58
    info.Version = app_version
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    59
    
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    60
    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
    61
    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
    62
    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
    63
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    64
    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
    65
    
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    66
    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
    67
                             "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
    68
                             "and flexible PLC runtime.")
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    69
    
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    70
    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
    71
		       "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
    72
		       "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
    73
		       "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
    74
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
    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
    77
    ' 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
    78
    ' 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
    79
    ' 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
    80
    '\n'
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    81
    ' 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
    82
    ' 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
    83
    ' 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
    84
    ' 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
    85
    '\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
    '')
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
    # read license file
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    91
    path=os.path.join(os.path.dirname(os.path.abspath(__file__)))
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    92
    license_path = os.path.join(path, u"COPYING")
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    93
    license=''
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    94
    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
    95
        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
    96
            info.License += f.read()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
    97
1569
06632b380d2a remove old debug code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1565
diff changeset
    98
    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
    99
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
   100
    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
   101
	                "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
   102
	                "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
   103
	                "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
   104
    return info
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1561
diff changeset
   105
1561
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   106
app_version =  "1.2"
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   107
rev = GetAppRevision()
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   108
if rev is not None:
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   109
    app_version = app_version + "-" + rev.rstrip()
f53ece47e18d add version.py needed for previous commit '4ce8492'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   110
    
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