Пример #1
0
    def __init__(self, parent=None, window_flags=None):
        QMainWindow.__init__(self, parent)
        if window_flags:
            self.setWindowFlags(window_flags)
        self.ui = load_ui(__file__, 'converter.ui', baseinstance=self)
        self.ui.InputVal.setValidator(QDoubleValidator(self.ui.InputVal))
        self.ui.totalFlightPathInput.setValidator(
            QDoubleValidator(self.ui.totalFlightPathInput))
        self.ui.scatteringAngleInput.setValidator(
            QDoubleValidator(self.ui.scatteringAngleInput))
        self.ui.convertButton.clicked.connect(self.convert)
        self.ui.helpButton.clicked.connect(self.helpClicked)
        self.ui.inputUnits.currentIndexChanged.connect(
            self.setInstrumentInputs)
        self.ui.outputUnits.currentIndexChanged.connect(
            self.setInstrumentInputs)
        self.setInstrumentInputs()

        ##defaults
        self.flightpath = -1.0
        self.Theta = -1.0
        self.output = 0.0

        #help
        self.assistant_process = QtCore.QProcess(self)
        # pylint: disable=protected-access
        self.mantidplot_name = 'TOF Converter'

        try:
            import mantid
            #register startup
            mantid.UsageService.registerFeatureUsage(
                mantid.kernel.FeatureType.Interface, "TofConverter", False)
        except ImportError:
            pass
Пример #2
0
    def __init__(self, parent=None):
        QMainWindow.__init__(self,parent)
        self.ui = load_ui(__file__, 'converter.ui', baseinstance=self)
        self.ui.InputVal.setValidator(QDoubleValidator(self.ui.InputVal))
        self.ui.totalFlightPathInput.setValidator(QDoubleValidator(self.ui.totalFlightPathInput))
        self.ui.scatteringAngleInput.setValidator(QDoubleValidator(self.ui.scatteringAngleInput))
        self.ui.convertButton.clicked.connect(self.convert)
        self.ui.helpButton.clicked.connect(self.helpClicked)
        self.ui.inputUnits.currentIndexChanged.connect(self.setInstrumentInputs)
        self.ui.outputUnits.currentIndexChanged.connect(self.setInstrumentInputs)
        self.setInstrumentInputs()

        ##defaults
        self.flightpath = -1.0
        self.Theta = -1.0
        self.output = 0.0

        #help
        self.assistant_process = QtCore.QProcess(self)
        # pylint: disable=protected-access
        import mantid
        self.mantidplot_name='TOF Converter'
        self.collection_file = os.path.join(mantid._bindir, '../docs/qthelp/MantidProject.qhc')
        version = ".".join(mantid.__version__.split(".")[:2])
        self.qt_url = 'qthelp://org.sphinx.mantidproject.' + version + '/doc/interfaces/TOF Converter.html'
        self.external_url = 'http://docs.mantidproject.org/nightly/interfaces/TOF Converter.html'

        try:
            import mantid
            #register startup
            mantid.UsageService.registerFeatureUsage("Interface","TofConverter",False)
        except ImportError:
            pass
Пример #3
0
    def startAssistant(self):
        if not self.proc:
            self.proc = QtCore.QProcess()

        if self.proc.state() != QtCore.QProcess.Running:
            app = QtCore.QLibraryInfo.location(
                QtCore.QLibraryInfo.BinariesPath)
            app += QtCore.QDir.separator()
            if sys.platform == 'darwin':
                app += QtCore.QLatin1String(
                    'Assistant.app/Contents/MacOS/Assistant')
            else:
                app += QtCore.QLatin1String('assistant')

            args = [
                QtCore.QLatin1String('-collectionFile'),
                QtCore.QLatin1String('path to .qhc'),
                QtCore.QLatin1String('-enableRemoteControl'),
            ]

            self.proc.start(app, args)

            if not self.proc.waitForStarted():
                if QtWidgets.aApp is not None:
                    tr = QtWidgets.qApp.tr
                else:
                    tr = str
                QtWidgets.QMessageBox.critical(
                    0, tr('Simple Text Viewer'),
                    tr('Unable to launch Qt Assistant (%s)') % app)
                return False

        return True
Пример #4
0
def mqtt_connection(request):
    broker_location = os.path.join(
        request.config.rootdir, "internals/paho.mqtt.testing/interoperability/startbroker.py",
    )
    broker_process = QtCore.QProcess()
    python_path = sys.executable
    arguments = [broker_location]
    configuration = "localhost_testing.conf"
    broker_dir = QtCore.QFileInfo(broker_location).absoluteDir()
    if broker_dir.exists(configuration):
        arguments += [
            "-c",
            QtCore.QDir.toNativeSeparators(broker_dir.absoluteFilePath(configuration)),
        ]
        broker_process.setWorkingDirectory(broker_dir.absolutePath())
    broker_process.start(python_path, arguments)
    if not broker_process.waitForStarted():
        raise Exception("Could not start MQTT test broker.")

    max_tries = 6

    for try_counter in range(max_tries):
        socket = QtNetwork.QTcpSocket()
        socket.connectToHost("localhost", 1883)

        if socket.waitForConnected(3000):
            yield "localhost"
            break
        loop = QtCore.QEventLoop()
        QtCore.QTimer.singleShot(5000, loop.quit)
        loop.exec_()
    print("Could not launch MQTT test broker.")
Пример #5
0
def reveal(path):
    proc = QtCore.QProcess()
    if sys.platform.startswith("darwin"):
        proc.startDetached("open", ["--", path])
    elif sys.platform.startswith("linux"):
        proc.startDetached("xdg-open", ["--", path])
    elif sys.platform.startswith("win32"):
        proc.startDetached("explorer", [path.replace("/", "\\")])
Пример #6
0
    def __init__(self, logger=None, parent=None, **kwargs):
        QtCore.QObject.__init__(self, parent, **kwargs)
        BaseToolController.__init__(self, logger)
        self.subprocess = QtCore.QProcess(parent)
        self.subprocess.setProcessChannelMode(QtCore.QProcess.MergedChannels)

        # connect process handlers and I/O handlers
        self.subprocess.readyReadStandardOutput.connect(self.handle_stdout)
        self.subprocess.readyReadStandardError.connect(self.handle_stderr)
        self.subprocess.error.connect(self.handle_error)
        self.subprocess.finished.connect(self.finalize_run)
