fixed code

This commit is contained in:
Andreas Preikschat 2013-06-06 08:40:10 +02:00
parent 1e8ad4ab7e
commit 43326c5781
3 changed files with 58 additions and 32 deletions

View File

@ -1 +1 @@
2.0.1-bzr2233 2.1.0-bzr2234

View File

@ -101,25 +101,38 @@ def get_application_version():
if APPLICATION_VERSION: if APPLICATION_VERSION:
return APPLICATION_VERSION return APPLICATION_VERSION
if u'--dev-version' in sys.argv or u'-d' in sys.argv: if u'--dev-version' in sys.argv or u'-d' in sys.argv:
# If we're running the dev version, let's use bzr to get the version. # NOTE: The following code is a duplicate of the code in setup.py. Any fix applied here should also be applied
bzr = Popen((u'bzr', u'tags', u'--sort', u'time'), stdout=PIPE) # there.
# Get the revision of this tree.
bzr = Popen((u'bzr', u'revno'), stdout=PIPE)
tree_revision, error = bzr.communicate()
code = bzr.wait()
if code != 0:
raise Exception(u'Error running bzr log')
# Get all tags.
bzr = Popen((u'bzr', u'tags'), stdout=PIPE)
output, error = bzr.communicate() output, error = bzr.communicate()
code = bzr.wait() code = bzr.wait()
if code != 0: if code != 0:
raise Exception(u'Error running bzr tags') raise Exception(u'Error running bzr tags')
lines = output.splitlines() tags = output.splitlines()
if not lines: if not tags:
tag = u'0.0.0' tag_version = u'0.0.0'
revision = u'0' tag_revision = u'0'
else: else:
tag, revision = lines[-1].split() # Remove any tag that has "?" as revision number. A "?" as revision number indicates, that this tag is from
bzr = Popen((u'bzr', u'log', u'--line', u'-r', u'-1'), stdout=PIPE) # another series.
output, error = bzr.communicate() tags = [tag for tag in tags if tag.split()[-1].strip() != u'?']
code = bzr.wait() # Get the last tag and split it in a revision and tag name.
if code != 0: tag_version, tag_revision = tags[-1].split()
raise Exception(u'Error running bzr log') # If they are equal, then this tree is tarball with the source for the release. We do not want the revision
latest = output.split(u':')[0] # number in the full version.
full_version = latest == revision and tag or u'%s-bzr%s' % (tag, latest) if tree_revision == tag_revision:
full_version = tag_version
else:
full_version = u'%s-bzr%s' % (tag_version, tree_revision)
else: else:
# We're not running the development version, let's use the file. # We're not running the development version, let's use the file.
filepath = AppLocation.get_directory(AppLocation.VersionDir) filepath = AppLocation.get_directory(AppLocation.VersionDir)

View File

@ -82,37 +82,50 @@ def natural_sort(seq, compare=natural_compare):
temp.sort(compare) temp.sort(compare)
return temp return temp
# NOTE: The following code is a duplicate of the code in openlp/core/utils/__init__.py. Any fix applied here should also
# be applied there.
try: try:
bzr = Popen((u'bzr', u'tags', u'--sort', u'time'), stdout=PIPE) # Get the revision of this tree.
bzr = Popen((u'bzr', u'revno'), stdout=PIPE)
tree_revision, error = bzr.communicate()
code = bzr.wait()
if code != 0:
raise Exception(u'Error running bzr log')
# Get all tags.
bzr = Popen((u'bzr', u'tags'), stdout=PIPE)
output, error = bzr.communicate() output, error = bzr.communicate()
code = bzr.wait() code = bzr.wait()
if code != 0: if code != 0:
raise Exception(u'Error running bzr tags') raise Exception(u'Error running bzr tags')
lines = output.splitlines() tags = output.splitlines()
if not lines: if not tags:
tag = u'0.0.0' tag_version = u'0.0.0'
revision = u'0' tag_revision = u'0'
else: else:
tag, revision = lines[-1].split() # Remove any tag that has "?" as revision number. A "?" as revision number indicates, that this tag is from
bzr = Popen((u'bzr', u'log', u'--line', u'-r', u'-1'), stdout=PIPE) # another series.
output, error = bzr.communicate() tags = [tag for tag in tags if tag.split()[-1].strip() != u'?']
code = bzr.wait() # Get the last tag and split it in a revision and tag name.
if code != 0: tag_version, tag_revision = tags[-1].split()
raise Exception(u'Error running bzr log') # If they are equal, then this tree is tarball with the source for the release. We do not want the revision number
latest = output.split(u':')[0] # in the version string.
version = latest == revision and tag or u'%s-bzr%s' % (tag, latest) if tree_revision == tag_revision:
version_string = tag_version
else:
version_string = u'%s-bzr%s' % (tag_version, tree_revision)
ver_file = open(VERSION_FILE, u'w') ver_file = open(VERSION_FILE, u'w')
ver_file.write(version) ver_file.write(version_string)
ver_file.close()
except: except:
ver_file = open(VERSION_FILE, u'r') ver_file = open(VERSION_FILE, u'r')
version = ver_file.read().strip() version_string = ver_file.read().strip()
finally:
ver_file.close() ver_file.close()
setup( setup(
name='OpenLP', name='OpenLP',
version=version, version=version_string,
description="Open source Church presentation and lyrics projection application.", description="Open source Church presentation and lyrics projection application.",
long_description="""\ long_description="""\
OpenLP (previously openlp.org) is free church presentation software, or lyrics projection software, used to display slides of songs, Bible verses, videos, images, and even presentations (if PowerPoint is installed) for church worship using a computer and a data projector.""", OpenLP (previously openlp.org) is free church presentation software, or lyrics projection software, used to display slides of songs, Bible verses, videos, images, and even presentations (if PowerPoint is installed) for church worship using a computer and a data projector.""",