示例#1
0
    def test_searchForExe(self):
        exe = ExeFinder.searchForExe()
        self.assertEqual(exe, None)

        method = os.environ.get("METHOD", "opt")
        moose_dir = os.environ.get("MOOSE_DIR")
        self.assertNotEqual(moose_dir, None)
        start_dir = os.path.join(moose_dir, "test")
        exe = ExeFinder.searchForExe(start_dir=start_dir)
        self.assertNotEqual(exe, None)
        self.assertTrue(exe.endswith("-%s" % method))

        exe = ExeFinder.searchForExe(start_dir=start_dir, methods=["unknown"])
        self.assertEqual(exe, None)

        for method in ["opt", "dbg", "oprof", "devel"]:
            exe_path = os.path.join(start_dir, "moose_test-%s" % method)
            if not os.path.exists(exe_path):
                continue
            os.environ["METHOD"] = method
            exe = ExeFinder.searchForExe(start_dir=start_dir)
            self.assertEqual(exe, exe_path)
            self.assertNotEqual(exe, None)
            self.assertTrue(exe.endswith("-%s" % method))

        # unset METHOD, it should pick up the opt version
        os.environ.pop("METHOD")
        exe = ExeFinder.searchForExe(start_dir=start_dir)
        self.assertNotEqual(exe, None)
        self.assertTrue(exe.endswith("-opt"))
示例#2
0
    def test_searchForExe(self):
        exe = ExeFinder.searchForExe()
        self.assertEqual(exe, None)

        method = os.environ.get("METHOD", "opt")
        moose_dir = os.environ.get("MOOSE_DIR")
        self.assertNotEqual(moose_dir, None)
        start_dir = os.path.join(moose_dir, "test")
        exe = ExeFinder.searchForExe(start_dir=start_dir)
        self.assertNotEqual(exe, None)
        self.assertTrue(exe.endswith("-%s" % method))

        exe = ExeFinder.searchForExe(start_dir=start_dir, methods=["unknown"])
        self.assertEqual(exe, None)

        for method in ["opt", "dbg", "oprof", "devel"]:
            exe_path = os.path.join(start_dir, "moose_test-%s" % method)
            if not os.path.exists(exe_path):
                continue
            os.environ["METHOD"] = method
            exe = ExeFinder.searchForExe(start_dir=start_dir)
            self.assertEqual(exe, exe_path)
            self.assertNotEqual(exe, None)
            self.assertTrue(exe.endswith("-%s" % method))

        # unset METHOD, it should pick up the opt version
        os.environ.pop("METHOD")
        exe = ExeFinder.searchForExe(start_dir=start_dir)
        self.assertNotEqual(exe, None)
        self.assertTrue(exe.endswith("-opt"))
示例#3
0
    def test_recursiveFindFile(self):
        start_dir = os.path.dirname(os.path.abspath(__file__))
        exe = ExeFinder.recursiveFindFile(start_dir, "run_tests")
        self.assertNotEqual(exe, None)
        self.assertEqual(os.path.basename(exe), "run_tests")

        exe = ExeFinder.recursiveFindFile(start_dir, "really_does_not_exist")
        self.assertEqual(exe, None)

        exe = ExeFinder.recursiveFindFile(start_dir, "really_does_not_exist", problems_dir="peacock")
        self.assertEqual(exe, None)
示例#4
0
    def test_recursiveFindFile(self):
        start_dir = os.path.dirname(os.path.abspath(__file__))
        exe = ExeFinder.recursiveFindFile(start_dir, "run_tests")
        self.assertNotEqual(exe, None)
        self.assertEqual(os.path.basename(exe), "run_tests")

        exe = ExeFinder.recursiveFindFile(start_dir, "really_does_not_exist")
        self.assertEqual(exe, None)

        exe = ExeFinder.recursiveFindFile(start_dir, "really_does_not_exist", problems_dir="peacock")
        self.assertEqual(exe, None)
示例#5
0
 def setExe(self, options):
     """
     Tries to find an executable.
     It first looks in the command line options.
     If not found it will search up the directory path.
     Input:
         options[argparse namespace]: The command line options as returned by ArgumentParser.parse_args()
     """
     exe_path = ExeFinder.getExecutablePath(options, start_dir=self.search_from_dir)
     if exe_path:
         self.ExecuteOptionsPlugin.setExecutablePath(exe_path)
示例#6
0
 def setExe(self, options):
     """
     Tries to find an executable.
     It first looks in the command line options.
     If not found it will search up the directory path.
     Input:
         options[argparse namespace]: The command line options as returned by ArgumentParser.parse_args()
     """
     if options.executable and not os.path.isabs(options.executable):
         options.executable = os.path.abspath(os.path.join(options.start_dir, options.executable))
     exe_path = ExeFinder.getExecutablePath(options, start_dir=self.search_from_dir)
     if exe_path:
         self.ExecuteOptionsPlugin.setExecutablePath(exe_path)
def main(size=None):
    """
    Run the FluidPropertyInterrogatorPlugin alone
    """
    from peacock.utils import ExeFinder

    widget = FluidPropertyInterrogatorPlugin()
    exe_path = ExeFinder.getExecutablePath(None, start_dir = os.getcwd())
    if exe_path:
        widget.setExecutablePath(exe_path)
        widget.layoutMain.setContentsMargins(15, 15, 15, 15)
        widget.show()
        widget.setWindowTitle("Fluid Property Interrogator")
        return widget
    else:
        raise SystemExit("No executable found")