[tuxdroid-svn] r4944 - in software_suite_v3/smart-core/smart-server/trunk/util/applicationserver:
Status: Beta
Brought to you by:
ks156
|
From: remi <c2m...@c2...> - 2009-06-30 08:48:48
|
Author: remi
Date: 2009-06-30 10:47:56 +0200 (Tue, 30 Jun 2009)
New Revision: 4944
Modified:
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetGenerator.py
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/Ugc.py
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/UgcContainer.py
Log:
* creation time of an ugc in now based on "time.time()" (millisec). This commit fixes the random order of the configurations when you update an ugc (user gadget) configuration.
Modified: software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetGenerator.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetGenerator.py 2009-06-30 08:13:14 UTC (rev 4943)
+++ software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetGenerator.py 2009-06-30 08:47:56 UTC (rev 4944)
@@ -547,6 +547,8 @@
else:
ugcTtsName = ugcName
ugcDataDict = {}
+ # Creation time
+ ugcDataDict['creationTime'] = time.time()
# Parent Gadget
ugcDataDict['parentGadget'] = {
'uuid' : gadget.getDescription().getUuid(),
@@ -604,6 +606,8 @@
# Description
ugcDataDict['description']['uuid'] = ugcUuid
ugcDataDict['description']['name'] = ugcName
+ # Creation time
+ ugcDataDict['creationTime'] = time.time()
# Serve the ugc content
resourcesManager.addContentToServe(str(ugcDataDict), '/tmp/%s.ugc' % ugcUuid)
return '/tmp/%s.ugc' % ugcUuid, ugcUuid
@@ -636,6 +640,8 @@
'name' : parentGadget.getDescription().getName(),
'version' : parentGadget.getDescription().getVersion(),
}
+ # Creation time
+ ugcDataDict['creationTime'] = ugc.getUgcFileCreationTime()
# Description
ugcDataDict['description'] = {
'uuid' : ugcUuid,
Modified: software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/Ugc.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/Ugc.py 2009-06-30 08:13:14 UTC (rev 4943)
+++ software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/Ugc.py 2009-06-30 08:47:56 UTC (rev 4944)
@@ -35,7 +35,7 @@
# Save the parent gadget object
self.__parentGadget = parentGadget
# Creation time of the ugc file
- self.__ugcFileCreationTime = None
+ self.__ugcFileCreationTime = dictionary['creationTime']
# Create descriptor
self.__description = UgcDescription(self, dictionary['description'])
# Create ugc parameters
@@ -242,7 +242,7 @@
# --------------------------------------------------------------------------
def setUgcFileCreationTime(self, value):
"""Set the creation time of the ugc file.
- @param value: An integer.
+ @param value: A float.
"""
self.__ugcFileCreationTime = value
@@ -251,7 +251,7 @@
# --------------------------------------------------------------------------
def getUgcFileCreationTime(self):
"""Get the creation time of the ugc file.
- @return: An integer.
+ @return: A float.
"""
return self.__ugcFileCreationTime
Modified: software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/UgcContainer.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/UgcContainer.py 2009-06-30 08:13:14 UTC (rev 4943)
+++ software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/UgcContainer.py 2009-06-30 08:47:56 UTC (rev 4944)
@@ -4,6 +4,7 @@
# http://www.gnu.org/copyleft/gpl.html
import os
+import time
import threading
from util.filesystem.DirectoryContentObserver import DirectoryContentObserver
@@ -200,7 +201,17 @@
"Can't read the ugc file")
self.__mutex.release()
return False
- (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) = os.stat(fileName)
+ # Add creation time if not exists
+ if not ugcDataDict.has_key("creationTime"):
+ ugcDataDict["creationTime"] = time.time()
+ try:
+ f = open(fileName, "w")
+ try:
+ f.write(str(ugcDataDict))
+ finally:
+ f.close()
+ except:
+ pass
# Get the parent gadget
if not ugcDataDict.has_key('parentGadget'):
if self.__onUgcDeploymentErrorCallback != None:
@@ -221,7 +232,6 @@
# Create the Ugc
try:
ugc = Ugc(self, ugcDataDict, fileName, parentGadget)
- ugc.setUgcFileCreationTime(ctime)
except:
if self.__onUgcDeploymentErrorCallback != None:
self.__onUgcDeploymentErrorCallback(observerName, fileName,
@@ -237,7 +247,7 @@
unSortedList.append(ugcObj)
self.__ugcs = []
while len(unSortedList) > 0:
- older = 99999999999
+ older = 99999999999.0
match = None
for ugcObj in unSortedList:
if ugcObj.getUgcFileCreationTime() < older:
@@ -248,6 +258,7 @@
self.__mutex.release()
if self.__onUgcDeployedCallback != None:
self.__onUgcDeployedCallback(ugc, fileName)
+ time.sleep(0.015)
return True
# --------------------------------------------------------------------------
|