示例#1
0
    def showUpdateDialog(self, auto=False):
        if not redREnviron.checkInternetConnection():
            if not auto:
                self.createDialog(_('No Internet Connection'), False)
            return

        today = date.today()
        if redREnviron.settings['checkedForUpdates'] != 0:
            diff = today - redREnviron.settings['checkedForUpdates']
            if int(diff.days) < 2 and auto:
                return

        redREnviron.settings['checkedForUpdates'] = today
        redREnviron.saveSettings()
        avaliable = self.checkForUpdate()
        if avaliable:
            html = _("<h2>Red-R %s</h2><h4>Revision:%s; Date: %s</h4><br>%s"
                     ) % (self.availableUpdate['redRVerion'],
                          self.availableUpdate['SVNVersion'],
                          self.availableUpdate['date'],
                          self.availableUpdate['changeLog'])
            self.createDialog(html, True)
        elif not avaliable and not auto:
            self.createDialog(
                _('You have the most current version of Red-R %s.') %
                self.version, False)
    def closeEvent(self, ce, postCloseFun=None):
        # save the current width of the toolbox, if we are using it
        # if isinstance(self.widgetsToolBar, orngTabs.WidgetToolBox):
            # redREnviron.settings["toolboxWidth"] = self.widgetsToolBar.toolbox.width()
        # redREnviron.settings["showWidgetToolbar"] = self.widgetsToolBar.isVisible()
        # redREnviron.settings["showToolbar"] = self.toolbar.isVisible()
#         qtsettings = QSettings("Red-R", "Red-R")
#         qtsettings.setValue("geometry", saveGeometry())
#         qtsettings.setValue("windowState", saveState())
        
        try:
            #ce.accept()
            redREnviron.settings["geometry"] = self.saveGeometry()
            redREnviron.settings["windowState"] = self.saveState()
            redREnviron.settings['pos'] = self.pos()
            redREnviron.settings['size'] = self.size()

            
            
            redREnviron.saveSettings()
            # closed = self.schema.close()
            if redREnviron.settings['dontAskBeforeClose']:
                res = QMessageBox.No
            else:
                res = QMessageBox.question(self, _('Red-R Canvas'),_('Do you wish to save the schema?'), QMessageBox.Yes, QMessageBox.No, QMessageBox.Cancel)
            
            if res == QMessageBox.Yes:
                self.RVariableRemoveSupress = 1
                #saveComplete = 
                closed=redRSaveLoad.saveDocument()
            elif res == QMessageBox.No:
                closed=True
            else:
                closed=False
        
            if closed:
                if postCloseFun:
                    print 'asdfasdfasfd'
                    r = postCloseFun()
                    print 'a', r
                self.canvasIsClosing = 1        # output window (and possibly report window also) will check this variable before it will close the window
                redRObjects.closeAllWidgets() # close all the widget first so their global data is saved
                import shutil
                shutil.rmtree(redREnviron.directoryNames['tempDir'], True) # remove the tempdir, better hope we saved everything we wanted.
                # close the entire session dropping anything that was open in case it was left by something else, 
                # makes the closing much cleaner than just loosing the session.
                
                redRHistory.saveConnectionHistory()
                redRLog.fileLogger.closeLogFile()
                #redRLog.closeLogger()
                ce.accept()
                QMainWindow.closeEvent(self,ce)
                

            else:
                ce.ignore()
        except Exception as inst:
            redRLog.log(redRLog.REDRCORE, redRLog.CRITICAL, 'Error closing session: %s' % unicode(inst))
            ce.ignore()
    def checkForUpdate(self, auto=True):
        today = date.today()
        if not redREnviron.checkInternetConnection():
            return

        if redREnviron.settings['lastUpdateCheck'] != 0:
            diff =  today - redREnviron.settings['lastUpdateCheck']
            if int(diff.days) < 7 and auto:
                    return
        url =redREnviron.settings['updatesRepository'] +'/currentVersion.xml'
        print 'theurl:', url
        print 'thesavefile', self.updateFile
        try:
            f = urllib2.urlopen(url)
            output = open(self.updateFile,'wb')
            output.write(f.read())
            output.close()
            
        except:
            redREnviron.settings['updateAvailable'] = False
            redRLog.log(redRLog.REDRCORE,redRLog.ERROR,'Could not find updates from web.')
            
        redREnviron.settings['lastUpdateCheck'] = today
        redREnviron.saveSettings()
        
        self.availableUpdate = self.parseUpdatesXML(self.updateFile)
        print 'avaliable', self.availableUpdate
        
        if self.availableUpdate and (self.availableUpdate['redRVersion'] == redREnviron.version['REDRVERSION'] 
        and self.availableUpdate['SVNVersion'] > redREnviron.version['SVNVERSION']):
            print auto, self.availableUpdate['SVNVersion'] in redREnviron.settings['ignoredUpdates']
            if auto and self.availableUpdate['SVNVersion'] in redREnviron.settings['ignoredUpdates']:
                redREnviron.settings['updateAvailable'] = False
            else: 
                redREnviron.settings['updateAvailable'] = True
        else: 
            redREnviron.settings['updateAvailable'] = False
        
        print 'is available', redREnviron.settings['updateAvailable']
        redREnviron.saveSettings()
def startSetupWizard():
    setupWizard = RedRInitWizard()
    if setupWizard.exec_() == QDialog.Accepted:
        redREnviron.settings['email'] = unicode(setupWizard.email.text())
        # redREnviron.settings['canContact'] = unicode(setupWizard.allowContact.getChecked()) == _('Yes')
        try:
            redREnviron.settings['CRANrepos'] = setupWizard.settings['CRANrepos']
        except:
            redRLog.log(redRLog.REDRCORE, redRLog.ERROR, redRLog.formatException())
            pass
        redREnviron.settings['focusOnCatchException'] = 'showErrorWindow' in setupWizard.redRExceptionHandling.getCheckedIds()
        #redREnviron.settings['outputVerbosity'] = setupWizard.REDRCORE_initWizard_ouptutVerbosity.currentId()
        redREnviron.settings['uploadError'] = 'submitError' in setupWizard.redRExceptionHandling.getCheckedIds()
        redREnviron.settings['askToUploadError'] = 'askToSubmit' in setupWizard.redRExceptionHandling.getCheckedIds()
        redREnviron.settings['checkForPackageUpdates'] = 'checkUpdates' in setupWizard.redRExceptionHandling.getCheckedIds()
        loadBaseLibs()
        if _('Start Example') in setupWizard.showExample.getChecked():
            redRSaveLoad.loadDocument(os.path.join(redREnviron.directoryNames['examplesDir'], 'firstSchema.rrs'))
        
    #print redREnviron.settings
    redREnviron.settings['firstLoad'] = False
    redREnviron.saveSettings()
示例#5
0
    def accept(self):
        # self.settings["widgetSelectedColor"] = self.selectedWidgetIcon.color.getRgb()
        # self.settings["widgetActiveColor"]   = self.activeWidgetIcon.color.getRgb()
        # self.settings["lineColor"]           = self.activeLineIcon.color.getRgb()
        
        # self.settings["exceptionLevel"] = int(self.exceptionLevel.value())
        # self.settings["minSeverity"] = int(self.otherLevel.value())
        
        # self.settings['helpMode'] = (str(self.helpModeSelection.getChecked()) in _('Show Help Icons'))
        self.settings['keepForXDays'] = int(self.numberOfDays.value())
        redREnviron.settings.update(self.settings)
        redREnviron.saveSettings()
        import redRLog
        redRLog.moveLogFile(redREnviron.settings['logFile'])
        # redRStyle.widgetSelectedColor = self.settings["widgetSelectedColor"]
        # redRStyle.widgetActiveColor   = self.settings["widgetActiveColor"]  
        # redRStyle.lineColor           = self.settings["lineColor"]          
        
        # update settings in widgets in current documents
        for widget in self.canvasDlg.schema.widgets():
            widget.instance()._owInfo      = redREnviron.settings["owInfo"]
            widget.instance()._owWarning   = redREnviron.settings["owWarning"]
            widget.instance()._owError     = redREnviron.settings["owError"]
            widget.instance()._owShowStatus= redREnviron.settings["owShow"]
            # widget.instance.updateStatusBarState()
            widget.resetWidgetSize()
            widget.updateWidgetState()
            widget.update()
        # update tooltips for lines in all documents
        for line in self.canvasDlg.schema.lines():
            line.showSignalNames = redREnviron.settings["showSignalNames"]
            line.updateTooltip()

        redRObjects.activeTab().repaint()
        qApp.canvasDlg.update()
        QDialog.accept(self)
 def ignore(self):
     print 'ignore'
     redREnviron.settings['ignoredUpdates'] += self.availableUpdate['SVNVersion']
     redREnviron.settings['updateAvailable'] = False
     redREnviron.saveSettings()
     self.app.exit(0)
 def accept(self):
     print 'accept'
     self.downloadUpdate(self.availableUpdate)
     redREnviron.settings['updateAvailable'] = False
     redREnviron.saveSettings()