Move version.py to the common ipa directory instead of being server-based so it can be used by the client tool.

Fix the client tool imports to fail more gracefully.
This commit is contained in:
Rob Crittenden
2008-05-30 14:21:45 -04:00
parent 5a56b7c885
commit c58b7a3d7c
7 changed files with 37 additions and 26 deletions

View File

@@ -104,9 +104,9 @@ version-update:
> ipa-server/selinux/ipa-server-selinux.spec > ipa-server/selinux/ipa-server-selinux.spec
sed s/VERSION/$(IPA_VERSION)/ ipa-python/setup.py.in \ sed s/VERSION/$(IPA_VERSION)/ ipa-python/setup.py.in \
> ipa-python/setup.py > ipa-python/setup.py
sed s/__VERSION__/$(IPA_VERSION)/ ipa-server/ipaserver/version.py.in \ sed s/__VERSION__/$(IPA_VERSION)/ ipa-python/version.py.in \
> ipa-server/ipaserver/version.py > ipa-python/version.py
perl -pi -e "s:__NUM_VERSION__:$(IPA_VERSION_MAJOR)$(IPA_VERSION_MINOR)$(IPA_VERSION_RELEASE):" ipa-server/ipaserver/version.py perl -pi -e "s:__NUM_VERSION__:$(IPA_VERSION_MAJOR)$(IPA_VERSION_MINOR)$(IPA_VERSION_RELEASE):" ipa-python/version.py
archive: archive:
-mkdir -p dist -mkdir -p dist

View File

@@ -19,10 +19,32 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
VERSION = "%prog .1" try:
import sys
import os
import krbV
import socket
import logging
from optparse import OptionParser
import ipaclient.ipadiscovery
import ipaclient.ipachangeconf
import ipaclient.ntpconf
from ipa.ipautil import run
from ipa import sysrestore
from ipa import version
except ImportError:
print >> sys.stderr, """\
There was a problem importing one of the required Python modules. The
error was:
%s
""" % sys.exc_value
sys.exit(1)
def parse_options(): def parse_options():
parser = OptionParser(version=VERSION) parser = OptionParser(version=version.VERSION)
parser.add_option("--domain", dest="domain", help="domain name") parser.add_option("--domain", dest="domain", help="domain name")
parser.add_option("--server", dest="server", help="IPA server") parser.add_option("--server", dest="server", help="IPA server")
parser.add_option("--realm", dest="realm_name", help="realm name") parser.add_option("--realm", dest="realm_name", help="realm name")
@@ -371,19 +393,9 @@ def main():
return 0 return 0
try: try:
import sys if __name__ == "__main__":
sys.exit(main())
import os except SystemExit, e:
import krbV sys.exit(e)
import socket
import logging
from optparse import OptionParser
import ipaclient.ipadiscovery
import ipaclient.ipachangeconf
import ipaclient.ntpconf
from ipa.ipautil import run
from ipa import sysrestore
sys.exit(main())
except KeyboardInterrupt: except KeyboardInterrupt:
sys.exit(1) sys.exit(1)

View File

@@ -13,7 +13,7 @@ install:
fi fi
clean: clean:
rm -f *~ *.pyc setup.py ipa-python.spec rm -f *~ *.pyc setup.py ipa-python.spec version.py
distclean: clean distclean: clean

View File

@@ -22,4 +22,4 @@ VERSION="__VERSION__"
# Just the numeric portion of the version so one can do direct numeric # Just the numeric portion of the version so one can do direct numeric
# comparisons to see if the API is compatible. # comparisons to see if the API is compatible.
NUM_VERSION="__NUM_VERSION__" NUM_VERSION=__NUM_VERSION__

View File

@@ -44,7 +44,7 @@ import ipaserver.httpinstance
import ipaserver.ntpinstance import ipaserver.ntpinstance
from ipaserver import service from ipaserver import service
from ipaserver import version from ipa import version
from ipaserver.installutils import * from ipaserver.installutils import *
from ipa import sysrestore from ipa import sysrestore

View File

@@ -13,7 +13,6 @@ app_PYTHON = \
installutils.py \ installutils.py \
replication.py \ replication.py \
certs.py \ certs.py \
version.py \
$(NULL) $(NULL)
EXTRA_DIST = \ EXTRA_DIST = \

View File

@@ -26,7 +26,7 @@ import ipaserver.dsinstance
import ipaserver.ipaldap import ipaserver.ipaldap
import copy import copy
from ipaserver import attrs from ipaserver import attrs
from ipaserver import version from ipa import version
from ipa import ipaerror from ipa import ipaerror
from ipa import ipautil from ipa import ipautil
from urllib import quote,unquote from urllib import quote,unquote
@@ -386,8 +386,8 @@ class IPAServer:
# Higher-level API # Higher-level API
def version(self, opts=None): def version(self, opts=None):
"""The version of IPA""" """The version of IPA"""
logging.debug("IPA: version %d" % ipaserver.version.NUM_VERSION) logging.debug("IPA: version %d" % version.NUM_VERSION)
return ipaserver.version.NUM_VERSION return version.NUM_VERSION
def get_aci_entry(self, sattrs, opts=None): def get_aci_entry(self, sattrs, opts=None):
"""Returns the entry containing access control ACIs.""" """Returns the entry containing access control ACIs."""