Пример #7
0
 def __init__(self, parent=None):
     super(SampleTransmissionCalculatorView, self).__init__(parent)
     self.setupUi(self)
     fig = Figure()
     self.axes = fig.add_subplot(111)
     self.plot_frame = FigureCanvas(fig)
     self.output_layout.replaceWidget(self.placeholder_widget,
                                      self.plot_frame)
     self.assistant_process = QtCore.QProcess(self)
     self.validation_label.setStyleSheet("QLabel { color : red; }")
     self.histogram_err.setStyleSheet("QLabel { color : red; }")
     self.chemical_formula_err.setStyleSheet("QLabel { color : red; }")
     self.density_err.setStyleSheet("QLabel { color : red; }")
     self.thickness_err.setStyleSheet("QLabel { color : red; }")
Пример #8
0
    def __init__(self, title, parent=None):
        standard.Dialog.__init__(self, parent)
        self.setWindowTitle(title)
        if parent is not None:
            self.setWindowModality(Qt.ApplicationModal)

        # Construct the process
        self.proc = QtCore.QProcess(self)
        self.exitstatus = 0
        self.out = ''
        self.err = ''
        self.command = []

        # Create the text browser
        self.output_text = QtWidgets.QTextBrowser(self)
        self.output_text.setAcceptDrops(False)
        self.output_text.setTabChangesFocus(True)
        self.output_text.setUndoRedoEnabled(False)
        self.output_text.setReadOnly(True)
        self.output_text.setAcceptRichText(False)

        # Create abort / close buttons
        # Start with abort disabled - will be enabled when the process is run.
        self.button_abort = qtutils.create_button(text=N_('Abort'),
                                                  enabled=False)
        self.button_close = qtutils.close_button()

        # Put them in a horizontal layout at the bottom.
        self.button_box = QtWidgets.QDialogButtonBox(self)
        self.button_box.addButton(self.button_abort,
                                  QtWidgets.QDialogButtonBox.RejectRole)
        self.button_box.addButton(self.button_close,
                                  QtWidgets.QDialogButtonBox.AcceptRole)

        # Connect the signals to the process
        # pylint: disable=no-member
        self.proc.readyReadStandardOutput.connect(self.read_stdout)
        self.proc.readyReadStandardError.connect(self.read_stderr)
        self.proc.finished.connect(self.proc_finished)
        self.proc.stateChanged.connect(self.proc_state_changed)

        qtutils.connect_button(self.button_abort, self.abort)
        qtutils.connect_button(self.button_close, self.close)

        self._layout = qtutils.vbox(defs.margin, defs.spacing,
                                    self.output_text, self.button_box)
        self.setLayout(self._layout)

        self.resize(720, 420)
Пример #9
0
    def __init__(self, binary, args, env=None, wid=1, **kwargs):
        super(SubprocessWorker, self).__init__()
        self.id = int(wid)
        self.binary = mosaicpy.util.which(binary)
        if not binary:
            raise err.MissingBinaryError(
                "Binary not found or not executable: {}".format(self.binary))
        self.args = args
        self.env = env
        self.polling_interval = 100
        self.name = "Subprocess"
        self.__abort = False
        self._logger = logging.getLogger("mosaicpy.worker." +
                                         type(self).__name__)

        self.process = QtCore.QProcess(self)
        self.process.readyReadStandardOutput.connect(self.procReadyRead)
        self.process.readyReadStandardError.connect(self.procErrorRead)
Пример #10
0
    def validate(self):
        """
        Run, pre generation script and provide information on finished.
        """
        if self._pre_gen_code is not None:
            cookiecutter_settings = self.get_values()
            template = Template(self._pre_gen_code)
            val = template.render(cookiecutter=Namespace(
                **cookiecutter_settings))

            with open(self._tempfile, "w") as fh:
                fh.write(val)

            if self._process is not None:
                self._process.terminate()

            self._process = QtCore.QProcess()
            self._process.setProgram(sys.executable)
            self._process.setArguments([self._tempfile])
            self._process.finished.connect(self._on_process_finished)
            self._process.start()
Пример #11
0
    def __init__(self):
        super(LogViewWidget, self).__init__()

        self.resize(754, 904 - 29)
        self.DATA_SOURCE_FLAG = None

        # QProcess object for external app
        self.process = QtCore.QProcess(self)
        # print('Process created')
        # QProcess emits `readyRead` when there is data to be read
        self.process.readyRead.connect(self.dataReady)
        # print('Process connected')

        self.btn_save_logs.setText('Send to pastebin')

        self.btn_connect_android.pressed.connect(self.get_logs_from_android)
        self.btn_connect_ios.pressed.connect(self.get_logs_from_ios)
        self.btn_save_logs.pressed.connect(self.pastebin_send_logs)

        timer = QtCore.QTimer(self)
        timer.timeout.connect(self.update_time)
        # self.connect(timer, SIGNAL("timeout()"), self.update)
        timer.start(100)
Пример #12
0
    def initUI(self):
        # Layout are better for placing widgets
        layout = QtWidgets.QHBoxLayout()
        self.runButton = QtWidgets.QPushButton('Run')
        self.runButton.clicked.connect(self.callProgram)

        self.output = QtWidgets.QTextEdit()

        layout.addWidget(self.output)
        layout.addWidget(self.runButton)

        centralWidget = QtWidgets.QWidget()
        centralWidget.setLayout(layout)
        self.setCentralWidget(centralWidget)

        # QProcess object for external app
        self.process = QtCore.QProcess(self)
        # QProcess emits `readyRead` when there is data to be read
        self.process.readyRead.connect(self.dataReady)

        # Just to prevent accidentally running multiple times
        # Disable the button when process starts, and enable it when it finishes
        self.process.started.connect(lambda: self.runButton.setEnabled(False))
        self.process.finished.connect(lambda: self.runButton.setEnabled(True))
