def download(self): self.emit(SIGNAL("progress")) url = 'https://raw.github.com/Pyros2097/Sabel/master/build/exe.win32-2.7/library.zip' file_name = url.split('/')[-1] try: u = urllib2.urlopen(url) f = open(file_name+"_2097", 'wb') meta = u.info() file_size = int(meta.getheaders('Content-Length')[0]) #print 'Downloading: %s Bytes: %s' % (file_name, file_size) file_size_dl = 0 block_sz = 8192 while self.running: buffer = u.read(block_sz) if not buffer: break file_size_dl += len(buffer) f.write(buffer) status = file_size_dl * 100.0 / file_size self.emit(SIGNAL("status"),status) ''' The file library.zip is never used the library is once loaded into the vm so no need to delete it ''' f.close() if(self.running): #to prevent it from executing this code if terminated if(ospathexists(file_name)): recycle(file_name) # deletes library.zip osrename(file_name+"_2097",ospathjoin(ospathdirname(file_name+"_2097"),"library.zip")) self.emit(SIGNAL("updated")) except urllib2.URLError as err: self.emit(SIGNAL("cant")) except: self.emit(SIGNAL("stop")) self.quit()
def renameDir(self,item): itempath = item.getPath() text,ok = QInputDialog.getText(self,"QInputDialog::getText()","New Name:") if (ok and text != ''): newname = ospathjoin(ospathdirname(itempath),str(text)) try: print newname osrename(itempath,newname) p = item.parent() p.removeChild(item) #self.refreshAllProjects() except: QMessageBox.about(self,"Error","Could Not Rename The File")
def renameFile(self,item): text,ok = QInputDialog.getText(self,"QInputDialog::getText()","New Name:") itempath = item.getPath() if (ok and text != ''): newname = ospathjoin(ospathdirname(itempath),str(text)) try: #print newname osrename(itempath,newname) p = item.parent() p.removeChild(item) f = File(p,ospathbasename(newname),ospathdirname(newname)) #p.addChild(f) except: QMessageBox.about(self,"Error","Could Not Rename The File")