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")
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"
def __init__(self, root): register_openers() Tkinter.Frame.__init__(self, root) self.root = root self.root.title("GoData Client Module") self.grid() Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10') self.root.columnconfigure(0, pad=3) self.root.columnconfigure(1, pad=3) self.root.columnconfigure(2, pad=3) self.root.columnconfigure(3, pad=3) self.root.columnconfigure(4, pad=3) self.root.rowconfigure(0, pad=3) self.root.rowconfigure(1, pad=3) self.root.rowconfigure(2, pad=3) self.root.rowconfigure(3, pad=3) self.root.rowconfigure(4, pad=3) self.root.rowconfigure(5, pad=3) self.root.rowconfigure(6, pad=3) self.root.rowconfigure(7, pad=3) self.root.rowconfigure(8, pad=3) self.root.rowconfigure(9, pad=3) self.root.rowconfigure(10, pad=3) self.root.rowconfigure(11, pad=3) self.root.rowconfigure(12, pad=3) self.root.rowconfigure(13, pad=3) self.root.rowconfigure(14, pad=3) self.root.rowconfigure(15, pad=3) self.root.rowconfigure(16, pad=3) self.root.rowconfigure(17, pad=3) self.root.rowconfigure(18, pad=3) self.root.rowconfigure(19, pad=3) self.root.rowconfigure(20, pad=3) self.root.rowconfigure(21, pad=3) self.root.rowconfigure(22, pad=3) self.root.rowconfigure(0, weight=1) self.root.columnconfigure(0, weight=1) global e e = Entry(self, width=4) e.grid(row=16, column=4) e.focus_set() #self.button = Button(self, text="Upload", fg="red", command=self.logout) #self.button.pack(side = RIGHT) button_opt = {'fill': Tkconstants.BOTH, 'padx': 5, 'pady': 5} a = Tkinter.Button(self, text='Browse', command=self.askopenfilename)#.pack(**button_opt) a.grid(row =1 , column =4) b = Tkinter.Button(self, text='Upload', command=self.upload)#.pack(**button_opt) b.grid(row = 3, column =4) f=client.doCmd({"cmd":"view"}) for i in f: FileInfo[i.split(":")[0]].append(i.split(":")[1].split("/")[-1]) print FileInfo t = SimpleTable(self, len(f)/5,5) t.grid(row = 4, column =4) #MyButton1 = Button(self, text="Download 5", width=14, command=self.Download) #MyButton1.grid(row=15, column=4) #MyButton2 = Button(self, text="Download 6", width=14, command=self.Download) #MyButton2.grid(row=15, column=5) #MyButton3 = Button(self, text="Download 7", width=14, command=self.Download) #MyButton3.grid(row=15, column=6) #MyButton4 = Button(self, text="Download 4", width=14, command=self.Download) #MyButton4.grid(row=15, column=3) #MyButton5 = Button(self, text="Download 3", width=14, command=self.Download) #MyButton5.grid(row=15, column=2) #MyButton6 = Button(self, text="Download 2", width=14, command=self.Download) #MyButton6.grid(row=15, column=1) #MyButton7 = Button(self, text="Download 1", width=14, command=self.Download) #MyButton7.grid(row=15, column=0) #MyButton8 = Button(self, text="Download 8", width=14, command=self.Download) #MyButton8.grid(row=15, column=7) MyButton9 = Button(self, text="Download", width=14, command=self.callback) MyButton9.grid(row=17, column=4) creation = tk.Label( self, text = "Created by Kuber, Digvijay, Anahita & Payal", borderwidth =5, width =45) creation.grid(row=50 , column = 4) self.file_opt = options = {} options['defaultextension'] = '.txt' options['filetypes'] = [('all files', '.*'), ('text files', '.txt')] options['initialdir'] = 'C:\\' options['initialfile'] = 'myfile.txt' options['parent'] = root options['title'] = 'Browse' self.dir_opt = options = {} options['initialdir'] = 'C:\\' options['mustexist'] = False options['parent'] = root options['title'] = 'Browse' image = Image.open("./header.png") photo = ImageTk.PhotoImage(image) label = Label(image=photo) label.image = photo # keep a reference! label.place(width=768, height=576) label.grid(row = 0 , column = 0 ) label.pack(side = TOP) self.centerWindow() self.master.columnconfigure(10, weight=1) #Tkinter.Button(self, text='upload file', command=self.Fname).pack(**button_opt) t = self.file_name = Text(self, width=39, height=1, wrap=WORD) t.grid(row = 2, column =4) extra1 = tk.Label(self, text = "please give a file number", borderwidth = 5, width =45) extra1.grid(row =15, column =4)