Пример #13
0
    def __init__(self, ol=None, parent=None):
        # pylint: disable=unused-argument,super-on-old-class
        super(DGSPlannerGUI, self).__init__(parent)
        # OrientedLattice
        if ValidateOL(ol):
            self.ol = ol
        else:
            self.ol = mantid.geometry.OrientedLattice()
        self.masterDict = dict()  # holds info about instrument and ranges
        self.updatedInstrument = False
        self.updatedOL = False
        self.wg = None  # workspace group
        self.instrumentWidget = InstrumentSetupWidget.InstrumentSetupWidget(self)
        self.setLayout(QtWidgets.QHBoxLayout())
        controlLayout = QtWidgets.QVBoxLayout()
        controlLayout.addWidget(self.instrumentWidget)
        self.ublayout = QtWidgets.QHBoxLayout()
        self.classic = ClassicUBInputWidget.ClassicUBInputWidget(self.ol)
        self.ublayout.addWidget(self.classic, alignment=QtCore.Qt.AlignTop, stretch=1)
        self.matrix = MatrixUBInputWidget.MatrixUBInputWidget(self.ol)
        self.ublayout.addWidget(self.matrix, alignment=QtCore.Qt.AlignTop, stretch=1)
        controlLayout.addLayout(self.ublayout)
        self.dimensionWidget = DimensionSelectorWidget.DimensionSelectorWidget(self)
        controlLayout.addWidget(self.dimensionWidget)
        plotControlLayout = QtWidgets.QGridLayout()
        self.plotButton = QtWidgets.QPushButton("Plot", self)
        self.oplotButton = QtWidgets.QPushButton("Overplot", self)
        self.helpButton = QtWidgets.QPushButton("?", self)
        self.colorLabel = QtWidgets.QLabel('Color by angle', self)
        self.colorButton = QtWidgets.QCheckBox(self)
        self.colorButton.toggle()
        self.aspectLabel = QtWidgets.QLabel('Aspect ratio 1:1', self)
        self.aspectButton = QtWidgets.QCheckBox(self)
        self.saveButton = QtWidgets.QPushButton("Save Figure", self)
        plotControlLayout.addWidget(self.plotButton, 0, 0)
        plotControlLayout.addWidget(self.oplotButton, 0, 1)
        plotControlLayout.addWidget(self.colorLabel, 0, 2, QtCore.Qt.AlignRight)
        plotControlLayout.addWidget(self.colorButton, 0, 3)
        plotControlLayout.addWidget(self.aspectLabel, 0, 4, QtCore.Qt.AlignRight)
        plotControlLayout.addWidget(self.aspectButton, 0, 5)
        plotControlLayout.addWidget(self.helpButton, 0, 6)
        plotControlLayout.addWidget(self.saveButton, 0, 7)
        controlLayout.addLayout(plotControlLayout)
        self.layout().addLayout(controlLayout)

        # figure
        self.figure = Figure()
        self.figure.patch.set_facecolor('white')
        self.canvas = FigureCanvas(self.figure)
        self.grid_helper = GridHelperCurveLinear((self.tr, self.inv_tr))
        self.trajfig = Subplot(self.figure, 1, 1, 1, grid_helper=self.grid_helper)
        if matplotlib.compare_versions('2.1.0',matplotlib.__version__):
            self.trajfig.hold(True) # hold is deprecated since 2.1.0, true by default
        self.figure.add_subplot(self.trajfig)
        self.toolbar = CustomNavigationToolbar(self.canvas, self)
        figureLayout = QtWidgets.QVBoxLayout()
        figureLayout.addWidget(self.toolbar,0)
        figureLayout.addWidget(self.canvas,1)
        self.layout().addLayout(figureLayout)
        self.needToClear = False
        self.saveDir = ''

        # connections
        self.matrix.UBmodel.changed.connect(self.updateUB)
        self.matrix.UBmodel.changed.connect(self.classic.updateOL)
        self.classic.changed.connect(self.matrix.UBmodel.updateOL)
        self.classic.changed.connect(self.updateUB)
        self.instrumentWidget.changed.connect(self.updateParams)
        self.dimensionWidget.changed.connect(self.updateParams)
        self.plotButton.clicked.connect(self.updateFigure)
        self.oplotButton.clicked.connect(self.updateFigure)
        self.helpButton.clicked.connect(self.help)
        self.saveButton.clicked.connect(self.save)
        # force an update of values
        self.instrumentWidget.updateAll()
        self.dimensionWidget.updateChanges()
        # help
        self.assistant_process = QtCore.QProcess(self)
        # pylint: disable=protected-access
        self.mantidplot_name='DGS Planner'
        self.collection_file = os.path.join(mantid._bindir, '../docs/qthelp/MantidProject.qhc')
        version = ".".join(mantid.__version__.split(".")[:2])
        self.qt_url = 'qthelp://org.sphinx.mantidproject.' + version + '/doc/interfaces/DGS Planner.html'
        self.external_url = 'http://docs.mantidproject.org/nightly/interfaces/DGS Planner.html'
        # control for cancel button
        self.iterations = 0
        self.progress_canceled = False

        # register startup
        mantid.UsageService.registerFeatureUsage("Interface", "DGSPlanner", False)
