Exemplo n.º 1
0
 def edittexture(self, i, initialfile=None):
     fname, ffilter = QFileDialog.getOpenFileName(
         self, "Texture Selection",
         self.lastTextureDir if initialfile is None else initialfile,
         "All files (*.*)")
     if len(fname) == 0: return
     self.lastTextureDir = os.path.dirname(str(fname))
     format = QImageReader.imageFormat(fname)
     if len(format) == 0:
         QMessageBox.warning(self, "Format error!",
                             "Format not supported !")
         self.edittexture(i, initialfile)
     else:
         self.setMaterial(i, ImageTexture(str(fname)))
         self.valueChanged.emit()
Exemplo n.º 2
0
    def monitorfile(self):
        if not hasattr(self,'monitoring'):
          self.monitoring = True
          if not self.fname is None:
            if not os.path.exists(self.fname):
                answer = QMessageBox.warning(self.lpywidget,"Removed file","File '"+os.path.basename(self.fname)+"' do not exists anymore. Do you want to keep it in editor ?",QMessageBox.Yes,QMessageBox.No)
                if answer == QMessageBox.No:
                    self.lpywidget.closeDocument(self.index)
            elif os.stat(self.fname).st_mtime > self.mtime :
                answer = QMessageBox.warning(self.lpywidget,"File has changed","File '"+os.path.basename(self.fname)+"' has changed on disk. Do you want to reload it ?",QMessageBox.Yes,QMessageBox.No)
                if answer == QMessageBox.Yes:
                    self.reload()
                else:
                    self.mtime = os.stat(self.fname).st_mtime +1
            self.updateSvnStatus()

          del self.monitoring
Exemplo n.º 3
0
 def fileDropEvent(self, pos, fname):
     from openalea.lpy.cpfgcompat.data_import import import_colormap, import_materialmap
     base, ext = os.path.splitext(fname)
     if ext == '.map' or ext == '.mat':
         if ext == '.map':
             newcolors = import_colormap(fname)
         else:
             newcolors = import_materialmap(fname)
         if len(newcolors) > 0:
             self.setMaterials(newcolors)
         else:
             QMessageBox.warning(
                 self, 'Data Error',
                 'Read no data from file "' + os.path.basename(fname) + '"')
     else:
         format = QImageReader.imageFormat(fname)
         if len(format) != 0:
             self.setMaterial(pos, ImageTexture(str(fname)))
             self.valueChanged.emit()
Exemplo n.º 4
0
 def ssl_server_trust_prompt(trust_dict):
     if svn_client_gui_parent is None: return True, True, True
     msg = 'The authenticity of host "%s" can\' t be established.\nRSA key fingerprint is %s.\nValid from %s to %s.\nCertified by %s.\nAccept ?'
     msg = msg % (trust_dict['hostname'], trust_dict['finger_print'],
                  trust_dict['valid_from'], trust_dict['valid_until'],
                  trust_dict['issuer_dname'])
     ok = QMessageBox.question(
         svn_client_gui_parent,
         'RSA Authentification of ' + trust_dict['realm'], msg,
         QMessageBox.Ok, QMessageBox.Cancel)
     return ok == QMessageBox.Ok, True, True
Exemplo n.º 5
0
 def pastematerial(self):
     if self.clipboard is None or not self.lenSelection() in [
             1, len(self.clipboard)
     ]:
         QMessageBox.warning(
             self, 'Copy error',
             'Cannot copy materials ! Source and target are inconsistents')
     else:
         if self.lenSelection() == 1:
             sel = self.selectionbegin
             if self.cutaction == True:
                 sourceindices = [i[0] for i in self.clipboard]
                 if sel in sourceindices:
                     sel = min(sourceindices)
                     sourceindices.pop(sourceindices.index(sel))
                 for i in reversed(sourceindices):
                     self.delMaterial(i)
                     if i < sel:
                         sel -= 1
             print 'Copy ', self.clipboard[0][0], 'to', sel
             self.setMaterial(sel, self.clipboard[0][1].deepcopy())
             for i, color in reversed(self.clipboard[1:]):
                 self.insertMaterial(sel + 1, color.deepcopy())
             self.setSelection(sel, sel + len(self.clipboard) - 1)
         else:
             for color, pos in zip(self.clipboard, self.getSelection()):
                 self.setMaterial(pos, color[1].deepcopy())
             if self.cutaction == True:
                 iminus = 0
                 for pos, color in reversed(self.clipboard):
                     if not self.isInSelection(pos):
                         self.delMaterial(pos)
                         if pos < self.selectionbegin:
                             iminus -= 1
                 self.setSelection(self.selectionbegin - iminus,
                                   self.selectionend - iminus)
         self.cutaction = None
         self.clipboard = None
         self.valueChanged.emit()
     self.menuselection = None
     self.updateGL()
Exemplo n.º 6
0
 def close(self):
     if self._edited:
         if not self.isCurrent():
             self.makeCurrent()
         answer = QMessageBox.warning(self.lpywidget,self.getShortName(),"Do you want to save this document ?",
                                     QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel, QMessageBox.Save)
         if answer == QMessageBox.Save: self.save()
         elif answer == QMessageBox.Cancel: return False
         elif answer == QMessageBox.Discard:
             bckupname = self.getBackupName()
             if bckupname and os.path.exists(bckupname): os.remove(bckupname)
     return True
