version.py
branchwxPython4
changeset 3587 295f21f9c581
parent 3570 eb915a9fdcb0
child 3750 f62625418bff
equal deleted inserted replaced
3586:cbc6a6ccd52e 3587:295f21f9c581
    23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    24 
    24 
    25 
    25 
    26 from __future__ import absolute_import
    26 from __future__ import absolute_import
    27 from __future__ import unicode_literals
    27 from __future__ import unicode_literals
       
    28 from __future__ import print_function
    28 
    29 
    29 import subprocess
       
    30 import os
    30 import os
    31 
       
    32 import util.paths as paths
       
    33 
       
    34 
    31 
    35 def GetCommunityHelpMsg():
    32 def GetCommunityHelpMsg():
    36     return _(
    33     return _(
    37         "The best place to ask questions about Beremiz/PLCOpenEditor\n"
    34         "The best place to ask questions about Beremiz/PLCOpenEditor\n"
    38         "is project's mailing list: beremiz-devel@lists.sourceforge.net\n"
    35         "is project's mailing list: beremiz-devel@lists.sourceforge.net\n"
    41         "For posting it is required to be subscribed to the mailing list.\n"
    38         "For posting it is required to be subscribed to the mailing list.\n"
    42         "\n"
    39         "\n"
    43         "You can subscribe to the list here:\n"
    40         "You can subscribe to the list here:\n"
    44         "https://lists.sourceforge.net/lists/listinfo/beremiz-devel"
    41         "https://lists.sourceforge.net/lists/listinfo/beremiz-devel"
    45     )
    42     )
    46 
       
    47 
       
    48 def GetAppRevision():
       
    49     rev = None
       
    50     app_dir = paths.AbsDir(__file__)
       
    51     try:
       
    52         pipe = subprocess.Popen(
       
    53             ["hg", "id", "-i"],
       
    54             stdout=subprocess.PIPE,
       
    55             cwd=app_dir
       
    56         )
       
    57         rev = pipe.communicate()[0]
       
    58         if pipe.returncode != 0:
       
    59             rev = None
       
    60     except Exception:
       
    61         pass
       
    62 
       
    63     # if this is not mercurial repository
       
    64     # try to read revision from file
       
    65     if rev is None:
       
    66         try:
       
    67             f = open(os.path.join(app_dir, "revision"))
       
    68             rev = f.readline()
       
    69         except Exception:
       
    70             pass
       
    71     return rev
       
    72 
    43 
    73 
    44 
    74 def GetAboutDialogInfo(info):
    45 def GetAboutDialogInfo(info):
    75 
    46 
    76     info.Version = app_version
    47     info.Version = app_version
   105         '\n'
    76         '\n'
   106         ''
    77         ''
   107     )
    78     )
   108 
    79 
   109     # read license file
    80     # read license file
   110     path = paths.AbsDir(__file__)
    81     license_path = os.path.join(
   111     license_path = os.path.join(path, "COPYING")
    82         os.path.dirname(os.path.realpath(__file__)), "COPYING")
   112     if os.path.exists(license_path):
    83     if os.path.exists(license_path):
   113         with open(license_path) as f:
    84         with open(license_path) as f:
   114             info.License += f.read()
    85             info.License += f.read()
   115 
    86 
   116     info.Translators = (
    87     info.Translators = (
   209 
   180 
   210     )
   181     )
   211     return info
   182     return info
   212 
   183 
   213 
   184 
   214 app_version = "1.2"
   185 app_version = "1.3-beta2"
   215 rev = GetAppRevision()
   186 
   216 if rev is not None:
   187 if __name__ == "__main__":
   217     app_version = app_version + "-" + rev.rstrip()
   188     print(app_version)