Пример #14
0
    def __init__(self, parent=None, window_flags=None, ol=None):
        # pylint: disable=unused-argument,super-on-old-class
        super(DGSPlannerGUI, self).__init__(parent)
        if window_flags:
            self.setWindowFlags(window_flags)
        # OrientedLattice
        if ValidateOL(ol):
            self.ol = ol
        else:
            self.ol = mantid.geometry.OrientedLattice()
        self.masterDict = dict()  # holds info about instrument and ranges
        self.updatedInstrument = False
        self.instrumentWAND = False
        self.updatedOL = False
        self.wg = None  # workspace group
        self.instrumentWidget = InstrumentSetupWidget.InstrumentSetupWidget(
            self)
        self.setLayout(QtWidgets.QHBoxLayout())
        controlLayout = QtWidgets.QVBoxLayout()
        geometryBox = QtWidgets.QGroupBox("Instrument Geometry")
        plotBox = QtWidgets.QGroupBox("Plot Axes")
        geometryBoxLayout = QtWidgets.QVBoxLayout()
        geometryBoxLayout.addWidget(self.instrumentWidget)
        geometryBox.setLayout(geometryBoxLayout)
        controlLayout.addWidget(geometryBox)
        self.ublayout = QtWidgets.QHBoxLayout()
        self.classic = ClassicUBInputWidget.ClassicUBInputWidget(self.ol)
        self.ublayout.addWidget(self.classic,
                                alignment=QtCore.Qt.AlignTop,
                                stretch=1)
        self.matrix = MatrixUBInputWidget.MatrixUBInputWidget(self.ol)
        self.ublayout.addWidget(self.matrix,
                                alignment=QtCore.Qt.AlignTop,
                                stretch=1)
        sampleBox = QtWidgets.QGroupBox("Sample")
        sampleBox.setLayout(self.ublayout)
        controlLayout.addWidget(sampleBox)
        self.dimensionWidget = DimensionSelectorWidget.DimensionSelectorWidget(
            self)
        plotBoxLayout = QtWidgets.QVBoxLayout()
        plotBoxLayout.addWidget(self.dimensionWidget)
        plotControlLayout = QtWidgets.QGridLayout()
        self.plotButton = QtWidgets.QPushButton("Plot", self)
        self.oplotButton = QtWidgets.QPushButton("Overplot", self)
        self.helpButton = QtWidgets.QPushButton("?", self)
        self.colorLabel = QtWidgets.QLabel('Color by angle', self)
        self.colorButton = QtWidgets.QCheckBox(self)
        self.colorButton.toggle()
        self.aspectLabel = QtWidgets.QLabel('Aspect ratio 1:1', self)
        self.aspectButton = QtWidgets.QCheckBox(self)
        self.saveButton = QtWidgets.QPushButton("Save Figure", self)
        plotControlLayout.addWidget(self.plotButton, 0, 0)
        plotControlLayout.addWidget(self.oplotButton, 0, 1)
        plotControlLayout.addWidget(self.colorLabel, 0, 2,
                                    QtCore.Qt.AlignRight)
        plotControlLayout.addWidget(self.colorButton, 0, 3)
        plotControlLayout.addWidget(self.aspectLabel, 0, 4,
                                    QtCore.Qt.AlignRight)
        plotControlLayout.addWidget(self.aspectButton, 0, 5)
        plotControlLayout.addWidget(self.helpButton, 0, 6)
        plotControlLayout.addWidget(self.saveButton, 0, 7)
        plotBoxLayout.addLayout(plotControlLayout)
        plotBox = QtWidgets.QGroupBox("Plot Axes")
        plotBox.setLayout(plotBoxLayout)
        controlLayout.addWidget(plotBox)
        self.layout().addLayout(controlLayout)

        # figure
        self.figure = Figure()
        self.figure.patch.set_facecolor('white')
        self.canvas = FigureCanvas(self.figure)
        self.grid_helper = GridHelperCurveLinear((self.tr, self.inv_tr))
        self.trajfig = Subplot(self.figure,
                               1,
                               1,
                               1,
                               grid_helper=self.grid_helper)
        if matplotlib.compare_versions('2.1.0', matplotlib.__version__):
            self.trajfig.hold(
                True)  # hold is deprecated since 2.1.0, true by default
        self.figure.add_subplot(self.trajfig)
        self.toolbar = MantidNavigationToolbar(self.canvas, self)
        figureLayout = QtWidgets.QVBoxLayout()
        figureLayout.addWidget(self.toolbar, 0)
        figureLayout.addWidget(self.canvas, 1)
        self.layout().addLayout(figureLayout)
        self.needToClear = False
        self.saveDir = ''

        # connections
        self.matrix.UBmodel.changed.connect(self.updateUB)
        self.matrix.UBmodel.changed.connect(self.classic.updateOL)
        self.classic.changed.connect(self.matrix.UBmodel.updateOL)
        self.classic.changed.connect(self.updateUB)
        self.instrumentWidget.changed.connect(self.updateParams)
        self.instrumentWidget.getInstrumentComboBox().activated[str].connect(
            self.instrumentUpdateEvent)
        self.instrumentWidget.getEditEi().textChanged.connect(
            self.eiWavelengthUpdateEvent)
        self.dimensionWidget.changed.connect(self.updateParams)
        self.plotButton.clicked.connect(self.updateFigure)
        self.oplotButton.clicked.connect(self.updateFigure)
        self.helpButton.clicked.connect(self.help)
        self.saveButton.clicked.connect(self.save)
        # force an update of values
        self.instrumentWidget.updateAll()
        self.dimensionWidget.updateChanges()
        # help
        self.assistant_process = QtCore.QProcess(self)
        # pylint: disable=protected-access
        self.mantidplot_name = 'DGS Planner'
        # control for cancel button
        self.iterations = 0
        self.progress_canceled = False

        # register startup
        mantid.UsageService.registerFeatureUsage(
            mantid.kernel.FeatureType.Interface, "DGSPlanner", False)
