コード例 #1
0
ファイル: ibm.py プロジェクト: glimmercn/numpy
    def get_version(self,*args,**kwds):
        version = FCompiler.get_version(self,*args,**kwds)

        if version is None and sys.platform.startswith('aix'):
            # use lslpp to find out xlf version
            lslpp = find_executable('lslpp')
            xlf = find_executable('xlf')
            if os.path.exists(xlf) and os.path.exists(lslpp):
                s,o = exec_command(lslpp + ' -Lc xlfcmp')
                m = re.search('xlfcmp:(?P<version>\d+([.]\d+)+)', o)
                if m: version = m.group('version')

        xlf_dir = '/etc/opt/ibmcmp/xlf'
        if version is None and os.path.isdir(xlf_dir):
            # linux:
            # If the output of xlf does not contain version info
            # (that's the case with xlf 8.1, for instance) then
            # let's try another method:
            l = os.listdir(xlf_dir)
            l.sort()
            l.reverse()
            l = [d for d in l if os.path.isfile(os.path.join(xlf_dir,d,'xlf.cfg'))]
            if l:
                from distutils.version import LooseVersion
                self.version = version = LooseVersion(l[0])
        return version
コード例 #2
0
    def check_config(self, logger):
        """
        Perform optional error checks.

        Parameters
        ----------
        logger : object
            The object that manages logging output.
        """
        # check for the command
        comp = self._comp

        cmd = [c for c in comp.options['command'] if c.strip()]
        if not cmd:
            logger.error("The command cannot be empty")
        else:
            program_to_execute = comp.options['command'][0]
            if sys.platform == 'win32':
                if not find_executable(program_to_execute):
                    missing = self._check_for_files([program_to_execute])
                    if missing:
                        logger.error("The command to be executed, '%s', "
                                     "cannot be found" % program_to_execute)
            else:
                if not find_executable(program_to_execute):
                    logger.error("The command to be executed, '%s', "
                                 "cannot be found" % program_to_execute)

        # Check for missing input files. This just generates a warning during
        # setup, since these files may be generated later during execution.
        missing = self._check_for_files(comp.options['external_input_files'])
        if missing:
            logger.warning("The following input files are missing at setup "
                           "time: %s" % missing)
コード例 #3
0
    def check_config(self, logger):
        """
        Perform optional error checks.

        Parameters
        ----------
        logger : object
            The object that manages logging output.
        """
        # check for the command
        comp = self._comp

        cmd = [c for c in comp.options['command'] if c.strip()]
        if not cmd:
            logger.error("The command cannot be empty")
        else:
            program_to_execute = comp.options['command'][0]
            if sys.platform == 'win32':
                if not find_executable(program_to_execute):
                    missing = self._check_for_files([program_to_execute])
                    if missing:
                        logger.error("The command to be executed, '%s', "
                                     "cannot be found" % program_to_execute)
            else:
                if not find_executable(program_to_execute):
                    logger.error("The command to be executed, '%s', "
                                 "cannot be found" % program_to_execute)

        # Check for missing input files. This just generates a warning during
        # setup, since these files may be generated later during execution.
        missing = self._check_for_files(comp.options['external_input_files'])
        if missing:
            logger.warning("The following input files are missing at setup "
                           "time: %s" % missing)
コード例 #4
0
ファイル: ibm.py プロジェクト: danielmoreira12/BAProject
    def get_version(self, *args, **kwds):
        version = FCompiler.get_version(self, *args, **kwds)

        if version is None and sys.platform.startswith('aix'):
            # use lslpp to find out xlf version
            lslpp = find_executable('lslpp')
            xlf = find_executable('xlf')
            if os.path.exists(xlf) and os.path.exists(lslpp):
                try:
                    o = subprocess.check_output([lslpp, '-Lc', 'xlfcmp'])
                except (OSError, subprocess.CalledProcessError):
                    pass
                else:
                    m = re.search(r'xlfcmp:(?P<version>\d+([.]\d+)+)', o)
                    if m: version = m.group('version')

        xlf_dir = '/etc/opt/ibmcmp/xlf'
        if version is None and os.path.isdir(xlf_dir):
            # linux:
            # If the output of xlf does not contain version info
            # (that's the case with xlf 8.1, for instance) then
            # let's try another method:
            l = sorted(os.listdir(xlf_dir))
            l.reverse()
            l = [
                d for d in l
                if os.path.isfile(os.path.join(xlf_dir, d, 'xlf.cfg'))
            ]
            if l:
                from distutils.version import LooseVersion
                self.version = version = LooseVersion(l[0])
        return version
