# HG changeset patch # User Andrey Skvortsov # Date 1534774280 -10800 # Node ID da288f63612fe01f2fb3a0d327a7bb747794842b # Parent 9c6b0109c43fec2af91e2af3c3ed8f678bc21925 Make Beremiz_service print version information Add support for long options '--help' and '--version' as is recommended by GNU Coding Standards. diff -r 9c6b0109c43f -r da288f63612f Beremiz_service.py --- a/Beremiz_service.py Mon Aug 20 16:46:50 2018 +0300 +++ b/Beremiz_service.py Mon Aug 20 17:11:20 2018 +0300 @@ -41,7 +41,13 @@ import util.paths as paths +def version(): + from version import app_version + print("Beremiz_service: ", app_version) + + def usage(): + version() print(""" Usage of Beremiz PLC execution service :\n %s {[-n servicename] [-i IP] [-p port] [-x enabletaskbar] [-a autostart]|-h|--help} working_dir @@ -62,7 +68,7 @@ try: - opts, argv = getopt.getopt(sys.argv[1:], "i:p:n:x:t:a:w:c:e:s:h") + opts, argv = getopt.getopt(sys.argv[1:], "i:p:n:x:t:a:w:c:e:s:h", ["help", "version"]) except getopt.GetoptError, err: # print help information and exit: print(str(err)) # will print something like "option -a not recognized" @@ -85,9 +91,12 @@ extensions = [] for o, a in opts: - if o == "-h": + if o == "-h" or o == "--help": usage() sys.exit() + if o == "--version": + version() + sys.exit() elif o == "-i": if len(a.split(".")) == 4 or a == "localhost": given_ip = a @@ -136,6 +145,7 @@ __builtin__.__dict__['_'] = lambda x: x # TODO: add a cmdline parameter if Trying Preloading Xenomai makes problem TryPreloadXenomai() + version() def Bpath(*args): diff -r 9c6b0109c43f -r da288f63612f runtime_files.list --- a/runtime_files.list Mon Aug 20 16:46:50 2018 +0300 +++ b/runtime_files.list Mon Aug 20 17:11:20 2018 +0300 @@ -15,3 +15,4 @@ runtime/typemapping.py runtime/loglevels.py Beremiz_service.py +version.py \ No newline at end of file