Пример #15
0
    def __init__(self, appName, x86, argTemplate, account, server, ticket,
                 chatServer, language, runDir, wineProgram, wineDebug,
                 winePrefix, hiResEnabled, wineApp, osType, homeDir,
                 iconFileIn, rootDir, crashreceiver, DefaultUploadThrottleMbps,
                 bugurl, authserverurl, supporturl, supportserviceurl,
                 glsticketlifetime, realmName, accountText, parent):

        #Fixes binary path for 64-bit client
        if x86:
            appName = ("x64" + os.sep + appName)

        self.homeDir = homeDir
        self.winLog = QtWidgets.QDialog()
        self.osType = osType
        self.realmName = realmName
        self.accountText = accountText
        self.parent = parent

        uifile = resource_filename(__name__, 'ui' + os.sep + 'winLog.ui')

        self.winLog = QtWidgets.QDialog(parent, QtCore.Qt.FramelessWindowHint)
        Ui_winLog, base_class = uic.loadUiType(uifile)
        self.uiLog = Ui_winLog()
        self.uiLog.setupUi(self.winLog)

        if self.osType.usingWindows:
            self.winLog.setWindowTitle("Output")
        else:
            if wineApp == "Wine":
                self.winLog.setWindowTitle("Launch Game - Wine output")
            else:
                self.winLog.setWindowTitle("Launch Game - Crossover output")

        # self.uiLog.btnStart.setVisible(False)
        self.uiLog.btnStart.setText("Launcher")
        self.uiLog.btnStart.setEnabled(False)
        self.uiLog.btnSave.setText("Save")
        self.uiLog.btnSave.setEnabled(False)
        self.uiLog.btnStop.setText("Exit")
        self.uiLog.btnStart.clicked.connect(self.btnStartClicked)
        self.uiLog.btnSave.clicked.connect(self.btnSaveClicked)
        self.uiLog.btnStop.clicked.connect(self.btnStopClicked)

        self.aborted = False
        self.finished = False
        self.command = ""
        self.arguments = []

        gameParams = argTemplate.replace("{SUBSCRIPTION}", account).replace("{LOGIN}", server)\
            .replace("{GLS}", ticket).replace("{CHAT}", chatServer).replace("{LANG}", language)\
            .replace("{CRASHRECEIVER}", crashreceiver).replace("{UPLOADTHROTTLE}", DefaultUploadThrottleMbps)\
            .replace("{BUGURL}", bugurl).replace("{AUTHSERVERURL}", authserverurl)\
            .replace("{GLSTICKETLIFETIME}", glsticketlifetime).replace("{SUPPORTURL}", supporturl)\
            .replace("{SUPPORTSERVICEURL}", supportserviceurl)

        if not hiResEnabled:
            gameParams = gameParams + " --HighResOutOfDate"

        if wineDebug != "":
            os.environ["WINEDEBUG"] = wineDebug

        if winePrefix != "" and wineApp == "Wine":
            os.environ["WINEPREFIX"] = winePrefix

        self.process = QtCore.QProcess()
        self.process.readyReadStandardOutput.connect(self.readOutput)
        self.process.readyReadStandardError.connect(self.readErrors)
        self.process.finished.connect(self.resetButtons)

        if wineApp == "Native":
            self.command = appName
            self.process.setWorkingDirectory(runDir)

            os.chdir(runDir)

            for arg in gameParams.split(" "):
                self.arguments.append(arg)

        elif wineApp == "Wine":
            self.command = wineProgram
            self.process.setWorkingDirectory(runDir)

            self.arguments.append(appName)

            for arg in gameParams.split(" "):
                self.arguments.append(arg)

        elif wineApp == "CXGames":
            if not self.osType.startCXG():
                self.uiLog.txtLog.append(
                    "<b>Error: Couldn't start Crossover Games</b>")
                self.uiLog.btnSave.setEnabled(False)
                self.uiLog.btnStart.setEnabled(False)

            if self.osType.macPathCX == "":
                tempFile = "%s%s%s" % (self.osType.globalDir,
                                       self.osType.directoryCXG, wineProgram)

                if os.path.isfile(tempFile):
                    self.command = tempFile
                else:
                    tempFile = "%s%s%s" % (homeDir, self.osType.directoryCXG,
                                           wineProgram)

                    if os.path.isfile(tempFile):
                        self.command = tempFile
                    else:
                        self.command = wineProgram
            else:
                self.command = "%s%s" % (self.osType.macPathCX, wineProgram)

            self.process.setWorkingDirectory(runDir)

            tempArg = "--bottle %s --verbose -- %s %s" % (winePrefix, appName,
                                                          gameParams)
            for arg in tempArg.split(" "):
                self.arguments.append(arg)
        elif wineApp == "CXOffice":
            if not self.osType.startCXO():
                self.uiLog.txtLog.append(
                    "<b>Error: Couldn't start Crossover</b>")
                self.uiLog.btnSave.setEnabled(False)
                self.uiLog.btnStart.setEnabled(False)

            if self.osType.macPathCX == "":
                tempFile = "%s%s%s" % (self.osType.globalDir,
                                       self.osType.directoryCXO, wineProgram)

                if os.path.isfile(tempFile):
                    self.command = tempFile
                else:
                    tempFile = "%s%s%s" % (homeDir, self.osType.directoryCXO,
                                           wineProgram)

                    if os.path.isfile(tempFile):
                        self.command = tempFile
                    else:
                        self.command = wineProgram
            else:
                self.command = "%s%s" % (self.osType.macPathCX, wineProgram)

            self.process.setWorkingDirectory(runDir)

            tempArg = "--bottle %s --verbose -- %s %s" % (winePrefix, appName,
                                                          gameParams)
            for arg in tempArg.split(" "):
                self.arguments.append(arg)

        self.uiLog.txtLog.append("Connecting to server: " + realmName)
        self.uiLog.txtLog.append("Account: " + accountText)
        self.uiLog.txtLog.append("Game Directory: " + runDir)
        self.uiLog.txtLog.append("Game Client: " + appName)