コード例 #5
0
    def _execute_local(self, command):
        """
        Run the command.

        Parameters
        ----------
        command : list
            List containing OS command string.

        Returns
        -------
        int
            Return Code
        str
            Error Message
        """
        # Check to make sure command exists
        comp = self._comp

        if isinstance(command, str):
            program_to_execute = re.findall(r"^([\w\-]+)", command)[0]
        else:
            program_to_execute = command[0]

        # Suppress message from find_executable function, we'll handle it
        numpy.distutils.log.set_verbosity(-1)

        if sys.platform == 'win32':
            if not find_executable(program_to_execute):
                missing = self._check_for_files([program_to_execute])
                if missing:
                    raise ValueError("The command to be executed, '%s', "
                                     "cannot be found" % program_to_execute)
            if isinstance(command, list):
                command_for_shell_proc = ['cmd.exe', '/c'] + command
            else:
                command_for_shell_proc = 'cmd.exe /c ' + str(command)

        else:
            if not find_executable(program_to_execute):
                raise ValueError("The command to be executed, '%s', "
                                 "cannot be found" % program_to_execute)
            command_for_shell_proc = command

        comp._process = \
            ShellProc(command_for_shell_proc, comp.stdin,
                      comp.stdout, comp.stderr, comp.options['env_vars'])

        try:
            return_code, error_msg = \
                comp._process.wait(comp.options['poll_delay'], comp.options['timeout'])
        finally:
            comp._process.close_files()
            comp._process = None

        return (return_code, error_msg)
コード例 #6
0
    def _execute_local(self, command):
        """
        Run the command.

        Parameters
        ----------
        command : List
            List containing OS command string.

        Returns
        -------
        int
            Return Code
        str
            Error Message
        """
        # Check to make sure command exists
        comp = self._comp

        if isinstance(command, str):
            program_to_execute = command
        else:
            program_to_execute = command[0]

        # Suppress message from find_executable function, we'll handle it
        numpy.distutils.log.set_verbosity(-1)

        if sys.platform == 'win32':
            if not find_executable(program_to_execute):
                missing = self._check_for_files([program_to_execute])
                if missing:
                    raise ValueError("The command to be executed, '%s', "
                                     "cannot be found" % program_to_execute)
            command_for_shell_proc = ['cmd.exe', '/c'] + command
        else:
            if not find_executable(program_to_execute):
                raise ValueError("The command to be executed, '%s', "
                                 "cannot be found" % program_to_execute)
            command_for_shell_proc = command

        comp._process = \
            ShellProc(command_for_shell_proc, comp.stdin,
                      comp.stdout, comp.stderr, comp.options['env_vars'])

        try:
            return_code, error_msg = \
                comp._process.wait(comp.options['poll_delay'], comp.options['timeout'])
        finally:
            comp._process.close_files()
            comp._process = None

        return (return_code, error_msg)
コード例 #7
0
ファイル: external_code.py プロジェクト: NoriVicJr/OpenMDAO
    def check_setup(self, out_stream=sys.stdout):
        """Write a report to the given stream indicating any potential problems found
        with the current configuration of this ``Problem``.

        Args
        ----
        out_stream : a file-like object, optional
        """

        # check for the command
        cmd = [c for c in self.options['command'] if c.strip()]
        if not cmd:
            out_stream.write("The command cannot be empty")
        else:
            program_to_execute = self.options['command'][0]
            command_full_path = find_executable(program_to_execute)

            if not command_full_path:
                out_stream.write("The command to be executed, '%s', "
                                 "cannot be found" % program_to_execute)

        # Check for missing input files
        missing = self._check_for_files(self.options['external_input_files'])
        if missing:
            out_stream.write("The following input files are missing at setup "
                             " time: %s" % missing)
