thomasvs - in flumotion/trunk: . flumotion/common
flumotion/configure flumotion/manager flumotion/test
flumotion-commit at lists.fluendo.com
flumotion-commit at lists.fluendo.com
Tue Jan 23 07:43:55 CET 2007
Author: thomasvs
Date: Tue Jan 23 07:43:41 2007
New Revision: 4424
Modified:
flumotion/trunk/ChangeLog
flumotion/trunk/flumotion/common/common.py
flumotion/trunk/flumotion/common/config.py
flumotion/trunk/flumotion/configure/configure.py
flumotion/trunk/flumotion/manager/manager.py
flumotion/trunk/flumotion/test/test_common.py
Log:
* flumotion/configure/configure.py:
Rename parseVersion and make it private to make sure no one uses
it outside of this module.
Don't call a tuple a Num.
* flumotion/common/config.py:
replace with versionTuple
* flumotion/common/common.py:
add versionTupleToString
* flumotion/test/test_common.py:
and a test for it
* flumotion/manager/manager.py:
Don't ever ever show a user a tuple! Also, provide a hint as to
what to do to fix the problem.
Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog (original)
+++ flumotion/trunk/ChangeLog Tue Jan 23 07:43:41 2007
@@ -1,3 +1,19 @@
+2007-01-23 Thomas Vander Stichele <thomas at apestaart dot org>
+
+ * flumotion/configure/configure.py:
+ Rename parseVersion and make it private to make sure no one uses
+ it outside of this module.
+ Don't call a tuple a Num.
+ * flumotion/common/config.py:
+ replace with versionTuple
+ * flumotion/common/common.py:
+ add versionTupleToString
+ * flumotion/test/test_common.py:
+ and a test for it
+ * flumotion/manager/manager.py:
+ Don't ever ever show a user a tuple! Also, provide a hint as to
+ what to do to fix the problem.
+
2007-01-22 Andy Wingo <wingo at pobox.com>
* flumotion/common/log.py (reopenOutputFiles): Open both files in
Modified: flumotion/trunk/flumotion/common/common.py
==============================================================================
--- flumotion/trunk/flumotion/common/common.py (original)
+++ flumotion/trunk/flumotion/common/common.py Tue Jan 23 07:43:41 2007
@@ -627,6 +627,16 @@
return 0
+def versionTupleToString(versionTuple):
+ """
+ Converts a version tuple to a string. If the tuple has a zero nano number,
+ it is dropped from the string.
+ """
+ if len(versionTuple) == 4 and versionTuple[3] == 0:
+ versionTuple = versionTuple[:3]
+
+ return ".".join([str(i) for i in versionTuple])
+
def _uniq(l, key=lambda x: x):
"""
Filters out duplicate entries in a list.
Modified: flumotion/trunk/flumotion/common/config.py
==============================================================================
--- flumotion/trunk/flumotion/common/config.py (original)
+++ flumotion/trunk/flumotion/common/config.py Tue Jan 23 07:43:41 2007
@@ -421,7 +421,7 @@
# If we don't have a version at all, use the current version
if not version:
- version = configure.versionNum
+ version = configure.versionTuple
type = str(node.getAttribute('type'))
name = str(node.getAttribute('name'))
Modified: flumotion/trunk/flumotion/configure/configure.py
==============================================================================
--- flumotion/trunk/flumotion/configure/configure.py (original)
+++ flumotion/trunk/flumotion/configure/configure.py Tue Jan 23 07:43:41 2007
@@ -63,11 +63,10 @@
@var defaultGstPortRange: the default range of internal GStreamer ports
@type defaultGstPortRange: list of ints
- at var version: Flumotion version number
- at type version: string
-
- at var versionNum: Flumotion version number
- at type versionNum: 4-tuple of integers
+ at var version: Flumotion version number
+ at type version: string
+ at var versionTuple: Flumotion version number
+ at type versionTuple: 4-tuple of integers
'''
# Note: This module is loaded very early on, so
@@ -102,12 +101,12 @@
# default value for component heartbeat interval, in seconds
config_dict['heartbeatInterval'] = 5
-def parseVersion(num):
- version = tuple(map(int, num.split('.')))
- if len (version) < 4:
- version = version + (0,)
- return version
-config_dict['versionNum'] = parseVersion(config_dict['version'])
+def _versionStringToTuple(versionString):
+ t = tuple(map(int, versionString.split('.')))
+ if len (t) < 4:
+ t = t + (0,)
+ return t
+config_dict['versionTuple'] = _versionStringToTuple(config_dict['version'])
for key, value in config_dict.items():
dictionary = locals()
Modified: flumotion/trunk/flumotion/manager/manager.py
==============================================================================
--- flumotion/trunk/flumotion/manager/manager.py (original)
+++ flumotion/trunk/flumotion/manager/manager.py Tue Jan 23 07:43:41 2007
@@ -412,10 +412,12 @@
avatarId = conf.getConfigDict()['avatarId']
- if conf.getConfigDict()['version'] != configure.versionNum:
+ if conf.getConfigDict()['version'] != configure.versionTuple:
m = messages.Warning(T_(N_("This component is configured for "
- "Flumotion version %r, but you are running version %r.\n"),
- conf.getConfigDict()['version'], configure.versionNum))
+ "Flumotion version %s, but you are running version %s.\n"
+ "Please update the configuration of the component.\n"),
+ common.versionTupleToString(conf.getConfigDict()['version']),
+ configure.version))
state.append('messages', m)
# add to mapper
Modified: flumotion/trunk/flumotion/test/test_common.py
==============================================================================
--- flumotion/trunk/flumotion/test/test_common.py (original)
+++ flumotion/trunk/flumotion/test/test_common.py Tue Jan 23 07:43:41 2007
@@ -137,6 +137,13 @@
def testVersion(self):
self.failUnless(common.version('abinary'))
+ def test_versionTupleToString(self):
+ self.assertEquals(common.versionTupleToString((1, )), "1")
+ self.assertEquals(common.versionTupleToString((1, 2, )), "1.2")
+ self.assertEquals(common.versionTupleToString((1, 2, 3, )), "1.2.3")
+ self.assertEquals(common.versionTupleToString((1, 2, 3, 0,)), "1.2.3")
+ self.assertEquals(common.versionTupleToString((1, 2, 3, 1,)), "1.2.3.1")
+
class TestArgRepr(unittest.TestCase):
def testEmpty(self):
self.assertEqual(common.argRepr(), '')
More information about the flumotion-commit
mailing list