Пример #16
0
 def __init__(self, parent=None, window_flags=None):
     QtWidgets.QWidget.__init__(self, parent)
     if window_flags:
         self.setWindowFlags(window_flags)
     self.setWindowTitle("QECoverage")
     self.grid = QtWidgets.QVBoxLayout()
     self.setLayout(self.grid)
     self.mainframe = QtWidgets.QFrame(self)
     self.mainframe_grid = QtWidgets.QHBoxLayout()
     self.mainframe.setLayout(self.mainframe_grid)
     # Left panel - inputs
     self.tabs = QtWidgets.QTabWidget(self)
     #      Direct geometry spectrometer tab
     self.tab_direct = QtWidgets.QWidget(self.tabs)
     self.direct_grid = QtWidgets.QVBoxLayout()
     self.tab_direct.setLayout(self.direct_grid)
     self.direct_inst_list = ['LET', 'MAPS', 'MARI', 'MERLIN', 'ARCS', 'CHESS', 'CNCS', 'HYSPEC', 'SEQUOIA',
                              'IN4', 'IN5', 'IN6', 'FOCUS', 'MIBEMOL', 'DNS', 'TOFTOF']
     self.direct_inst_box = QtWidgets.QComboBox(self.tab_direct)
     for inst in self.direct_inst_list:
         self.direct_inst_box.addItem(inst)
     self.direct_grid.addWidget(self.direct_inst_box)
     self.direct_inst_box.activated[str].connect(self.onDirectInstActivated)
     self.direct_ei = QtWidgets.QFrame(self.tab_direct)
     self.direct_ei_grid = QtWidgets.QHBoxLayout()
     self.direct_ei.setLayout(self.direct_ei_grid)
     self.direct_ei_label = QtWidgets.QLabel("Ei", self.direct_ei)
     self.direct_ei_grid.addWidget(self.direct_ei_label)
     self.direct_ei_input = QtWidgets.QLineEdit("55", self.direct_ei)
     self.direct_ei_input.setToolTip("Incident Energy in meV")
     self.direct_ei_grid.addWidget(self.direct_ei_input)
     self.emptyfield_msgbox = QtWidgets.QMessageBox()
     self.emptyfield_msgbox.setText("Invalid input has been provided for Ei or Emin! Please try again")
     self.ei_msgbox = QtWidgets.QMessageBox()
     self.ei_msgbox.setText("Ei cannot be negative! Please try again")
     self.ei_emin_msgbox = QtWidgets.QMessageBox()
     self.ei_emin_msgbox.setText("Emin must be less than the values provided for Ei! Please try again")
     self.direct_grid.addWidget(self.direct_ei)
     self.emaxfield_msgbox = QtWidgets.QMessageBox()
     self.direct_plotover = QtWidgets.QCheckBox("Plot Over", self.tab_direct)
     self.direct_plotover.setToolTip("Hold this plot?")
     self.direct_grid.addWidget(self.direct_plotover)
     self.direct_plotover.stateChanged.connect(self.onDirectPlotOverChanged)
     self.direct_createws = QtWidgets.QCheckBox("Create Workspace", self.tab_direct)
     self.direct_createws.setToolTip("Create a Mantid workspace?")
     self.direct_grid.addWidget(self.direct_createws)
     self.direct_createws.stateChanged.connect(self.onDirectCreateWSChanged)
     self.direct_emin = QtWidgets.QFrame(self.tab_direct)
     self.direct_emin_grid = QtWidgets.QHBoxLayout()
     self.direct_emin.setLayout(self.direct_emin_grid)
     self.direct_emin_label = QtWidgets.QLabel("Emin", self.direct_emin)
     self.direct_emin_grid.addWidget(self.direct_emin_label)
     self.direct_emin_input = QtWidgets.QLineEdit("-10", self.direct_emin)
     self.direct_emin_input.setToolTip("Minimum energy transfer to plot down to.")
     self.direct_emin_grid.addWidget(self.direct_emin_input)
     self.direct_grid.addWidget(self.direct_emin)
     self.direct_plotbtn = QtWidgets.QPushButton("Plot Q-E", self.tab_direct)
     self.direct_grid.addWidget(self.direct_plotbtn)
     self.direct_plotbtn.clicked.connect(self.onClickDirectPlot)
     self.direct_s2 = QtWidgets.QFrame(self.tab_direct)
     self.direct_s2_grid = QtWidgets.QHBoxLayout()
     self.direct_s2.setLayout(self.direct_s2_grid)
     self.direct_s2_label = QtWidgets.QLabel("s2", self.direct_s2)
     self.direct_s2_grid.addWidget(self.direct_s2_label)
     self.direct_s2_input = QtWidgets.QLineEdit("30", self.direct_s2)
     self.direct_s2_input.setToolTip("Scattering angle of middle of the HYSPEC detector bank.")
     self.direct_s2_grid.addWidget(self.direct_s2_input)
     self.direct_s2_input.textChanged[str].connect(self.onS2Changed)
     self.direct_grid.addWidget(self.direct_s2)
     self.direct_s2.hide()
     self.direct_grid.addStretch(10)
     self.tabs.addTab(self.tab_direct, "Direct")
     self.tthlims = [2.65, 140]
     #      Indirect geometry spectrometer tab
     self.tab_indirect = QtWidgets.QWidget(self.tabs)
     self.indirect_grid = QtWidgets.QVBoxLayout()
     self.tab_indirect.setLayout(self.indirect_grid)
     self.indirect_inst_list = ['IRIS', 'OSIRIS', 'TOSCA', 'VESUVIO', 'BASIS', 'VISION']
     self.indirect_inst_box = QtWidgets.QComboBox(self.tab_indirect)
     for inst in self.indirect_inst_list:
         self.indirect_inst_box.addItem(inst)
     self.indirect_grid.addWidget(self.indirect_inst_box)
     self.indirect_inst_box.activated[str].connect(self.onIndirectInstActivated)
     self.indirect_ef = QtWidgets.QFrame(self.tab_indirect)
     self.indirect_ef_grid = QtWidgets.QHBoxLayout()
     self.indirect_ef.setLayout(self.indirect_ef_grid)
     self.indirect_ef_label = QtWidgets.QLabel("Ef", self.indirect_ef)
     self.indirect_ef_grid.addWidget(self.indirect_ef_label)
     self.indirect_ef_input = QtWidgets.QComboBox(self.indirect_ef)
     self.indirect_analysers = \
         {'IRIS': {'PG002': 1.84, 'PG004': 7.38, 'Mica002': 0.207, 'Mica004': 0.826, 'Mica006': 1.86},
          'OSIRIS': {'PG002': 1.84, 'PG004': 7.38},
          # Assuming the PG analysers scatter through 90deg (theta=45deg)
          'TOSCA': {'PG002': 3.634},
          'VESUVIO': {'AuFoil': 4897},
          'BASIS': {'Si111': 2.08, 'Si311': 7.64},
          # From IDF - implies analyser scattering angle is 90deg
          'VISION': {'PG002': 3.64}}
     for ana in self.indirect_analysers[str(self.indirect_inst_box.currentText())]:
         self.indirect_ef_input.addItem(ana)
     self.indirect_ef_grid.addWidget(self.indirect_ef_input)
     self.indirect_ef_input.activated[str].connect(self.onIndirectEfActivated)
     self.indirect_grid.addWidget(self.indirect_ef)
     self.indirect_plotover = QtWidgets.QCheckBox("Plot Over", self.tab_indirect)
     self.indirect_plotover.setToolTip("Hold this plot?")
     self.indirect_grid.addWidget(self.indirect_plotover)
     self.indirect_plotover.stateChanged.connect(self.onIndirectPlotOverChanged)
     self.indirect_createws = QtWidgets.QCheckBox("Create Workspace", self.tab_indirect)
     self.indirect_createws.setToolTip("Create a Mantid workspace?")
     self.indirect_grid.addWidget(self.indirect_createws)
     self.indirect_createws.stateChanged.connect(self.onIndirectCreateWSChanged)
     self.indirect_emax = QtWidgets.QFrame(self.tab_direct)
     self.indirect_emax = QtWidgets.QFrame(self.tab_indirect)
     self.indirect_emax_grid = QtWidgets.QHBoxLayout()
     self.indirect_emax.setLayout(self.indirect_emax_grid)
     self.indirect_emax_label = QtWidgets.QLabel("Emax", self.indirect_emax)
     self.indirect_emax_grid.addWidget(self.indirect_emax_label)
     self.indirect_emax_input = QtWidgets.QLineEdit("10", self.indirect_emax)
     self.indirect_emax_input.setToolTip("Max energy loss to plot up to.")
     self.indirect_emax_grid.addWidget(self.indirect_emax_input)
     self.indirect_grid.addWidget(self.indirect_emax)
     self.indirect_plotbtn = QtWidgets.QPushButton("Plot Q-E", self.tab_indirect)
     self.indirect_grid.addWidget(self.indirect_plotbtn)
     self.indirect_plotbtn.clicked.connect(self.onClickIndirectPlot)
     self.indirect_grid.addStretch(10)
     self.tabs.addTab(self.tab_indirect, "Indirect")
     self.mainframe_grid.addWidget(self.tabs)
     self.tabs.currentChanged.connect(self.onTabChange)
     # Right panel, matplotlib figure to show Q-E
     self.figure_frame = QtWidgets.QFrame(self.mainframe)
     self.figure_grid = QtWidgets.QVBoxLayout()
     self.figure_frame.setLayout(self.figure_grid)
     self.figure = Figure()
     self.figure.patch.set_facecolor('white')
     self.canvas = FigureCanvas(self.figure)
     self.axes = self.figure.add_subplot(111)
     self.axes.axhline(color='k')
     self.axes.set_xlabel(r'$|Q|$ ($\AA^{-1}$)')
     self.axes.set_ylabel('Energy Transfer (meV)')
     self.canvas.draw()
     self.mainframe_grid.addWidget(self.canvas)
     self.figure_grid.addWidget(self.canvas)
     self.figure_controls = NavigationToolbar2QT(self.canvas, self.figure_frame)
     self.figure_grid.addWidget(self.figure_controls)
     self.mainframe_grid.addWidget(self.figure_frame)
     self.grid.addWidget(self.mainframe)
     self.helpbtn = QtWidgets.QPushButton("?", self)
     self.helpbtn.setMaximumWidth(30)
     self.helpbtn.clicked.connect(self.onHelp)
     self.grid.addWidget(self.helpbtn)
     # Matplotlib does seem to rescale x-axis properly after axes.clear()
     self.xlim = 0
     #help
     self.assistant_process = QtCore.QProcess(self)
     # pylint: disable=protected-access
     self.mantidplot_name='QE Coverage'
     #register startup
     mantid.UsageService.registerFeatureUsage(mantid.kernel.FeatureType.Interface,"QECoverage",False)