コード例 #8
0
ファイル: external_code.py プロジェクト: NoriVicJr/OpenMDAO
    def _execute_local(self):
        """ Run command. """

        # check to make sure command exists
        if isinstance(self.options['command'], str):
            program_to_execute = self.options['command']
        else:
            program_to_execute = self.options['command'][0]

        # suppress message from find_executable function, we'll handle it
        numpy.distutils.log.set_verbosity(-1)

        command_full_path = find_executable(program_to_execute)
        if not command_full_path:
            raise ValueError(
                "The command to be executed, '%s', cannot be found" %
                program_to_execute)

        command_for_shell_proc = self.options['command']
        if sys.platform == 'win32':
            command_for_shell_proc = ['cmd.exe', '/c'] + command_for_shell_proc

        self._process = \
            ShellProc(command_for_shell_proc, self.stdin,
                      self.stdout, self.stderr, self.options['env_vars'])

        try:
            return_code, error_msg = \
                self._process.wait(self.options['poll_delay'], self.options['timeout'])
        finally:
            self._process.close_files()
            self._process = None

        return (return_code, error_msg)
コード例 #9
0
ファイル: external_code.py プロジェクト: cephdon/OpenMDAO
    def check_setup(self, out_stream=sys.stdout):
        """Write a report to the given stream indicating any potential problems found
        with the current configuration of this ``Problem``.

        Args
        ----
        out_stream : a file-like object, optional
        """

        # check for the command
        if not self.options['command']:
            out_stream.write( "The command cannot be empty")
        else:
            if isinstance(self.options['command'], str):
                program_to_execute = self.options['command']
            else:
                program_to_execute = self.options['command'][0]
            command_full_path = find_executable( program_to_execute )

            if not command_full_path:
                msg = "The command to be executed, '%s', cannot be found" % program_to_execute
                out_stream.write(msg)

        # Check for missing input files
        missing_files = self._check_for_files(input=True)
        for iotype, path in missing_files:
            msg = "The %s file %s is missing" % ( iotype, path )
            out_stream.write(msg)
コード例 #10
0
ファイル: external_code.py プロジェクト: Satadru-Roy/OpenMDAO
    def _execute_local(self):
        """ Run command. """

        # check to make sure command exists
        if isinstance(self.options['command'], str):
            program_to_execute = self.options['command']
        else:
            program_to_execute = self.options['command'][0]

        # suppress message from find_executable function, we'll handle it
        numpy.distutils.log.set_verbosity(-1)

        command_full_path = find_executable( program_to_execute )
        if not command_full_path:
            raise ValueError("The command to be executed, '%s', cannot be found" % program_to_execute)

        command_for_shell_proc = self.options['command']
        if sys.platform == 'win32':
            command_for_shell_proc = ['cmd.exe', '/c' ] + command_for_shell_proc

        self._process = \
            ShellProc(command_for_shell_proc, self.stdin,
                      self.stdout, self.stderr, self.options['env_vars'])

        try:
            return_code, error_msg = \
                self._process.wait(self.options['poll_delay'], self.options['timeout'])
        finally:
            self._process.close_files()
            self._process = None

        return (return_code, error_msg)
コード例 #11
0
ファイル: external_code.py プロジェクト: Satadru-Roy/OpenMDAO
    def check_setup(self, out_stream=sys.stdout):
        """Write a report to the given stream indicating any potential problems found
        with the current configuration of this ``Problem``.

        Args
        ----
        out_stream : a file-like object, optional
        """

        # check for the command
        cmd = [c for c in self.options['command'] if c.strip()]
        if not cmd:
            out_stream.write( "The command cannot be empty")
        else:
            program_to_execute = self.options['command'][0]
            command_full_path = find_executable( program_to_execute )

            if not command_full_path:
                out_stream.write("The command to be executed, '%s', "
                                 "cannot be found" % program_to_execute)

        # Check for missing input files
        missing = self._check_for_files(self.options['external_input_files'])
        if missing:
            out_stream.write("The following input files are missing at setup "
                             " time: %s" % missing)