Exemplo n.º 7
0
 def svnFileCommit(fname, msg=None, parent=None):
     import os
     fname = os.path.abspath(fname)
     if not isSvnAddedFile(fname) and not svnIsUpToDate(
             fname, parent, True):
         QMessageBox.question(
             parent, 'Update first',
             repr(os.path.basename(fname)) +
             ' is not up to date.\nUpdate first.')
         return
     if msg is None:
         if parent is None:
             msg = ''
         else:
             ok, msg = get_log(parent,
                               'SVN Commit - ' + os.path.basename(fname))
             if not ok: return
     client = get_svn_client()
     cwd = os.getcwd()
     os.chdir(os.path.dirname(fname))
     res = client.checkin(fname, msg)
     os.chdir(cwd)
     return res
Exemplo n.º 8
0
 def error_match(self,pos_beg,pos_end,dest,rule,args,exc_info):
     self.print_src(pos_beg,pos_end)        
     self.print_dest(dest)
     self.ruleView.setText(str(rule.lineno)+': '+rule.name()+' --> raise exception!')
     self.addMarker(rule.lineno)
     self.updateArgs(dict(zip(rule.parameterNames(),args)))        
     tb.print_exception(*exc_info)
     self.lpywidget.errorEvent(exc_info)
     errmsg = self.lpywidget.getErrorMessage(exc_info)
     res = QMessageBox.warning(self.lpywidget,"Exception",errmsg,QMessageBox.Abort,QMessageBox.Ignore)
     self.delMarker()
     if res == QMessageBox.Ignore:
         return True
     else : 
         return False
Exemplo n.º 9
0
 def svnIsUpToDate(fname, parent=None, silent=False):
     import os
     global svn_client_gui_parent
     client = get_svn_client()
     svn_client_gui_parent = parent
     import os
     fname = os.path.abspath(fname)
     local_entry_list = client.info2(fname)[0]
     current_entry = local_entry_list[1]
     current_rev = current_entry['rev']
     try:
         server_entry_list = client.info2(
             fname,
             revision=pysvn.Revision(pysvn.opt_revision_kind.head))[0]
         server_entry = server_entry_list[1]
         server_rev = server_entry['last_changed_rev']
         if current_rev.number < server_rev.number:
             if not silent and parent:
                 changelogs = client.log(fname,
                                         revision_start=server_rev,
                                         revision_end=current_rev)
                 msg = os.path.basename(
                     fname
                 ) + '\nA new version of the model exists : %s (current=%s).\n' % (
                     server_rev.number, current_rev.number)
                 for log in changelogs:
                     msg += " - [%s][%s] '%s'\n" % (log.revision.number,
                                                    log.author, log.message)
                 msg += "Status : " + str(svnFileTextStatus(fname))
                 QMessageBox.question(parent, 'Up-to-date', msg)
             return False
         else:
             if not silent and parent:
                 msg = os.path.basename(
                     fname
                 ) + '\nYour version is up-to-date.\nRevision: %s.\n' % (
                     current_rev.number)
                 if server_entry['last_changed_date']:
                     import time
                     msg += 'Last changed date : %s\n' % time.asctime(
                         time.gmtime(server_entry['last_changed_date']))
                 if server_entry['last_changed_author']:
                     msg += 'Last changed author : %s\n' % server_entry[
                         'last_changed_author']
                 msg += "Status : " + str(svnFileTextStatus(fname))
                 QMessageBox.question(parent, 'Up-to-date', msg)
             return True
     except pysvn.ClientError, ce:
         if not silent and parent:
             QMessageBox.warning(parent, 'Up-to-date', ce.message)
             return True
         else:
             raise ce
Exemplo n.º 10
0
 def open(self,fname):
     self.setFname(fname)
     assert self._fname == fname
     recovery = False
     readname = self.fname
     bckupname = self.getBackupName()
     if bckupname and os.path.exists(bckupname):
         answer = QMessageBox.warning(self.lpywidget,"Recovery mode","A backup file '"+os.path.basename(bckupname)+"' exists. Do you want to recover ?",QMessageBox.Ok,QMessageBox.Discard)
         if answer == QMessageBox.Ok:
             recovery = True
             readname = bckupname
         elif answer == QMessageBox.Discard:
             os.remove(bckupname)     
     os.chdir(os.path.dirname(self.fname))        
     code = file(readname,'rU').read()
     self.readonly = (not os.access(fname, os.W_OK))
     self.textedition = recovery
     self.setEdited(recovery)
     self.opencode(code)
     self.mtime = os.stat(self.fname).st_mtime
     self.updateReadOnly()
Exemplo n.º 11
0
 def svnUpdate(fname, parent=None):
     global svn_client_gui_parent
     client = get_svn_client()
     svn_client_gui_parent = parent
     import os
     fname = os.path.abspath(fname)
     local_rev = client.info2(fname)[0][1]['rev']
     try:
         rev = client.update(fname)
         if type(rev) is list: rev = rev[0]
         if local_rev.number == rev.number:
             if parent:
                 QMessageBox.question(
                     parent, 'Update',
                     'Your version is already up-to-date : %s' % rev.number)
             return False
         else:
             if parent:
                 QMessageBox.question(parent, 'Update',
                                      'Updated at revision %s' % rev.number)
             return True
     except pysvn.ClientError, ce:
         QMessageBox.warning(parent, 'Update', ce.message)
         return False
Exemplo n.º 12
0
 def errorMessage(self, msg):
     return QMessageBox.warning(self, "Exception", msg, QMessageBox.Ok)