Exemple #1
0
	def callback(self):
		print "enter Download logic here"
		print FileInfo['Filename'][int(e.get())-1]
    		if (not cache2.inCache(FileInfo['Filename'][int(e.get())-1])):
			(fid,filename)=client.doCmd({"cmd":"getFile","filename":FileInfo['Filename'][int(e.get())-1]})
    			print fid
    			url='http://godatacloud.appspot.com/file/'+fid+'/download'
    			print url
			cache2.updateCache(filename,url)
		else:
			print "File served from cache folder.Please check"
Exemple #2
0
def main():

    FileInfo={}
    FileInfo['Filename']=[]
    FileInfo['Size']=[]
    FileInfo['User']=[]
    FileInfo['Time']=[]
    FileInfo['ContentType']=[]
    register_openers()
    if (sys.argv[1]=="view"):
	f=doCmd({"cmd":"view"})
    	for i in f:
		FileInfo[i.split(":")[0]].append(i.split(":")[1].split("/")[-1])		
    	for f in FileInfo:
		print f,FileInfo[f]


    elif (sys.argv[1]=="upload"):
	f=doCmd({"cmd":"upload"})
   	url=f
  	#print url
  	datagen, headers = multipart_encode({"sublet": open(sys.argv[2], "rb")})
  	request = urllib2.Request(url, datagen, headers)
	print urllib2.urlopen(request).read() 
   	cache2.getRequest(sys.argv[2])

    elif (sys.argv[1]=="getFile"):
	filename=sys.argv[2]
    	if (not cache2.inCache(filename)):
		(fid,filename)=doCmd({"cmd":"getFile","filename":filename})  
    		print fid
    		url='http://godatacloud.appspot.com/file/'+fid+'/download'
    		print url
		cache2.updateCache(filename,url)
    	response=urllib2.urlopen(url)
    	localFile = open(filename, 'w')
    	localFile.write(response.read())
    	response.close()
    	localFile.close()
    else:
		print "File served from cache folder.Please check"