コード例 #12
0
ファイル: gnu.py プロジェクト: radical-software/radicalspam
 def find_executables(self):
     for fc_exe in [find_executable(c) for c in ['gfortran','f95']]:
         if os.path.isfile(fc_exe):
             break
     for key in ['version_cmd', 'compiler_f77', 'compiler_f90',
                 'compiler_fix', 'linker_so', 'linker_exe']:
         self.executables[key][0] = fc_exe
コード例 #13
0
ファイル: hooks.py プロジェクト: pchanial/setuphooks
 def build_libraries(self, libraries):
     if parse_version(numpy.__version__) < parse_version('1.7'):
         fcompiler = self.fcompiler
     else:
         fcompiler = self._f_compiler
     if isinstance(fcompiler,
                   numpy.distutils.fcompiler.gnu.Gnu95FCompiler):
         old_value = numpy.distutils.log.set_verbosity(-2)
         exe = find_executable('gcc-ar')
         if exe is None:
             exe = find_executable('ar')
         numpy.distutils.log.set_verbosity(old_value)
         self.compiler.archiver[0] = exe
         flags = F77_COMPILE_ARGS_GFORTRAN + F77_COMPILE_OPT_GFORTRAN
         if self.debug:
             flags += F77_COMPILE_DEBUG_GFORTRAN
         if F77_OPENMP:
             flags += ['-openmp']
         fcompiler.executables['compiler_f77'] += flags
         flags = F90_COMPILE_ARGS_GFORTRAN + F90_COMPILE_OPT_GFORTRAN
         if self.debug:
             flags += F90_COMPILE_DEBUG_GFORTRAN
         if F90_OPENMP:
             flags += ['-openmp']
         fcompiler.executables['compiler_f90'] += flags
         fcompiler.libraries += [LIBRARY_OPENMP_GFORTRAN]
     elif isinstance(fcompiler,
                     numpy.distutils.fcompiler.intel.IntelFCompiler):
         old_value = numpy.distutils.log.set_verbosity(-2)
         self.compiler.archiver[0] = find_executable('xiar')
         numpy.distutils.log.set_verbosity(old_value)
         flags = F77_COMPILE_ARGS_IFORT + F77_COMPILE_OPT_IFORT
         if self.debug:
             flags += F77_COMPILE_DEBUG_IFORT
         if F77_OPENMP:
             flags += ['-openmp']
         fcompiler.executables['compiler_f77'] += flags
         flags = F90_COMPILE_ARGS_IFORT + F90_COMPILE_OPT_IFORT
         if self.debug:
             flags += F90_COMPILE_DEBUG_IFORT
         if F90_OPENMP:
             flags += ['-openmp']
         fcompiler.executables['compiler_f90'] += flags
         fcompiler.libraries += [LIBRARY_OPENMP_IFORT]
     else:
         raise RuntimeError("Unhandled compiler: '{}'.".format(fcompiler))
     build_clib.build_libraries(self, libraries)
