incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strou...@apache.org
Subject svn commit: r1205173 - in /incubator/tashi: branches/stablefix/src/tashi/clustermanager/data/sql.py trunk/src/tashi/clustermanager/data/sql.py
Date Tue, 22 Nov 2011 21:12:04 GMT
Author: stroucki
Date: Tue Nov 22 21:12:03 2011
New Revision: 1205173

URL: http://svn.apache.org/viewvc?rev=1205173&view=rev
Log:
sql.py: Add getImages to SQL based interface. This info is not DB backed, so it should probably
eventually be looked up elsewhere

Modified:
    incubator/tashi/branches/stablefix/src/tashi/clustermanager/data/sql.py
    incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py

Modified: incubator/tashi/branches/stablefix/src/tashi/clustermanager/data/sql.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stablefix/src/tashi/clustermanager/data/sql.py?rev=1205173&r1=1205172&r2=1205173&view=diff
==============================================================================
--- incubator/tashi/branches/stablefix/src/tashi/clustermanager/data/sql.py (original)
+++ incubator/tashi/branches/stablefix/src/tashi/clustermanager/data/sql.py Tue Nov 22 21:12:03
2011
@@ -19,15 +19,18 @@ import logging
 import threading
 import time
 import types
+# XXXstroucki getImages needs os?
+import os
 from tashi.rpycservices.rpyctypes import *
 from tashi.clustermanager.data.datainterface import DataInterface
-from tashi.util import stringPartition, boolean
+from tashi.util import stringPartition, boolean, instantiateImplementation, humanReadable
 
 class SQL(DataInterface):
 	def __init__(self, config):
 		DataInterface.__init__(self, config)
 		self.uri = self.config.get("SQL", "uri")
 		self.log = logging.getLogger(__name__)
+		self.dfs = instantiateImplementation(config.get("ClusterManager", "dfs"), config)
 
 		if (self.uri.startswith("sqlite://")):
 			import sqlite
@@ -282,6 +285,17 @@ class SQL(DataInterface):
 		r = cur.fetchone()
 		network = Network(d={'id':r[0], 'name':r[1]})
 		return network
+
+        def getImages(self):
+                count = 0
+                myList = []
+                for i in self.dfs.list("images"):
+                        myFile = self.dfs.getLocalHandle("images/" + i)
+                        if os.path.isfile(myFile):
+                                image = LocalImages(d={'id':count, 'imageName':i, 'imageSize':humanReadable(self.dfs.stat(myFile)[6])})
+                                myList.append(image)
+                                count += 1
+                return myList
 	
 	def getUsers(self):
 		cur = self.executeStatement("SELECT * from users")

Modified: incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py?rev=1205173&r1=1205172&r2=1205173&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py (original)
+++ incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py Tue Nov 22 21:12:03 2011
@@ -19,15 +19,18 @@ import logging
 import threading
 import time
 import types
+# XXXstroucki getImages needs os?
+import os
 from tashi.rpycservices.rpyctypes import *
 from tashi.clustermanager.data.datainterface import DataInterface
-from tashi.util import stringPartition, boolean
+from tashi.util import stringPartition, boolean, instantiateImplementation, humanReadable
 
 class SQL(DataInterface):
 	def __init__(self, config):
 		DataInterface.__init__(self, config)
 		self.uri = self.config.get("SQL", "uri")
 		self.log = logging.getLogger(__name__)
+		self.dfs = instantiateImplementation(config.get("ClusterManager", "dfs"), config)
 
 		if (self.uri.startswith("sqlite://")):
 			import sqlite
@@ -282,6 +285,17 @@ class SQL(DataInterface):
 		r = cur.fetchone()
 		network = Network(d={'id':r[0], 'name':r[1]})
 		return network
+
+        def getImages(self):
+                count = 0
+                myList = []
+                for i in self.dfs.list("images"):
+                        myFile = self.dfs.getLocalHandle("images/" + i)
+                        if os.path.isfile(myFile):
+                                image = LocalImages(d={'id':count, 'imageName':i, 'imageSize':humanReadable(self.dfs.stat(myFile)[6])})
+                                myList.append(image)
+                                count += 1
+                return myList
 	
 	def getUsers(self):
 		cur = self.executeStatement("SELECT * from users")



Mime
View raw message