示例#1
0
 def paste(self,item):
     '''First check if item is file then get its parent 
         otherwise check if item is Dir'''
     if(item.isFile()):
         p = item.parent()
     else:
         p = item
     if(self.clipboard != []):
         for items in self.clipboard:
             if(items.isFile()):
                 itemspath = items.getPath()     
                 '''Check if we are pasting files that alreadt exists using ospathjoin'''
                 if not(ospathexists(ospathjoin(p.getPath(),items.name))): 
                     try:
                         shutil.copyfile(itemspath,ospathjoin(p.getPath(),items.name))
                         newItem = File(p,items.name,ospathdirname(itemspath))
                     except:
                         QMessageBox.about(self,"Error","File Cannot be Pasted"+ospathjoin(p.getPath(),items.name))
                 else:
                     QMessageBox.about(self,"Error","File already Exists "+ospathjoin(p.getPath(),items.name))
                     return
             elif(items.isDir()):
                 itemspath = items.getPath()     
                 '''Check if we are pasting files that alreadt exists using ospathjoin'''
                 if not(ospathexists(ospathjoin(p.getPath(),items.name))):
                     try:
                         shutil.copyfile(itemspath,ospathjoin(p.getPath(),items.name))
                         newItem = File(p,items.name,ospathdirname(itemspath))
                     except:
                         QMessageBox.about(self,"Error","File Cannot be Pasted"+ospathjoin(p.getPath(),items.name))
                 else:
                     QMessageBox.about(self,"Error","File already Exists "+ospathjoin(p.getPath(),items.name))
                     return
示例#2
0
 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()
示例#3
0
 def addClosedProject(self,startDir):
     if(ospathexists(startDir)):
         self.closed[self.projects.index(startDir)] = True
         i = Project(self,startDir,True) 
         self.addTopLevelItem(i)
     else:
         QMessageBox.about(self,"Can't Close Project","Project Does Not Exist %s"%startDir)
示例#4
0
 def addPixmapFile(self,nfile, pos): 
     if(nfile.isEmpty()):
         return
     else:
         #print(nfile)
         if(ospathexists(nfile)):
             self.createPixmapItem(QPixmap(nfile),self.view.mapToScene(pos))#self.position())
示例#5
0
 def createProject(self,startDir):
     if(ospathexists(startDir)):
         self.projects.append(startDir)
         self.addProject(startDir)
         return True
     else:
         QMessageBox.about(self,"Can't Open Project","Project Does Not Exist %s"%startDir)
         return False
示例#6
0
 def openAudio(self,nfile):
     if(ospathexists(nfile)):
         form = Audio(self,nfile)
         form.show()
         return True
     else:
         QMessageBox.about(self,"Can't Open","File Does Not Exist\n"+nfile)
         return False
示例#7
0
 def openImage(self,nfile):
     if(ospathexists(nfile)):
         form = Image(self,nfile)
         form.show()
         return True
     else:
         QMessageBox.about(self,"Can't Open","File Does Not Exist\n"+nfile)
         error("Opening: File Does Not Exist "+nfile)
         return False
示例#8
0
 def createTab(self,nfile):
     if(nfile != None):
         if(self.files != None):
             if(len(self.files) != 0):
                     if(nfile in self.files):
                         #print "File Already Open\n"+nfile
                         self.tabWidget.setCurrentIndex(self.files.index(nfile))
                         return False
             if(ospathexists(nfile)):
                     self.openEditor(nfile)  
                     return True    
             else:
                 if(nfile in self.files):
                     self.files.remove(nfile)
                 config.setFile(self.files)
                 QMessageBox.about(self,"Can't Open","File Does Not Exist\n"+nfile) 
                 return False
示例#9
0
 def createProject(self,startDir):
     if(ospathexists(startDir)):
         if self.projects != None:
             if(startDir in self.projects):#will work even if list is empty
                 QMessageBox.about(self, "Already Open","Project Already Open\n"+startDir)
                 return False
         self.projects.append(startDir)
         self.addProject(startDir)
         config.setProject(self.projects)
         return True
         #print "adding"+startDir
     else:
         #This is important very very important otherwise it will crash
         if self.projects != None:
             if(startDir in self.projects):
                 self.projects.remove(startDir)
         config.setProject(self.projects)
         QMessageBox.about(self,"Can't Open Project","Project Does Not Exist %s"%startDir)
         return False
示例#10
0
    def createTab(self, nfile):
        if nfile != None:
            if self.files != None:
                if len(self.files) != 0:
                    for i in self.files:
                        if i == nfile:
                            # print "File Already Open\n"+nfile
                            self.tabWidget.setCurrentIndex(self.files.index(nfile))
                            return
            if type(nfile) == str:
                if ospathexists(nfile):
                    text = ""
                    try:
                        infile = open(nfile, "r")
                        text = infile.read()
                        infile.close()
                        config.addFile(nfile)
                        self.dirty.append(False)
                        self.files.append(nfile)
                        # print len(self.files)
                    except:
                        config.removeFile(nfile)
                        QMessageBox.about(self, "Can't Open", "File Does Not Exist or Locked\n" + nfile)

                    tab = Editor(self, text, self.syntax(nfile), self.colorStyle)
                    self.tabWidget.addTab(tab, ospathbasename(nfile))
                    tab.textChanged.connect(lambda: self.setDirty(nfile))
                    if self.files != None:
                        if (len(self.files)) != 0:
                            # This line sets the opened file to display first Important not checked
                            self.tabWidget.setCurrentIndex(len(self.files) - 1)
                else:
                    # dont know must check this the last file is not removed executes only
                    # twice when it has to remove 3 files
                    # check sel.files
                    # print len(config.files())
                    config.removeFile(nfile)
                    QMessageBox.about(self, "Can't Open", "File Does Not Exist or Locked\n" + nfile)
示例#11
0
 def exists(self):
     return ospathexists(self.path)
示例#12
0
 def createProject(self, startDir):
     if ospathexists(startDir):
         self.treeWidget.addProject(startDir)
     else:
         config.removeProject(startDir)
         QMessageBox.about(self, "Can't Open Project", "Project Does Not Exist %s" % startDir)