コード例 #14
0
 def build_libraries(self, libraries):
     if parse_version(numpy.__version__) < parse_version('1.7'):
         fcompiler = self.fcompiler
     else:
         fcompiler = self._f_compiler
     if isinstance(fcompiler, numpy.distutils.fcompiler.gnu.Gnu95FCompiler):
         old_value = numpy.distutils.log.set_verbosity(-2)
         exe = find_executable('gcc-ar')
         if exe is None:
             exe = find_executable('ar')
         numpy.distutils.log.set_verbosity(old_value)
         self.compiler.archiver[0] = exe
         flags = F77_COMPILE_ARGS_GFORTRAN + F77_COMPILE_OPT_GFORTRAN
         if self.debug:
             flags += F77_COMPILE_DEBUG_GFORTRAN
         if F77_OPENMP:
             flags += ['-openmp']
         fcompiler.executables['compiler_f77'] += flags
         flags = F90_COMPILE_ARGS_GFORTRAN + F90_COMPILE_OPT_GFORTRAN
         if self.debug:
             flags += F90_COMPILE_DEBUG_GFORTRAN
         if F90_OPENMP:
             flags += ['-openmp']
         fcompiler.executables['compiler_f90'] += flags
         fcompiler.libraries += [LIBRARY_OPENMP_GFORTRAN]
     elif isinstance(fcompiler,
                     numpy.distutils.fcompiler.intel.IntelFCompiler):
         old_value = numpy.distutils.log.set_verbosity(-2)
         self.compiler.archiver[0] = find_executable('xiar')
         numpy.distutils.log.set_verbosity(old_value)
         flags = F77_COMPILE_ARGS_IFORT + F77_COMPILE_OPT_IFORT
         if self.debug:
             flags += F77_COMPILE_DEBUG_IFORT
         if F77_OPENMP:
             flags += ['-qopenmp']
         fcompiler.executables['compiler_f77'] += flags
         flags = F90_COMPILE_ARGS_IFORT + F90_COMPILE_OPT_IFORT
         if self.debug:
             flags += F90_COMPILE_DEBUG_IFORT
         if F90_OPENMP:
             flags += ['-qopenmp']
         fcompiler.executables['compiler_f90'] += flags
         fcompiler.libraries += [LIBRARY_OPENMP_IFORT]
     elif fcompiler is not None:
         raise RuntimeError("Unhandled compiler: '{}'.".format(fcompiler))
     build_clib.build_libraries(self, libraries)
コード例 #15
0
ファイル: scons.py プロジェクト: illume/numpy3k
def get_cxx_tool_path(compiler):
    """Given a distutils.ccompiler.CCompiler class, returns the path of the
    toolset related to C compilation."""
    fullpath_exec = find_executable(get_cxxcompiler_executable(compiler))
    if fullpath_exec:
        fullpath = pdirname(fullpath_exec)
    else:
        raise DistutilsSetupError("Could not find compiler executable info for scons")
    return fullpath
コード例 #16
0
 def find_executables(self):
     for fc_exe in [find_executable(c) for c in ['gfortran', 'f95']]:
         if os.path.isfile(fc_exe):
             break
     for key in [
             'version_cmd', 'compiler_f77', 'compiler_f90', 'compiler_fix',
             'linker_so', 'linker_exe'
     ]:
         self.executables[key][0] = fc_exe
コード例 #17
0
def get_cxx_tool_path(compiler):
    """Given a distutils.ccompiler.CCompiler class, returns the path of the
    toolset related to C compilation."""
    fullpath_exec = find_executable(get_cxxcompiler_executable(compiler))
    if fullpath_exec:
        fullpath = pdirname(fullpath_exec)
    else:
        raise DistutilsSetupError(
            "Could not find compiler executable info for scons")
    return fullpath
