コード例 #1
0
    def OnDrop(self, event):
        """Handles files which are dropped into GSBrowser; prompts a message box and uploads the files accordingly"""
        fileNames = event.GetFiles()
        msgBox = wx.MessageDialog(
            self, helper.list2str(fileNames),
            "Are you sure you want to upload these files?", wx.YES_NO)
        if msgBox.ShowModal() == wx.ID_NO:
            return
        else:
            bucketName = self.GetSelectedItems(self.bktList)[0]
            self.StatusBar.SetStatusText("Uploading...")
            normalCursor = self.GetCursor()
            busyCursor = wx.StockCursor(wx.CURSOR_WAIT)
            self.SetCursor(busyCursor)
            for fname in fileNames:
                pdlg = wx.ProgressDialog(fname,
                                         "FileUpload",
                                         maximum=os.path.getsize(fname))
                pdlg.SetSize((400, 100))

                def update(m, n):
                    pdlg.Update(m, str(100 * m / n) + "% done")

                gs.uploadObject(bucketName, fname, update)
            self.StatusBar.SetStatusText("Done!")
            self.SetCursor(normalCursor)
            #refresh
            self.OnListBox(event)
コード例 #2
0
    def OnUpload(self, event):
        """Uploads object(s)/directory(ies)"""
        bucketName = self.GetSelectedItems(self.bktList)[0]
        selections = self.dir_tree.GetSelections()
        filesToUpload = []
        self.StatusBar.SetStatusText("Uploading...")
        normalCursor = self.GetCursor()
        busyCursor = wx.StockCursor(wx.CURSOR_WAIT)
        self.SetCursor(busyCursor)
        for item in selections:
            k = self.dir_tree.GetItemData(item)
            path = self.dirCtrl.GetDirItemData(item).m_path
            if os.path.isdir(
                    path
            ) == False:  #if its not a directory, simply append the path
                filesToUpload.append(path)
            else:  #if its a directory, upload all the files in the directory
                msgBox = wx.MessageDialog(
                    self,
                    "You have also selected a directory, do you want to upload its entire contents?",
                    "GS", wx.YES_NO)
                if msgBox.ShowModal() == wx.ID_NO:
                    pass
                else:  #user said Yes!
                    dirlist = []
                    for i in os.listdir(path):
                        dirlist.append(os.path.join(path, i))
                    for fname in dirlist:
                        pdlg = wx.ProgressDialog(
                            fname,
                            "FileUpload",
                            maximum=os.path.getsize(fname))
                        pdlg.SetSize((400, 100))

                        def update(m, n):
                            pdlg.Update(m, str(100 * m / n) + "% done")

                        gs.uploadObject(bucketName, fname, update)
        for fname in filesToUpload:
            pdlg = wx.ProgressDialog(fname,
                                     "FileUpload",
                                     maximum=os.path.getsize(fname))
            pdlg.SetSize((400, 100))

            def update(m, n):
                pdlg.Update(m, str(100 * m / n) + "% done")

            gs.uploadObject(bucketName, fname, update)
        self.StatusBar.SetStatusText("Done!")
        self.SetCursor(normalCursor)
        #refresh
        self.OnListBox(event)
コード例 #3
0
ファイル: app.py プロジェクト: cute/google-storage-ui
	def OnDrop(self,event):
		"""Handles files which are dropped into GSBrowser; prompts a message box and uploads the files accordingly"""
		fileNames = event.GetFiles()
		msgBox = wx.MessageDialog(self,helper.list2str(fileNames),"Are you sure you want to upload these files?",wx.YES_NO)
		if msgBox.ShowModal() == wx.ID_NO:
                         return
		else:
			bucketName = self.GetSelectedItems(self.bktList)[0]
			self.StatusBar.SetStatusText("Uploading...")
	                normalCursor = self.GetCursor()
        	        busyCursor = wx.StockCursor(wx.CURSOR_WAIT)
                	self.SetCursor(busyCursor)
			for fname in fileNames:
				pdlg = wx.ProgressDialog(fname,"FileUpload",maximum=os.path.getsize(fname))
				pdlg.SetSize((400,100))
				def update(m,n):
					pdlg.Update(m,str(100*m/n)+ "% done")
				gs.uploadObject(bucketName,fname,update)
			self.StatusBar.SetStatusText("Done!")
        	        self.SetCursor(normalCursor)
	                #refresh
                	self.OnListBox(event)
コード例 #4
0
ファイル: app.py プロジェクト: cute/google-storage-ui
	def OnUpload(self,event):
		"""Uploads object(s)/directory(ies)"""
		bucketName = self.GetSelectedItems(self.bktList)[0]
		selections = self.dir_tree.GetSelections()
		filesToUpload = []
		self.StatusBar.SetStatusText("Uploading...")
		normalCursor = self.GetCursor()
		busyCursor = wx.StockCursor(wx.CURSOR_WAIT)
		self.SetCursor(busyCursor)
		for item in selections:
			k = self.dir_tree.GetItemData(item)
		        path= self.dirCtrl.GetDirItemData(item).m_path
			if os.path.isdir(path)==False: #if its not a directory, simply append the path
				filesToUpload.append(path)
			else: #if its a directory, upload all the files in the directory
				msgBox = wx.MessageDialog(self,"You have also selected a directory, do you want to upload its entire contents?","GS",wx.YES_NO)
				if msgBox.ShowModal() == wx.ID_NO:
					pass
				else: #user said Yes!
					dirlist = []
					for i in os.listdir(path):
						dirlist.append(os.path.join(path,i))
					for fname in dirlist:
						pdlg = wx.ProgressDialog(fname,"FileUpload",maximum=os.path.getsize(fname))
						pdlg.SetSize((400,100))
						def update(m,n):
							pdlg.Update(m,str(100*m/n)+ "% done")
						gs.uploadObject(bucketName,fname,update)
		for fname in filesToUpload:
			pdlg = wx.ProgressDialog(fname,"FileUpload",maximum=os.path.getsize(fname))
			pdlg.SetSize((400,100))
			def update(m,n):
				pdlg.Update(m,str(100*m/n)+ "% done")
			gs.uploadObject(bucketName,fname,update)
		self.StatusBar.SetStatusText("Done!")
		self.SetCursor(normalCursor)
		#refresh
                self.OnListBox(event)