summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Kreen2009-10-14 15:03:54 +0000
committerMarko Kreen2009-10-14 15:03:54 +0000
commit15042c82b01ac74385068c70c7ccf84e1407186d (patch)
tree142ad82d6119bc044611e45d3c2b22b9abee892d
parent8d36578a23d6ea1a17199765b412d963da5fd34f (diff)
python/: Add --version switch to all scripts.
Based on patch by Hannu Krosing
-rw-r--r--Makefile2
-rw-r--r--config.mak.in5
-rw-r--r--python/skytools/__init__.py3
-rw-r--r--python/skytools/installer_config.py.in3
-rw-r--r--python/skytools/scripting.py8
5 files changed, 20 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 976597d3..8a5df5c8 100644
--- a/Makefile
+++ b/Makefile
@@ -59,7 +59,7 @@ python-install: config.mak sub-all
python-install python-all: python/skytools/installer_config.py
python/skytools/installer_config.py: python/skytools/installer_config.py.in config.mak
- sed -e 's!@SQLDIR@!$(SQLDIR)!g' $< > $@
+ sed -e 's!@SQLDIR@!$(SQLDIR)!g' -e 's!@PACKAGE_VERSION@!$(PACKAGE_VERSION)!g' $< > $@
realclean: distclean
$(MAKE) -C doc $@
diff --git a/config.mak.in b/config.mak.in
index 894c8c98..d105f635 100644
--- a/config.mak.in
+++ b/config.mak.in
@@ -36,3 +36,8 @@ INSTALL = @INSTALL@
BININSTALL = @BININSTALL@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_STRING = @PACKAGE_STRING@
+
diff --git a/python/skytools/__init__.py b/python/skytools/__init__.py
index b958b483..03b18a04 100644
--- a/python/skytools/__init__.py
+++ b/python/skytools/__init__.py
@@ -35,3 +35,6 @@ __all__ = (skytools.psycopgwrapper.__all__
+ skytools.adminscript.__all__
+ skytools.parsing.__all__)
+import skytools.installer_config
+__version__ = skytools.installer_config.package_version
+
diff --git a/python/skytools/installer_config.py.in b/python/skytools/installer_config.py.in
index a01621f7..2c684c17 100644
--- a/python/skytools/installer_config.py.in
+++ b/python/skytools/installer_config.py.in
@@ -6,3 +6,6 @@ __all__ = ['sql_locations']
sql_locations = [
"@SQLDIR@",
]
+
+package_version = "@PACKAGE_VERSION@"
+
diff --git a/python/skytools/scripting.py b/python/skytools/scripting.py
index 0d4b0fab..57401773 100644
--- a/python/skytools/scripting.py
+++ b/python/skytools/scripting.py
@@ -325,6 +325,9 @@ class DBScript(object):
self.options, self.args = parser.parse_args(args)
# check args
+ if self.options.version:
+ self.print_version()
+ sys.exit(0)
if self.options.daemon:
self.go_daemon = 1
if self.options.quiet:
@@ -353,6 +356,9 @@ class DBScript(object):
elif self.options.cmd == "reload":
self.send_signal(signal.SIGHUP)
+ def print_version(self):
+ print '%s, Skytools version %s' % (self.service_name, skytools.__version__)
+
def print_ini(self):
"""Prints out ini file from doc string of the script of default for dbscript
@@ -431,6 +437,8 @@ class DBScript(object):
help = "log verbosely")
p.add_option("-d", "--daemon", action="store_true",
help = "go background")
+ p.add_option("-V", "--version", action="store_true",
+ help = "print version info and exit")
p.add_option("", "--ini", action="store_true",
help = "display sample ini file")