コード例 #18
0
    def test_pyxdsm_pdf(self):
        """
        Makes an XDSM of the Sphere test case. It also adds a design variable, constraint and
        objective.
        """
        class Rosenbrock(ExplicitComponent):

            def __init__(self, problem):
                super(Rosenbrock, self).__init__()
                self.problem = problem
                self.counter = 0

            def setup(self):
                self.add_input('x', np.array([1.5, 1.5]))
                self.add_output('f', 0.0)
                self.declare_partials('f', 'x', method='fd', form='central', step=1e-4)

            def compute(self, inputs, outputs, discrete_inputs=None, discrete_outputs=None):
                x = inputs['x']
                outputs['f'] = sum(x**2)

        x0 = np.array([1.2, 1.5])
        filename = 'xdsm2'

        prob = Problem()
        indeps = prob.model.add_subsystem('indeps', IndepVarComp(problem=prob), promotes=['*'])
        indeps.add_output('x', list(x0))

        prob.model.add_subsystem('sphere', Rosenbrock(problem=prob), promotes=['*'])
        prob.model.add_subsystem('con', ExecComp('c=sum(x)', x=np.ones(2)), promotes=['*'])
        prob.driver = ScipyOptimizeDriver()
        prob.model.add_design_var('x')
        prob.model.add_objective('f')
        prob.model.add_constraint('c', lower=1.0)

        prob.setup(check=False)
        prob.final_setup()

        # requesting 'pdf', but if 'pdflatex' is not found we will only get 'tex'
        pdflatex = find_executable('pdflatex')

        # Write output
        write_xdsm(prob, filename=filename, out_format='pdf', show_browser=SHOW, quiet=QUIET)

        # Check if file was created
        self.assertTrue(os.path.isfile('.'.join([filename, 'tex'])))
        # Check if PDF was created (only if pdflatex is installed)
        self.assertTrue(not pdflatex or os.path.isfile('.'.join([filename, 'pdf'])))
コード例 #19
0
    def _execute_local(self):
        """ Run command. """
        #self._logger.info('executing %s...', self.options['command'])
        # start_time = time.time()

        # check to make sure command exists
        if isinstance(self.options['command'], str):
            program_to_execute = self.options['command']
        else:
            program_to_execute = self.options['command'][0]

        # suppress message from find_executable function, we'll handle it
        numpy.distutils.log.set_verbosity(-1)

        command_full_path = find_executable(program_to_execute)
        if not command_full_path:
            raise ValueError(
                "The command to be executed, '%s', cannot be found" %
                program_to_execute)

        command_for_shell_proc = self.options['command']
        if sys.platform == 'win32':
            command_for_shell_proc = ['cmd.exe', '/c'] + command_for_shell_proc

        self._process = \
            ShellProc(command_for_shell_proc, self.stdin,
                      self.stdout, self.stderr, self.options['env_vars'])
        #self._logger.debug('PID = %d', self._process.pid)

        try:
            return_code, error_msg = \
                self._process.wait(self.options['poll_delay'], self.options['timeout'])
        finally:
            self._process.close_files()
            self._process = None

        # et = time.time() - start_time
        #if et >= 60:  #pragma no cover
        #self._logger.info('elapsed time: %.1f sec.', et)

        return (return_code, error_msg)
コード例 #20
0
ファイル: external_code.py プロジェクト: cephdon/OpenMDAO
    def _execute_local(self):
        """ Run command. """
        #self._logger.info('executing %s...', self.options['command'])
        # start_time = time.time()

        # check to make sure command exists
        if isinstance(self.options['command'], str):
            program_to_execute = self.options['command']
        else:
            program_to_execute = self.options['command'][0]

        # suppress message from find_executable function, we'll handle it
        numpy.distutils.log.set_verbosity(-1)

        command_full_path = find_executable( program_to_execute )
        if not command_full_path:
            raise ValueError("The command to be executed, '%s', cannot be found" % program_to_execute)

        command_for_shell_proc = self.options['command']
        if sys.platform == 'win32':
            command_for_shell_proc = ['cmd.exe', '/c' ] + command_for_shell_proc

        self._process = \
            ShellProc(command_for_shell_proc, self.stdin,
                      self.stdout, self.stderr, self.options['env_vars'])
        #self._logger.debug('PID = %d', self._process.pid)

        try:
            return_code, error_msg = \
                self._process.wait(self.options['poll_delay'], self.options['timeout'])
        finally:
            self._process.close_files()
            self._process = None

        # et = time.time() - start_time
        #if et >= 60:  #pragma no cover
            #self._logger.info('elapsed time: %.1f sec.', et)

        return (return_code, error_msg)
