Ejemplo n.º 1
0
    def on_btn_rebuild_native_clicked(self):
        library_dirs = None if not self.ui.lineEditLibDirs.text() else ",".split(self.ui.lineEditLibDirs.text())
        num_natives = self.backend_handler.num_native_backends
        extensions = ExtensionHelper.get_device_extensions(use_cython=False, library_dirs=library_dirs)
        new_natives = len(extensions) - num_natives

        if new_natives == 0:
            self.ui.labelRebuildNativeStatus.setText(self.tr("No new native backends were found."))
            return
        else:
            s = "s" if new_natives > 1 else ""
            self.ui.labelRebuildNativeStatus.setText(self.tr("Rebuilding device extensions..."))
            QApplication.instance().processEvents()
            pickle.dump(extensions, open(os.path.join(tempfile.gettempdir(), "native_extensions"), "wb"))
            target_dir = os.path.realpath(os.path.join(__file__, "../../../"))
            rc = call([sys.executable, os.path.realpath(ExtensionHelper.__file__),
                  "build_ext", "-b", target_dir, "-t", tempfile.gettempdir()])

            if rc == 0:
                self.ui.labelRebuildNativeStatus.setText(self.tr("<font color=green>"
                                                                 "Rebuilt {0} new device extension{1}. "
                                                                 "</font>"
                                                                 "Please restart URH.".format(new_natives, s)))
            else:
                self.ui.labelRebuildNativeStatus.setText(self.tr("<font color='red'>"
                                                                 "Failed to rebuild {0} device extension{1}. "
                                                                 "</font>"
                                                                 "Run URH as root (<b>sudo urh</b>) "
                                                                 "and try again.".format(new_natives, s)))
Ejemplo n.º 2
0
    def on_btn_rebuild_native_clicked(self):
        library_dirs = None if not self.ui.lineEditLibDirs.text() \
            else list(map(str.strip, self.ui.lineEditLibDirs.text().split(",")))
        extensions = ExtensionHelper.get_device_extensions(
            library_dirs=library_dirs)

        self.ui.labelRebuildNativeStatus.setText(
            self.tr("Rebuilding device extensions..."))
        QApplication.instance().processEvents()
        build_cmd = [
            sys.executable,
            os.path.realpath(ExtensionHelper.__file__), "build_ext",
            "--inplace", "-t",
            tempfile.gettempdir()
        ]
        if library_dirs:
            build_cmd.extend(["-L", ":".join(library_dirs)])

        subprocess.call([
            sys.executable,
            os.path.realpath(ExtensionHelper.__file__), "clean", "--all"
        ])
        p = subprocess.Popen(build_cmd,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.STDOUT)

        num_dots = 1
        while p.poll() is None:
            self.ui.labelRebuildNativeStatus.setText(
                self.tr("Rebuilding device extensions" + ". " * num_dots))
            QApplication.instance().processEvents()
            time.sleep(0.1)
            num_dots %= 10
            num_dots += 1

        rc = p.returncode
        if rc == 0:
            self.ui.labelRebuildNativeStatus.setText(
                self.tr("<font color=green>"
                        "Rebuilt {0} device extensions. "
                        "</font>"
                        "Please restart URH.".format(len(extensions))))
        else:
            self.ui.labelRebuildNativeStatus.setText(
                self.tr("<font color='red'>"
                        "Failed to rebuild {0} device extensions. "
                        "</font>"
                        "Run URH as root (<b>sudo urh</b>) "
                        "and try again.".format(len(extensions))))

        self.build_log = p.stdout.read().decode()
        self.ui.btnViewBuildLog.show()
Ejemplo n.º 3
0
    def on_btn_rebuild_native_clicked(self):
        library_dirs = None if not self.ui.lineEditLibDirs.text() \
            else list(map(str.strip, self.ui.lineEditLibDirs.text().split(",")))
        extensions = ExtensionHelper.get_device_extensions(use_cython=False, library_dirs=library_dirs)

        self.ui.labelRebuildNativeStatus.setText(self.tr("Rebuilding device extensions..."))
        QApplication.instance().processEvents()
        build_cmd = [sys.executable, os.path.realpath(ExtensionHelper.__file__),
                     "build_ext", "--inplace", "-t", tempfile.gettempdir()]
        if library_dirs:
            build_cmd.extend(["-L", ":".join(library_dirs)])

        subprocess.call([sys.executable, os.path.realpath(ExtensionHelper.__file__), "clean", "--all"])
        p = subprocess.Popen(build_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

        num_dots = 1
        while p.poll() is None:
            self.ui.labelRebuildNativeStatus.setText(self.tr("Rebuilding device extensions" + ". " * num_dots))
            QApplication.instance().processEvents()
            time.sleep(0.1)
            num_dots %= 10
            num_dots += 1

        rc = p.returncode
        if rc == 0:
            self.ui.labelRebuildNativeStatus.setText(self.tr("<font color=green>"
                                                             "Rebuilt {0} device extensions. "
                                                             "</font>"
                                                             "Please restart URH.".format(len(extensions))))
        else:
            self.ui.labelRebuildNativeStatus.setText(self.tr("<font color='red'>"
                                                             "Failed to rebuild {0} device extensions. "
                                                             "</font>"
                                                             "Run URH as root (<b>sudo urh</b>) "
                                                             "and try again.".format(len(extensions))))

        self.build_log = p.stdout.read().decode()
        self.ui.btnViewBuildLog.show()
Ejemplo n.º 4
0
    def on_btn_rebuild_native_clicked(self):
        library_dirs = None if not self.ui.lineEditLibDirs.text() \
                            else list(map(str.strip, self.ui.lineEditLibDirs.text().split(",")))
        num_natives = self.backend_handler.num_native_backends
        extensions = ExtensionHelper.get_device_extensions(use_cython=False, library_dirs=library_dirs)
        new_natives = len(extensions) - num_natives

        if new_natives == 0:
            self.ui.labelRebuildNativeStatus.setText(self.tr("No new native backends were found."))
            return
        else:
            s = "s" if new_natives > 1 else ""
            self.ui.labelRebuildNativeStatus.setText(self.tr("Rebuilding device extensions..."))
            pickle.dump(extensions, open(os.path.join(tempfile.gettempdir(), "native_extensions"), "wb"))
            target_dir = os.path.realpath(os.path.join(__file__, "../../../"))
            build_cmd = [sys.executable, os.path.realpath(ExtensionHelper.__file__),
                         "build_ext", "-b", target_dir,
                         "-t", tempfile.gettempdir()]
            if library_dirs:
                build_cmd.extend(["-L", ":".join(library_dirs)])
            rc = call(build_cmd)

            if rc == 0:
                self.ui.labelRebuildNativeStatus.setText(self.tr("<font color=green>"
                                                                 "Rebuilt {0} new device extension{1}. "
                                                                 "</font>"
                                                                 "Please restart URH.".format(new_natives, s)))
            else:
                self.ui.labelRebuildNativeStatus.setText(self.tr("<font color='red'>"
                                                                 "Failed to rebuild {0} device extension{1}. "
                                                                 "</font>"
                                                                 "Run URH as root (<b>sudo urh</b>) "
                                                                 "and try again.".format(new_natives, s)))
            try:
                os.remove(os.path.join(tempfile.gettempdir(), "native_extensions"))
            except OSError:
                pass