示例#1
0
    def getWorkingDialog(text):
        """
        Generates a working dialog object which blocks the UI.

        :param text: Text to display while working
        :return: The created working dialog widget
        """

        progressDialog = QProgressDialog(text,
                                         "",
                                         0,
                                         0,
                                         parent=Globals.ui.tabWidgetMain)

        progressDialog.setMinimumDuration(0)
        progressDialog.setMinimum(0)
        progressDialog.setMaximum(0)
        progressDialog.setRange(0, 0)

        progressDialog.setFixedSize(progressDialog.width(),
                                    progressDialog.height())

        # No cancel button <:
        progressDialog.setCancelButton(None)
        # No X button
        progressDialog.setWindowFlags(progressDialog.windowFlags()
                                      & ~QtCore.Qt.WindowCloseButtonHint)

        progressBar = progressDialog.findChild(QProgressBar)
        # :S:S
        progressBar.setMinimumWidth(progressDialog.width() + 20)

        return progressDialog
示例#2
0
class UpdatesView(QDialog, Ui_UpdatesView):
  def __init__(self, parent, appargs):
    QDialog.__init__(self, parent)
    self.setupUi(self)
    self._app = esky.Esky(sys.executable,
        "http://10.78.55.218/pyrite/downloads")
    self._appargs = appargs

    self.connectActions()
    self.updateView()

  def connectActions(self):
    self.btnCheckForUpdates.clicked.connect(self.updateView)
    self.btnInstallUpdate.clicked.connect(self.installUpdate)
    self.btnClose.clicked.connect(self.reject)

  def updateView(self):
    self.lblCurrentVersion.setText("You are currently running Pyrite version:"
        " {0}".format(version.version))
    update = self._app.find_update()
    if update is not None:
      self.lblAvailableUpdate.setText("Pyrite version {0} is available for"
          " download".format(update))
      self.btnInstallUpdate.setEnabled(True)
    else:
      self.lblAvailableUpdate.setText("There are no new updates available at"
          " this time.")

  def installUpdate(self):
    try:
      # setup progress dialog
      self._progressDlg = QProgressDialog(self)
      self._progressDlg.setWindowModality(Qt.WindowModal)
      self._progressDlg.setAutoClose(True)
      self._progressDlg.setMinimum(0)
      self._progressDlg.setMaximum(100)
      self._progressDlg.setLabelText("Auto-Updating")
      self._progressDlg.setCancelButton(None)
      self._progressDlg.setValue(0)

      self._app.auto_update(self.autoUpdateCallback)

      appexe = esky.util.appexe_from_executable(sys.executable)
      os.execv(appexe, self._appargs)
      QMessageBox.information(None, "Updating", "Update complete!")
      self._app.cleanup()
      self._progressDlg.reset()
      sys.exit()
    except Exception, e:
      print("ERROR AUTO-UPDATING APP: {0}".format(e))
示例#3
0
    def collectNoise(self, seconds):
        """
        Collect noise data and update ``noiseData``.
        Uses the processes/threads started in :func:`startSnifferAndAdder`.

        :param seconds: Amount of seconds to capture noise

        :return: True if noise was captured. False if the user pressed "Cancel"
        """

        self.noiseData = []
        # Setup the ProgressDialog
        progressDialog = QProgressDialog(
            Strings.filterTabCollectingNoiseMessageBoxText, "Cancel", 0,
            seconds)

        progressDialog.setMinimumDuration(0)
        progressDialog.setMinimum(0)
        progressDialog.setMaximum(seconds)
        progressDialog.adjustSize()
        progressDialog.setFixedSize(progressDialog.width() + 40,
                                    progressDialog.height())

        # Users still can click on the "X"
        progressDialog.setCancelButton(None)

        # Start collecting
        self.startSnifferAndAdder(adderMethod=self.addSniffedNoise)

        progressDialog.open()

        secondsToCollect = seconds
        while secondsToCollect > 0 and not progressDialog.wasCanceled():
            time.sleep(0.5)
            secondsToCollect -= 0.5
            self.updateNoiseCollectProgress(progressDialog,
                                            seconds - secondsToCollect)

        self.stopSnifferAndAdder()
        return not progressDialog.wasCanceled()