コード例 #21
0
def _build_import_library_amd64():
    out_exists, out_file = numpy.distutils.mingw32ccompiler._check_for_import_lib(
    )
    if out_exists:
        numpy.distutils.mingw32ccompiler.log.debug(
            'Skip building import library: "%s" exists', out_file)
        return

    # get the runtime dll for which we are building import library
    dll_file = numpy.distutils.mingw32ccompiler.find_python_dll()
    numpy.distutils.mingw32ccompiler.log.info(
        'Building import library (arch=AMD64): "%s" (from %s)' %
        (out_file, dll_file))

    # generate symbol list from this library
    def_name = "python%d%d.def" % tuple(sys.version_info[:2])
    def_file = os.path.join(sys.prefix, 'libs', def_name)
    numpy.distutils.mingw32ccompiler.generate_def(dll_file, def_file)

    # generate import library from this symbol list
    cmd = [find_executable("dlltool"), '-d', def_file, '-l', out_file]
    subprocess.Popen(cmd)
コード例 #22
0
    def test_examples(self):
        """
        This test just builds the three examples, and assert that the output files exist.
        Unlike the other tests, this one requires LaTeX to be available.
        """
        # we first copy the examples to the temp dir
        shutil.copytree(os.path.join(basedir, "../examples"), os.path.join(self.tempdir, "examples"))
        os.chdir(os.path.join(self.tempdir, "examples"))

        filenames = ["kitchen_sink", "mdf"]
        for f in filenames:
            subprocess.run(["python", f"{f}.py"], check=True)
            self.assertTrue(os.path.isfile(f + ".tikz"))
            self.assertTrue(os.path.isfile(f + ".tex"))
            # look for the pdflatex executable
            pdflatex = find_executable("pdflatex") is not None
            # if no pdflatex, then do not assert that the pdf was compiled
            self.assertTrue(not pdflatex or os.path.isfile(f + ".pdf"))
        subprocess.run(["python", "mat_eqn.py"], check=True)
        self.assertTrue(os.path.isfile("mat_eqn_example.pdf"))
        # change back to previous directory
        os.chdir(self.tempdir)
コード例 #23
0
    def test_examples(self):
        '''
        This test just builds the three examples, and assert that the output files exist.
        Unlike the other tests, this one requires LaTeX to be available.
        '''
        os.chdir(
            os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         '../examples'))

        filenames = ['kitchen_sink', 'mdf']
        for f in filenames:
            os.system('python {}.py'.format(f))
            self.assertTrue(os.path.isfile(f + '.tikz'))
            self.assertTrue(os.path.isfile(f + '.tex'))
            # look for the pdflatex executable
            pdflatex = find_executable('pdflatex') is not None
            # if no pdflatex, then do not assert that the pdf was compiled
            self.assertTrue(not pdflatex or os.path.isfile(f + '.pdf'))
        os.system('python mat_eqn.py')
        self.assertTrue(os.path.isfile('mat_eqn_example.pdf'))
        # change back to previous directory
        os.chdir(self.tempdir)
コード例 #24
0
    def test_examples(self):
        """
        This test just builds the three examples, and assert that the output files exist.
        Unlike the other tests, this one requires LaTeX to be available.
        """
        os.chdir(
            os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         "../examples"))

        filenames = ["kitchen_sink", "mdf"]
        for f in filenames:
            os.system("python {}.py".format(f))
            self.assertTrue(os.path.isfile(f + ".tikz"))
            self.assertTrue(os.path.isfile(f + ".tex"))
            # look for the pdflatex executable
            pdflatex = find_executable("pdflatex") is not None
            # if no pdflatex, then do not assert that the pdf was compiled
            self.assertTrue(not pdflatex or os.path.isfile(f + ".pdf"))
        os.system("python mat_eqn.py")
        self.assertTrue(os.path.isfile("mat_eqn_example.pdf"))
        # change back to previous directory
        os.chdir(self.tempdir)
コード例 #25
0
def _monkey_patch_dump_table(dll):
    objdump = find_executable("objdump")
    st = subprocess.Popen([objdump, "-p", dll], stdout=subprocess.PIPE)
    return st.stdout.readlines()
コード例 #26
0
ファイル: setup.py プロジェクト: marcopovitch/obspy
 def finalize_options(self):
     build.finalize_options(self)
     self.help2man = find_executable('help2man')
     if not self.help2man:
         raise DistutilsSetupError('Building man pages requires help2man.')
