Exemplo n.º 1
0
	def upload(self):
		print "enter logout logic here"
		f=client.doCmd({"cmd":"upload"})
	   	url=f
	    	print url
		fl=str(self.file_name.get("1.0", END)).strip()
	    	datagen, headers = multipart_encode({"sublet": open(fl, "rb")})
	   	request = urllib2.Request(url, datagen, headers)
		print urllib2.urlopen(request).read() 
	    	cache2.getRequest(fl)
		del FileInfo['Filename'][:]
		del FileInfo['Size'][:]
		del FileInfo['User'][:]
		del FileInfo['Time'][:]
		del FileInfo['ContentType'][:]
		f=client.doCmd({"cmd":"view"})
		count = 1
		count1 = 1		
		for i in f:
			count += 1
			#if count < 10:
			FileInfo[i.split(":")[0]].append(i.split(":")[1].split("/")[-1])
			count1 += 1		
		print FileInfo
       		t = SimpleTable(self, len(f)/5,5)
        	t.pack(side="bottom", fill="y")
Exemplo n.º 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"