[tuxdroid-svn] r5098 - software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadge
Status: Beta
Brought to you by:
ks156
|
From: remi <c2m...@c2...> - 2009-07-10 06:30:58
|
Author: remi
Date: 2009-07-10 08:30:37 +0200 (Fri, 10 Jul 2009)
New Revision: 5098
Modified:
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetsContainer.py
Log:
* Remove duplicated gadgets. (alway remove the older version)
Modified: software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetsContainer.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetsContainer.py 2009-07-09 10:00:43 UTC (rev 5097)
+++ software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetsContainer.py 2009-07-10 06:30:37 UTC (rev 5098)
@@ -409,6 +409,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 plugin uuid
+ gadgetUuid = gadget.getDescription().getUuid()
+ gadgetVersion = getSplitedGadgetVersion(gadget)
+ for sGadget in self.__gadgets:
+ if sGadget.getDescription().getUuid() == gadgetUuid:
+ sGadgetVersion = getSplitedGadgetVersion(sGadget)
+ # New gadget is more recent
+ if cmpVersionGt(gadgetVersion, sGadgetVersion):
+ try:
+ # Remove the old gadget
+ os.remove(sGadget.getScgFile())
+ 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)
|