コード例 #27
0
    def test_pyxdsm_identical_relative_names(self):
        class TimeComp(ExplicitComponent):
            def setup(self):
                self.add_input('t_initial', val=0.)
                self.add_input('t_duration', val=1.)
                self.add_output('time', shape=(2, ))

            def compute(self, inputs, outputs):
                t_initial = inputs['t_initial']
                t_duration = inputs['t_duration']

                outputs['time'][0] = t_initial
                outputs['time'][1] = t_initial + t_duration

        class Phase(Group):
            def setup(self):
                super(Phase, self).setup()

                indep = IndepVarComp()
                for var in ['t_initial', 't_duration']:
                    indep.add_output(var, val=1.0)

                self.add_subsystem('time_extents',
                                   indep,
                                   promotes_outputs=['*'])

                time_comp = TimeComp()
                self.add_subsystem('time', time_comp)

                self.connect('t_initial', 'time.t_initial')
                self.connect('t_duration', 'time.t_duration')

                self.set_order(['time_extents', 'time'])

        p = Problem()
        p.driver = ScipyOptimizeDriver()
        orbit_phase = Phase()
        p.model.add_subsystem('orbit_phase', orbit_phase)

        systems_phase = Phase()
        p.model.add_subsystem('systems_phase', systems_phase)

        systems_phase = Phase()
        p.model.add_subsystem('extra_phase', systems_phase)
        p.model.add_design_var('orbit_phase.t_initial')
        p.model.add_design_var('orbit_phase.t_duration')
        p.setup(check=True)

        p.run_model()

        # requesting 'pdf', but if 'pdflatex' is not found we will only get 'tex'
        pdflatex = find_executable('pdflatex')

        # Test non unique local names
        write_xdsm(p,
                   'xdsm3',
                   out_format='pdf',
                   quiet=QUIET,
                   show_browser=False)
        self.assertTrue(os.path.isfile('.'.join(['xdsm3', 'tex'])))
        self.assertTrue(not pdflatex
                        or os.path.isfile('.'.join(['xdsm3', 'pdf'])))

        # Check formatting

        # Max character box formatting
        write_xdsm(p,
                   'xdsm4',
                   out_format='pdf',
                   quiet=QUIET,
                   show_browser=False,
                   box_stacking='cut_chars',
                   box_width=15)
        self.assertTrue(os.path.isfile('.'.join(['xdsm4', 'tex'])))
        self.assertTrue(not pdflatex
                        or os.path.isfile('.'.join(['xdsm4', 'pdf'])))

        # Cut characters box formatting
        write_xdsm(p,
                   'xdsm5',
                   out_format='pdf',
                   quiet=True,
                   show_browser=False,
                   box_stacking='max_chars',
                   box_width=15)
        self.assertTrue(os.path.isfile('.'.join(['xdsm5', 'tex'])))
        self.assertTrue(not pdflatex
                        or os.path.isfile('.'.join(['xdsm5', 'pdf'])))
コード例 #28
0
ファイル: setup.py プロジェクト: yanyuandaxia/obspy
 def finalize_options(self):
     build.finalize_options(self)
     self.help2man = find_executable('help2man')
     if not self.help2man:
         raise DistutilsSetupError('Building man pages requires help2man.')
コード例 #29
0
ファイル: __init__.py プロジェクト: blitzmann/Pyfa-skel
 def cached_find_executable(exe):
     if exe in exe_cache:
         return exe_cache[exe]
     fc_exe = find_executable(exe)
     exe_cache[exe] = exe_cache[fc_exe] = fc_exe
     return fc_exe
コード例 #30
0
ファイル: __init__.py プロジェクト: MingleiYang/FlipbookApp
 def cached_find_executable(exe):
     if exe in exe_cache:
         return exe_cache[exe]
     fc_exe = find_executable(exe)
     exe_cache[exe] = exe_cache[fc_exe] = fc_exe
     return fc_exe