Пример #17
0
    def startCXO(self):
        finished = True

        if self.usingMac:
            uid = os.getuid()
            tempfile = subprocess.Popen(
                "ps -ocomm -U%s" % (uid), shell=True, stdout=subprocess.PIPE).stdout
            cxPath = ""
            for line in tempfile.readlines():
                line = line.strip()
                if line.endswith("CrossOver"):
                    cxPath = line

            if cxPath == "":
                process = QtCore.QProcess()
                process.start("open", ["-b", "com.codeweavers.CrossOver"])
                finished = process.waitForFinished()
                if finished:
                    tempfile = subprocess.Popen(
                        "ps -ocomm -U%s" % (uid), shell=True, stdout=subprocess.PIPE).stdout
                    cxPath = ""
                    for line in tempfile.readlines():
                        line = line.strip()
                        if line.endswith("CrossOver"):
                            cxPath = line
                else:
                    process.close()

            if finished:
                lineout = ""

                lines = cxPath.split("/")
                for line in lines[0:len(lines) - 3]:
                    lineout += "%s/" % (line)

                cxPath = lineout

                path = os.environ.get('PATH')

                os.environ["CX_ROOT"] = "%s/Contents/SharedSupport/CrossOver" % (
                    cxPath)
                os.environ["FONT_ENCODINGS_DIRECTORY"] = (cxPath + "/Contents/SharedSupport/X11/lib/" +
                                                          "X11/fonts/encodings/encodings.dir")
                os.environ["FONTCONFIG_ROOT"] = "%s/Contents/SharedSupport/X11" % (
                    cxPath)
                os.environ["COMMAND_MODE"] = "legacy"
                os.environ["FONTCONFIG_PATH"] = "%s/Contents/SharedSupport/X11/etc/fonts" % (
                    cxPath)
                os.environ["DYLD_FALLBACK_LIBRARY_PATH"] = (cxPath + "/Contents/SharedSupport/X11/lib" +
                                                            ":" + os.environ.get('HOME') + "/lib:/usr/local/lib:/lib:/usr/lib")
                os.environ["PATH"] = (
                    path + ":" + cxPath + "/Contents/SharedSupport/CrossOver/bin")
                self.macPathCX = os.environ.get('CX_ROOT')

                tempfile = subprocess.Popen("defaults read com.coeweavers.CrossOver Display",
                                            shell=True, stdout=subprocess.PIPE).stdout
                display = tempfile.read().strip()
                if display == "":
                    display = "2"
                os.environ["DISPLAY"] = ":%s" % (display)

        return finished
Пример #18
0
    def __init__(self, cmdline, env, input_enabled=False,
                 success_msg=None, fail_msg=None,
                 **kwargs):
        super(Terminal, self).__init__(**kwargs)

        self.success_msg = success_msg or "Command finished"
        self.fail_msg = fail_msg or "Command failed"

        layout = QtWidgets.QVBoxLayout()
        self.text = QtWidgets.QTextEdit(readOnly=True)
        layout.addWidget(self.text)
        if input_enabled:
            self.input = QtWidgets.QLineEdit()
            self.input.returnPressed.connect(self._enter)
            layout.addWidget(self.input)
        else:
            self.input = None
        self.setLayout(layout)

        self.process = QtCore.QProcess(self)

        # Dodge py2app issues
        environ = QtCore.QProcessEnvironment.systemEnvironment()
        if environ.contains('PYTHONHOME'):
            environ.remove('PYTHONPATH')
            environ.remove('PYTHONHOME')
        if sys.platform == 'darwin':
            environ.insert(
                'PATH',
                (environ.value('PATH', '/usr/bin:/bin:/usr/sbin:/sbin') +
                 ':/usr/local/bin:/opt/reprounzip'))

        # Unset TERM to avoid ansi escapes
        environ.remove('TERM')

        # Add additional environment variables
        for k, v in env.items():
            environ.insert(k, v)

        logger.info("Running in builtin Qt terminal: %r", cmdline)

        self.process.setProcessEnvironment(environ)
        self.process.setProcessChannelMode(QtCore.QProcess.SeparateChannels)
        if input_enabled:
            mode = QtCore.QIODevice.ReadWrite
        else:
            mode = QtCore.QIODevice.ReadOnly
        self.process.start(cmdline[0], cmdline[1:], mode)
        if not input_enabled:
            self.process.closeWriteChannel()
        self.process.readyReadStandardOutput.connect(self._read_stdout)
        self.process.readyReadStandardError.connect(self._read_stderr)
        self.process.finished.connect(self._finished)
        self.text.setHtml('''\
<style>
body {
    font: Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

.err {
    color: red;
}
</style>
''')
        self.text.append('<span style="color: blue;">%s</span>' %
                         cgi.escape(' '.join(cmdline)))
Пример #19
0
    def __init__(self, urlPatchServer, prodCode, language, runDir, patchClient,
                 wineProgram, hiResEnabled, iconFileIn, homeDir, winePrefix,
                 wineApp, osType, rootDir, parent):

        self.homeDir = homeDir
        self.winLog = QtWidgets.QDialog()
        self.osType = osType

        self.winLog = QtWidgets.QDialog(parent, QtCore.Qt.FramelessWindowHint)

        uifile = resource_filename(__name__, 'ui' + os.sep + 'winPatch.ui')
        Ui_winLog, base_class = uic.loadUiType(uifile)
        self.uiLog = Ui_winLog()
        self.uiLog.setupUi(self.winLog)

        if self.osType.usingWindows:
            self.winLog.setWindowTitle("Output")
        else:
            if wineApp == "Wine":
                self.winLog.setWindowTitle("Patch - Wine output")
            else:
                self.winLog.setWindowTitle("Patch - Crossover output")

        self.uiLog.btnSave.setText("Save Log")
        self.uiLog.btnSave.setEnabled(False)
        self.uiLog.progressBar.reset()
        self.uiLog.btnStop.setText("Launcher")
        self.uiLog.btnStart.setText("Patch")
        self.uiLog.btnSave.clicked.connect(self.btnSaveClicked)
        self.uiLog.btnStop.clicked.connect(self.btnStopClicked)
        self.uiLog.btnStart.clicked.connect(self.btnStartClicked)

        self.aborted = False
        self.finished = True
        self.lastRun = False
        self.command = ""
        self.arguments = []

        self.progressMonitor = ProgressMonitor(self.uiLog)

        if winePrefix != "" and wineApp == "Wine":
            os.environ["WINEPREFIX"] = winePrefix

        self.process = QtCore.QProcess()
        self.process.readyReadStandardOutput.connect(self.readOutput)
        self.process.readyReadStandardError.connect(self.readErrors)
        self.process.finished.connect(self.processFinished)

        if wineApp == "Native":
            patchParams = "%s,Patch %s --language %s --productcode %s" % (
                patchClient, urlPatchServer, language, prodCode)

            if hiResEnabled:
                patchParams = patchParams + " --highres"

            self.command = "rundll32.exe"
            self.process.setWorkingDirectory(runDir)

            for arg in patchParams.split(" "):
                self.arguments.append(arg)

        elif wineApp == "Wine":
            patchParams = "rundll32.exe %s,Patch %s --language %s --productcode %s" % (
                patchClient, urlPatchServer, language, prodCode)

            if hiResEnabled:
                patchParams = patchParams + " --highres"

            self.command = wineProgram
            self.process.setWorkingDirectory(runDir)

            for arg in patchParams.split(" "):
                self.arguments.append(arg)

        else:
            tempArg = ("--bottle %s --cx-app rundll32.exe --verbose " +
                       "%s,Patch %s --language %s --productcode %s") % (
                           winePrefix, patchClient, urlPatchServer, language,
                           prodCode)

            if hiResEnabled:
                tempArg = tempArg + " --highres"

            for arg in tempArg.split(" "):
                self.arguments.append(arg)

            self.process.setWorkingDirectory(runDir)

            if wineApp == "CXGames":
                if not self.osType.startCXG():
                    self.uiLog.txtLog.append(
                        "<b>Error: Couldn't start Crossover Games</b>")
                    self.uiLog.btnSave.setEnabled(False)
                    self.uiLog.btnStart.setEnabled(False)

                if self.osType.macPathCX == "":
                    tempFile = "%s%s%s" % (self.osType.globalDir,
                                           self.osType.directoryCXG,
                                           wineProgram)

                    if os.path.isfile(tempFile):
                        self.command = tempFile
                    else:
                        tempFile = "%s%s%s" % (
                            homeDir, self.osType.directoryCXG, wineProgram)

                        if os.path.isfile(tempFile):
                            self.command = tempFile
                        else:
                            self.command = wineProgram
                else:
                    self.command = "%s%s" % (self.osType.macPathCX,
                                             wineProgram)
            elif wineApp == "CXOffice":
                if not self.osType.startCXO():
                    self.uiLog.txtLog.append(
                        "<b>Error: Couldn't start Crossover</b>")
                    self.uiLog.btnSave.setEnabled(False)
                    self.uiLog.btnStart.setEnabled(False)

                if self.osType.macPathCX == "":
                    tempFile = "%s%s%s" % (self.osType.globalDir,
                                           self.osType.directoryCXO,
                                           wineProgram)

                    if os.path.isfile(tempFile):
                        self.command = tempFile
                    else:
                        tempFile = "%s%s%s" % (
                            homeDir, self.osType.directoryCXO, wineProgram)

                        if os.path.isfile(tempFile):
                            self.command = tempFile
                        else:
                            self.command = wineProgram
                else:
                    self.command = "%s%s" % (self.osType.macPathCX,
                                             wineProgram)

        self.file_arguments = self.arguments.copy()
        self.file_arguments.append("--filesonly")