Author: remi
Date: 2009-04-13 13:40:11 +0200 (Mon, 13 Apr 2009)
New Revision: 4496
Modified:
softwares_suite_v3/kysoh/tuxware/server/trunk/util/applicationserver/gadget/GadgetsContainer.py
Log:
* in the case of two gadgets have the same uuid, the older is removed.
Modified:
softwares_suite_v3/kysoh/tuxware/server/trunk/util/applicationserver/gadget/GadgetsContainer.py
===================================================================
---
softwares_suite_v3/kysoh/tuxware/server/trunk/util/applicationserver/gadget/GadgetsContainer.py
2009-04-12 20:14:25 UTC (rev 4495)
+++
softwares_suite_v3/kysoh/tuxware/server/trunk/util/applicationserver/gadget/GadgetsContainer.py
2009-04-13 11:40:11 UTC (rev 4496)
@@ -334,11 +334,44 @@
else:
if os.name == "nt":
return None, "Platform"
+ def getSplitedGadgetVersion(theGadget):
+ vList = theGadget.getDescription().getVersion().split(".")
+ for i, v in enumerate(vList):
+ try:
+ vList[i] = int(v)
+ except:
+ vList[i] = 0
+ if len(vList) < 3:
+ if len(vList) < 2:
+ if len(vList) < 1:
+ vList.append(0)
+ vList.append(0)
+ vList.append(0)
+ return vList
+ def cmpVersionGt(v1, v2):
+ for i in range(3):
+ if v1[i] > v2[i]:
+ return True
+ elif v1[i] < v2[i]:
+ return False
+ return False
# Check for duplicated gadget uuid
gadgetUuid = gadget.getDescription().getUuid()
+ gadgetVersion = getSplitedGadgetVersion(gadget)
for sGadget in self.__gadgets:
if sGadget.getDescription().getUuid() == gadgetUuid:
- return None, "Duplicated gadget UUID (%s)" %
sGadget.getDescription().getName()
+ sGadgetVersion = getSplitedGadgetVersion(sGadget)
+ # New gadget is more recent
+ if cmpVersionGt(gadgetVersion, sGadgetVersion):
+ try:
+ # Remove the old gadget
+ os.remove(sGadget.getTgfFile())
+ except:
+ pass
+ # New gadget is older
+ else:
+ # Can't accept this gadget ...
+ return None, "Duplicated gadget UUID (%s)" %
sGadget.getDescription().getName()
# Add this gadget to the container
self.__mutex.acquire()
self.__gadgets.append(gadget)
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn