Esempio n. 1
0
    def runto(self):
        try:
            self.path = QtCore.QFileInfo(self.filename).path()
        except AttributeError:
            pass
        g = globals()
        os.chdir(str(self.path))
        os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path)))
        script = str(self.codebox.text())
        try:
            exec (script, g)
            QtGui.QCloseEvent()


        except ImportError:
            os.chdir(str(self.path))
            os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path)))
            sys.path.append(str(self.path))
            exec (script, g)
            QtGui.QCloseEvent()

            if TypeError (QTextStream):
                g = globals()
                os.chdir(str(self.path))
                os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path)))
                sys.path.insert(0, str(self.path))
                exec int(script)
                QtGui.QCloseEvent()
Esempio n. 2
0
 def closeEvent(self, event):
     self.im2d.closeEvent(QtGui.QCloseEvent())
     self.imboxed.closeEvent(QtGui.QCloseEvent())
     self.improj.closeEvent(QtGui.QCloseEvent())
     self.imslice.closeEvent(QtGui.QCloseEvent())
     self.imvol.closeEvent(QtGui.QCloseEvent())
     event.accept()
Esempio n. 3
0
 def startDownload(self, tree):
     '''Start the download of all the packages for the installation.
     @param tree: the installation tree. '''
     self.parent.tree = tree
     self.parent.sourceDir = self.sourceDir
     self.progress.action = ProgressDialog.START_DOWN
     self.progress.closeEvent(QtGui.QCloseEvent())
Esempio n. 4
0
    def runto(self):
        self.path = QtCore.QFileInfo(self.filename).path()
        g = globals()
        os.chdir(str(self.path))
        script = str(self.codebox.text())
        try:
            exec(script, g)
            QtGui.QCloseEvent()

        except ImportError:
            os.chdir(str(self.path))
            os.path.join(os.path.expanduser('~'),
                         os.path.expandvars(str(self.path)))
            sys.path.insert(0, str(self.path))
            exec(script, g)
            QtGui.QCloseEvent()
Esempio n. 5
0
 def check(self, tree):
     '''Check if there are new versions of a package. '''
     try:
         old = self.getOldNodes(tree)
     except:
         self.progress.action = ProgressDialog.ERROR
         self.progress.title = "Error!"
         self.progress.msg = "Check your source directory"
         self.progress.closeEvent(QtGui.QCloseEvent())
     else:
         self.parent.tree = tree
         self.setAction(self.parent.tree.root, False, old)
         if self.parent.action == self.parent.UPGRADE:
             self.list = QtCore.QStringList()
             for x in old:
                 self.list.append(x.name + " - " + x.version)
             self.progress.action = ProgressDialog.CHECK
             self.progress.closeEvent(QtGui.QCloseEvent())
Esempio n. 6
0
 def checkForRebuild(self, tree):
     '''Check if all the required packages are installed.'''
     try:
         old = self.getOldNodes(tree)
     except:
         self.progress.action = ProgressDialog.ERROR
         self.progress.title = "Error!"
         self.progress.msg = "Check your source directory"
         self.progress.closeEvent(QtGui.QCloseEvent())
     else:
         self.parent.tree = tree
         self.setAction(self.parent.tree.root, False, None)
         if len(old) != 0:
             self.progress.action = ProgressDialog.ERROR
             self.progress.title = "Updates Found!"
             self.progress.msg = "ILDJIT is outdated or not properly installed.\nTry to perform a new installation or an upgrade."
             self.progress.closeEvent(QtGui.QCloseEvent())
         else:
             self.parent.sourceDir = self.sourceDir
             self.progress.action = ProgressDialog.REBUILD
             self.progress.closeEvent(QtGui.QCloseEvent())
Esempio n. 7
0
 def handleCharacterChoice(self):
     """
     Send the character selection to the server as a string identifier.
     """
     # Get character selection from dialog box
     self.character = str(
         self.getCharacter.characterList.currentItem().text())
     # Request to join game as chosen character
     self.connection.send(
         self.encrypt('function::joinGame:' + self.character))
     self.getCharacter.closeEvent(QtGui.QCloseEvent(), valid=True)
     self.inputWindow.setReadOnly(False)
Esempio n. 8
0
 def handleRevealChoice(self):
     """
     Send the card that the user has chosen to reveal to the server
     as a string identifier.
     """
     # Get the selected card from dialog box
     choice = str(self.getReveal.cardList.currentItem().text())
     # Get the name of the person user is revealing to
     name = self.getReveal.player
     # Send signal to server to reveal chosen card
     self.connection.send(
         self.encrypt('function::revealCard:%s:%s' % (choice, name)))
     self.getReveal.closeEvent(QtGui.QCloseEvent(), valid=True)
Esempio n. 9
0
 def handleSuggestion(self):
     """
     Send the suggestion selections to the server as a pickled list of
     string identifiers.
     """
     # Get suggestion selections from dialog box
     suggestion = [
         self.getSuggestion.suspectCombo.currentText(),
         self.getSuggestion.weaponCombo.currentText()
     ]
     # Send signal to server to make suggestion
     self.connection.send(
         self.encrypt('function::makingSuggestion:' +
                      pickle.dumps(suggestion)))
     self.getSuggestion.closeEvent(QtGui.QCloseEvent(), valid=True)
Esempio n. 10
0
 def handleAccusationChoice(self):
     """
     Send the accusation selections to the server as a pickled list of
     string identifiers.
     """
     # Get accusation selections from dialog box
     accusation = [
         self.getAccusation.suspectCombo.currentText(),
         self.getAccusation.weaponCombo.currentText(),
         self.getAccusation.roomCombo.currentText()
     ]
     # Send pickled list of selections to server
     self.connection.send(
         self.encrypt('function::makingAccusation:' +
                      pickle.dumps(accusation)))
     self.getAccusation.closeEvent(QtGui.QCloseEvent(), valid=True)
     # Only get one accusation per game
     self.hasAccusation = False
Esempio n. 11
0
 def start(self):
     '''Perform the right action according to the action chosen by the user'''
     self.sourceDir = str(self.sourceLine.text())
     if self.sourceDir == '':
         QtGui.QMessageBox.critical(
             self, self.tr("A field is Missing!"),
             self.tr("The source directory is empty."))
     else:
         self.progress = ProgressDialog(self)
         self.progress.show()
         self.backButton.setEnabled(False)
         self.startButton.setEnabled(False)
         self.sourceLine.enabled = False
         #build the tree
         try:
             self.tree = Tree(self.parent.CONFIG_FILE)
             self.nm = NetworkManager(self.tree)
             self.connect(self.nm, QtCore.SIGNAL("connectionError"),
                          self.manageConnectionError,
                          QtCore.Qt.QueuedConnection)
             if self.parent.action == self.parent.UPGRADE:
                 self.connect(self.nm, QtCore.SIGNAL("completion"),
                              self.check, QtCore.Qt.QueuedConnection)
             elif self.parent.action == self.parent.INSTALL:
                 self.connect(self.nm, QtCore.SIGNAL("completion"),
                              self.startDownload,
                              QtCore.Qt.QueuedConnection)
             elif self.parent.action == self.parent.REBUILD:
                 self.connect(self.nm, QtCore.SIGNAL("completion"),
                              self.checkForRebuild,
                              QtCore.Qt.QueuedConnection)
             self.nm.start()
         except:
             self.progress.action = ProgressDialog.ERROR
             self.progress.title = "Parsing Error"
             self.progress.msg = "Error parsing the configuration file:\n" + self.parent.CONFIG_FILE
             self.progress.closeEvent(QtGui.QCloseEvent())
Esempio n. 12
0
 def manageConnectionError(self):
     '''Show an error message to the user to notify a connection error.'''
     self.progress.action = ProgressDialog.ERROR
     self.progress.title = "Connection Error"
     self.progress.msg = "Cannot connect to the server!"
     self.progress.closeEvent(QtGui.QCloseEvent())
Esempio n. 13
0
 def slotFileQuit(self):
     self.app.postEvent(self, QtGui.QCloseEvent())
Esempio n. 14
0
 def handleCancel(self):
     self.closeEvent(QtGui.QCloseEvent(), valid=True)
Esempio n. 15
0
 def save(self):
     for field_reference, dialog_field in self.fields:
         text = re.sub('[, ]+', ', ', str(dialog_field.text()))
         text = re.sub('^, |, $', '', text)
         field_reference.setText(text)
     self.closeEvent(QtGui.QCloseEvent())