示例#1
0
def run_profiler(programname):
    """grab data from gprof/prof output and format nicely"""

    # gprof needs gmon.out (from the last execution of programname)
    if os.path.isfile('gmon.out'):
        # run gprof:
        if not findprograms(['gprof']):
            print 'Cannot find gprof'
            return
        res = os.popen('gprof ' + programname)
        lines = res.readlines()
        failure = res.close()
        if failure:
            print 'Could not run gprof'
            return
        # grab the table from the gprof output:
        for i in range(len(lines)):
            if re.search(r'\%\s+cumulative\s+self', lines[i]):
                startline = i
                break
        try:
            # we are interested in the 10 first lines of the table,
            # but if there is a blank line, we stop there
            stopline = 10
            i = 0
            for line in lines[startline:startline + stopline]:
                if re.search(r'^\s*$', line):
                    stopline = i
                    break
                i = i + 1
            table = ''.join(lines[startline:startline + stopline])
            print table
            os.remove('gmon.out')  # require new file for next run...
        except:
            print 'Could not recognize a table in gmon.out...'
            return
    elif os.path.isfile('mon.out'):
        # run prof:
        if not findprograms(['prof']):
            print 'Cannot find gprof'
            return
        res = os.popen('prof ' + programname)
        lines = res.readlines()
        failure = res.close()
        if failure:
            print 'Could not run prof'
            return
        for line in lines[0:10]:
            print line,

    else:  # no gmon.out or mon.out, cannot run gprof or prof
        print programname,\
              'was not compiled in profiling mode (-pg or -p?)'
        return
示例#2
0
def run_profiler(programname):
    """grab data from gprof/prof output and format nicely"""

    # gprof needs gmon.out (from the last execution of programname)
    if os.path.isfile('gmon.out'):
        # run gprof:
        if not findprograms(['gprof']):
            print 'Cannot find gprof'
            return
        res = os.popen('gprof ' + programname)
        lines = res.readlines()
        failure = res.close()
        if failure:
            print 'Could not run gprof'; return
        # grab the table from the gprof output:
        for i in range(len(lines)):
            if re.search(r'\%\s+cumulative\s+self', lines[i]):
                startline = i
                break
        try:
            # we are interested in the 10 first lines of the table,
            # but if there is a blank line, we stop there
            stopline = 10
            i = 0
            for line in lines[startline:startline+stopline]:
                if re.search(r'^\s*$', line):
                    stopline = i;  break
                i = i + 1
            table = ''.join(lines[startline:startline+stopline])
            print table
            os.remove('gmon.out') # require new file for next run...
        except:
            print 'Could not recognize a table in gmon.out...'; return
    elif os.path.isfile('mon.out'):
        # run prof:
        if not findprograms(['prof']):
            print 'Cannot find gprof'
            return
        res = os.popen('prof ' + programname)
        lines = res.readlines()
        failure = res.close()
        if failure:
            print 'Could not run prof'; return
        for line in lines[0:10]: print line,
        
    else:  # no gmon.out or mon.out, cannot run gprof or prof
        print programname,\
              'was not compiled in profiling mode (-pg or -p?)'
        return
示例#3
0
    def _any2any(self, files, basename='tmp_easyviz_',
                 size=None, ofile_ext='.pnm'):
        """Convert a list of files to the file format specified in the
        ofile_ext keyword argument. Using either Netpbm tools or convert
        (from the ImageMagick package).
        """
        netpbm_converters = {'.png': ('pngtopnm', 'pnmtopng'),
                             '.gif': ('giftopnm',  'ppmtogif'),
                             '.jpg': ('jpegtopnm', 'pnmtojpeg'),
                             '.ps':  ('pstopnm', 'pnmtops'),
                             '.eps': ('pstopnm', 'pnmtops'),
                             '.bmp': ('bmptopnm', 'ppmtobmp'),
                             '.tif': ('tifftopnm', 'pnmtotiff'),
                             '.tga': ('tgatopnm', 'ppmtotga'),
                             '.pnm': ('cat', ''),
                             }
        _check_type(files, 'files', (list,tuple))
        ifile_ext = os.path.splitext(files[0])[1]
        anytopnm = netpbm_converters[ifile_ext][0]
        pnmtoany = netpbm_converters[ofile_ext][1]
        pnmscale = 'pnmscale'
        #pnmcrop = 'pnmcrop'
        convert = 'convert'

        app = anytopnm
        if findprograms((convert, anytopnm, pnmtoany)):
            if self._prop['preferred_package'].lower() == 'imagemagick':
                app = convert
        elif findprograms(convert):
            app = convert
        elif not findprograms((anytopnm, pnmtoany)):
            raise Exception("Neither %s nor %s was found" % (convert,anytopnm))

        quiet = self._prop['quiet']
        new_files = []
        i = 1 # counter
        for file_ in files:
            new_file = "%s%04d%s" % (basename, i, ofile_ext)
            if app == anytopnm:
                options = ''
                if quiet and app != 'cat':
                    options += '-quiet'
                if app == 'pstopnm':
                    options += ' -stdout'
                    #options += ' -portrait'
                cmd = "%(app)s %(options)s %(file_)s " % vars()
                if size is not None and findprograms(pnmscale):
                    w, h = size
                    cmd += "| %(pnmscale)s -width %(w)s -height %(h)s" % vars()
                if pnmtoany != '':
                    options = ''
                    if quiet:
                        options += '-quiet'
                    if pnmtoany == 'pnmtojpeg':
                        options += ' -quality 100' # don't lose quality
                    cmd += " | %(pnmtoany)s %(options)s" % vars()
                cmd += " > %s" % new_file
            else:
                options = ''
                if size is not None:
                    options += '-resize %sx%s' % size
                cmd = "%(app)s %(options)s %(file_)s %(new_file)s" % vars()
            if not quiet:
                print cmd
            failure = os.system(cmd)
            if failure:
                print "... %s failed, jumping to next file..." % app
                continue
            new_files.append(new_file)
            if not quiet:
                apps = app
                if app != convert and pnmtoany != '':
                    apps += ' and %s' % pnmtoany
                print "%s transformed via %s to %s (%d Kb)" % \
                      (file_,apps,new_file,int(os.path.getsize(new_file)/1000))
            i += 1

        return new_files
示例#4
0
    def _mpeg2enc(self):
        """Return a string with commands for making a movie with the
        mpeg2enc tool (from MJPEGTools).
        """
        encoder = self._prop['encoder']
        png2yuv = 'png2yuv'
        jpeg2yuv = 'jpeg2yuv'
        yuvscaler = 'yuvscaler'

        file_type = self._prop['file_type']
        files = self._prop['input_files']
        if isinstance(files, str):
            pattern = r'(.*)%(\d+)d(.*\..*)'
            match = re.search(pattern, files)
            if match:
                if file_type not in ['jpg', 'png'] or \
                       self._prop['force_conversion']:
                    pre = match.group(1)
                    num = int(match.group(2))
                    ext = match.group(3)
                    files = pre + '[0-9]'*num + ext
                    files = glob.glob(files)
                    files.sort()
            else:
                files = glob.glob(files)
                files.sort()
        if isinstance(files, (list,tuple)):
            basename = 'tmp_easyviz_'
            files = self._any2any(files, basename=basename, ofile_ext='.png')
            file_type = 'png'
            self._tmp_files = files[:]
            # create a new string with the right pattern:
            files = basename + '%04d.png'

        cmd = ''
        if file_type == 'jpg' and findprograms(jpeg2yuv):
            cmd += jpeg2yuv
        elif findprograms(png2yuv):
            cmd += png2yuv
        else:
            raise Exception("png2yuv or jpeg2yuv is not installed")
        cmd += ' -f 25' # frame rate
        cmd += ' -I p'  # interlacing mode: p = none / progressive
        cmd += ' -j "%s"' % files # set image files
        # find start image:
        for i in xrange(9999):
            if os.path.isfile(files % i):
                cmd += ' -b %d' % i
                break
        if self._prop['quiet']:
            cmd += ' -v 0' # verbosity level 0

        # set size of movie (by using the yuvscaler tool):
        size = self._get_size()
        if size is not None and findprograms(yuvscaler):
            width, height = size
            cmd += ' | %(yuvscaler)s -O SIZE_%(width)sx%(height)s' % vars()

        # if no output file is given, use 'movie.avi' as default:
        if self._prop['output_file'] is None:
            self._prop['output_file'] = 'movie.mpeg'
        output_file = self._prop['output_file']
        if os.path.isfile(output_file) and not self._prop['overwrite_output']:
            raise Exception("Output file '%s' already exist. Use" \
                            " 'overwrite_output=True' to overwrite the file." \
                            % output_file)

        cmd += ' | '
        cmd += encoder
        if self._prop['vcodec'] == 'mpeg2video':
            cmd += ' -f 3' # generic mpeg-2 video
        else:
            cmd += ' -f 0' # generic mpeg-1 video
        if self._prop['vbitrate'] is not None:
            cmd += ' -b %d' % int(self._prop['vbitrate'])
        if self._prop['vbuffer'] is not None:
            cmd += ' -V %d' % int(self._prop['vbuffer'])
        if self._prop['qscale'] is not None:
            cmd += ' -q %s' % self._prop['qscale']

        # set movie frame rate:
        legal_fps = {'23.976': 1, '24': 2, '25': 3, '29.97': 4,
                     '30': 5, '50': 6, '59.94': 7, '60': 8}
        fps = str(self._prop['fps'])
        if not fps in legal_fps:
            raise ValueError("fps must be %s, not %s" % \
                             (fps_convert.keys(), fps))
        cmd += ' -F %s' % legal_fps[fps]
        #cmd += ' --cbr' # constant bit rate
        gop_size = self._prop['gop_size']
        if gop_size is not None:
            # set min (-g) and max (-G) gop size to the same value:
            cmd += ' -g %s -G %s' % (gop_size, gop_size)

        # set aspect ratio:
        legal_aspects = {'1.0': 1, '1.3': 2, '1.7': 3, '2.21': 4}
        aspect = self._get_aspect_ratio()
        if aspect is not None:
            if aspect not in legal_aspects.values():
                aspect = str(aspect)
                for key in legal_aspects.keys():
                    if aspect.startswith(key):
                        aspect = legal_aspects[key]
                        break
                if aspect not in legal_aspects.values():
                    raise ValueError(
                        "aspect must be either 1:1, 4:3, 16:9, or 2.21:1," \
                        " not '%s'" % aspect)
            cmd += ' -a %s' % aspect

        # set output file:
        cmd += ' -o %s' % self._prop['output_file']
        if self._prop['quiet']:
            cmd += ' -v 0' # verbosity level 0 (warnings and errors only)
        return cmd
示例#5
0
    def __init__(self, input_files, **kwargs):
        self._prop = {}
        self._prop.update(self._local_prop)
        self._prop['input_files'] = input_files
        for key in kwargs:
            if key in self._prop:
                self._prop[key] = kwargs[key]

        print '\n\n' # provide some space before print statements

        # Determine which encoder to be used
        encoder = self._prop['encoder']
        if encoder is None:
            # No encoder given, find the first installed among the legal ones
            for enc in self._legal_encoders:
                if findprograms(enc):
                    encoder = enc
                    break
            if encoder is None:
                # No encoder is installed, fall back on html
                encoder = 'html'
            self._prop['encoder'] = encoder
        else:
            if not encoder in self._legal_encoders:
                raise ValueError("encoder must be %s, not '%s'" %
                                 (self._legal_encoders, encoder))
            if not encoder.startswith('html') and not findprograms(encoder):
                raise Exception("The selected encoder (%s) is not installed" \
                                % encoder)

        # Determine the file type of the input files
        if isinstance(input_files, (tuple,list)):
            file_ = input_files[0]
        elif isinstance(input_files, str):
            file_ = input_files
        else:
            raise ValueError("The input files must be given as either a "\
                             "list/tuple of strings or a string, not '%s'" % \
                             type(input_files))

        # Check that the input files do exist
        if isinstance(input_files, str):
            # Are input_files on ffmpeg/mpeg2enc format or Unix wildcard format?
            ffmpeg_format = r'(.+)%\d+d(\..+)'
            m = re.search(ffmpeg_format, input_files, re.DOTALL)
            if m:
                wildcard_format = m.group(1) + '*' + m.group(2)
            else:
                wildcard_format = input_files
            all_input_files = glob.glob(wildcard_format)
            if not all_input_files:
                print 'No files of the form %s exist.' % input_files
            else:
                print 'Found %d files of the format %s.' % \
                (len(all_input_files), input_files)
        else:  # list of specific filenames
            all_input_files = input_files
        error_encountered = False
        for f in all_input_files:
            if not os.path.isfile(f):
                print 'Input file %s does not exist.' % f
                error_encountered = True
        if error_encountered:
            raise IOError('Some input files were not found.')

        fname, ext = os.path.splitext(file_)
        if not ext:
            raise ValueError("Unable to determine file type from file name.")
        file_type = ext[1:] # remove the . (dot)
        if not file_type in self._legal_file_types:
            raise TypeError("File type must be %s, not '%s'" % \
                            (self._legal_file_types, file_type))
        self._prop['file_type'] = file_type
示例#6
0
programs = {
    'gnuplot'    : 'plotting program',
    'gs'         : 'ghostscript, ps/pdf interpreter and previewer',
    'ps2pdf'     : 'ps/pdf converter, part of ghostscript',
    'convert'    : 'image conversion, part of the ImageMagick package',
    'animate'    : 'animation viewer, part of the ImageMagick package',
    'display'    : 'image viewer, part of the ImageMagick package',
    'latex'      : 'mathematical typesetting tool',
    'dvips'      : 'tool for converting latex to ps',
    'happydoc'   : 'generation of Python code documentation from doc strings',
    'epydoc'     : 'generation of Python code documentation from doc strings',
    'f2py'       : 'generator for Python interfaces to F77',
    'swig'       : 'generator for Python/Perl/Tcl interfaces to C/C++',
    }

installed = findprograms(programs.keys())
for program in installed.keys():
    if installed[program] is not None:
        print "You have %s (%s)\n   in %s" % \
              (program, programs[program], installed[program])
    else:
        print "*** Program", program, "was not found on the system"
        if sys.platform.startswith('win') and program in ('latex', 'dvips'):
            print "*** You don't have latex/dvips but on Windows this is usual"
        elif sys.platform.startswith('win') and program == 'gs':
            # no link/script turning C:\gs\gs814... into 'gs', that's ok
            pass
        else:
            print "           .....(%s)" % programs[program]

# check if Gnuplot is compiled with PNG support
示例#7
0
文件: movie.py 项目: terjekv/scitools
    def _any2any(self,
                 files,
                 basename='tmp_easyviz_',
                 size=None,
                 ofile_ext='.pnm'):
        """Convert a list of files to the file format specified in the
        ofile_ext keyword argument. Using either Netpbm tools or convert
        (from the ImageMagick package).
        """
        netpbm_converters = {
            '.png': ('pngtopnm', 'pnmtopng'),
            '.gif': ('giftopnm', 'ppmtogif'),
            '.jpg': ('jpegtopnm', 'pnmtojpeg'),
            '.ps': ('pstopnm', 'pnmtops'),
            '.eps': ('pstopnm', 'pnmtops'),
            '.bmp': ('bmptopnm', 'ppmtobmp'),
            '.tif': ('tifftopnm', 'pnmtotiff'),
            '.tga': ('tgatopnm', 'ppmtotga'),
            '.pnm': ('cat', ''),
        }
        _check_type(files, 'files', (list, tuple))
        ifile_ext = os.path.splitext(files[0])[1]
        anytopnm = netpbm_converters[ifile_ext][0]
        pnmtoany = netpbm_converters[ofile_ext][1]
        pnmscale = 'pnmscale'
        #pnmcrop = 'pnmcrop'
        convert = 'convert'

        app = anytopnm
        if findprograms((convert, anytopnm, pnmtoany)):
            if self._prop['preferred_package'].lower() == 'imagemagick':
                app = convert
        elif findprograms(convert):
            app = convert
        elif not findprograms((anytopnm, pnmtoany)):
            raise Exception("Neither %s nor %s was found" %
                            (convert, anytopnm))

        quiet = self._prop['quiet']
        new_files = []
        i = 1  # counter
        for file_ in files:
            new_file = "%s%04d%s" % (basename, i, ofile_ext)
            if app == anytopnm:
                options = ''
                if quiet and app != 'cat':
                    options += '-quiet'
                if app == 'pstopnm':
                    options += ' -stdout'
                    #options += ' -portrait'
                cmd = "%(app)s %(options)s %(file_)s " % vars()
                if size is not None and findprograms(pnmscale):
                    w, h = size
                    cmd += "| %(pnmscale)s -width %(w)s -height %(h)s" % vars()
                if pnmtoany != '':
                    options = ''
                    if quiet:
                        options += '-quiet'
                    if pnmtoany == 'pnmtojpeg':
                        options += ' -quality 100'  # don't lose quality
                    cmd += " | %(pnmtoany)s %(options)s" % vars()
                cmd += " > %s" % new_file
            else:
                options = ''
                if size is not None:
                    options += '-resize %sx%s' % size
                cmd = "%(app)s %(options)s %(file_)s %(new_file)s" % vars()
            if not quiet:
                print cmd
            failure = os.system(cmd)
            if failure:
                print "... %s failed, jumping to next file..." % app
                continue
            new_files.append(new_file)
            if not quiet:
                apps = app
                if app != convert and pnmtoany != '':
                    apps += ' and %s' % pnmtoany
                print "%s transformed via %s to %s (%d Kb)" % \
                      (file_,apps,new_file,int(os.path.getsize(new_file)/1000))
            i += 1

        return new_files
示例#8
0
文件: movie.py 项目: terjekv/scitools
    def _mpeg2enc(self):
        """Return a string with commands for making a movie with the
        mpeg2enc tool (from MJPEGTools).
        """
        encoder = self._prop['encoder']
        png2yuv = 'png2yuv'
        jpeg2yuv = 'jpeg2yuv'
        yuvscaler = 'yuvscaler'

        file_type = self._prop['file_type']
        files = self._prop['input_files']
        if isinstance(files, str):
            pattern = r'(.*)%(\d+)d(.*\..*)'
            match = re.search(pattern, files)
            if match:
                if file_type not in ['jpg', 'png'] or \
                       self._prop['force_conversion']:
                    pre = match.group(1)
                    num = int(match.group(2))
                    ext = match.group(3)
                    files = pre + '[0-9]' * num + ext
                    files = glob.glob(files)
                    files.sort()
            else:
                files = glob.glob(files)
                files.sort()
        if isinstance(files, (list, tuple)):
            basename = 'tmp_easyviz_'
            files = self._any2any(files, basename=basename, ofile_ext='.png')
            file_type = 'png'
            self._tmp_files = files[:]
            # create a new string with the right pattern:
            files = basename + '%04d.png'

        cmd = ''
        if file_type == 'jpg' and findprograms(jpeg2yuv):
            cmd += jpeg2yuv
        elif findprograms(png2yuv):
            cmd += png2yuv
        else:
            raise Exception("png2yuv or jpeg2yuv is not installed")
        cmd += ' -f 25'  # frame rate
        cmd += ' -I p'  # interlacing mode: p = none / progressive
        cmd += ' -j "%s"' % files  # set image files
        # find start image:
        for i in xrange(9999):
            if os.path.isfile(files % i):
                cmd += ' -b %d' % i
                break
        if self._prop['quiet']:
            cmd += ' -v 0'  # verbosity level 0

        # set size of movie (by using the yuvscaler tool):
        size = self._get_size()
        if size is not None and findprograms(yuvscaler):
            width, height = size
            cmd += ' | %(yuvscaler)s -O SIZE_%(width)sx%(height)s' % vars()

        # if no output file is given, use 'movie.avi' as default:
        if self._prop['output_file'] is None:
            self._prop['output_file'] = 'movie.mpeg'
        output_file = self._prop['output_file']
        if os.path.isfile(output_file) and not self._prop['overwrite_output']:
            raise Exception("Output file '%s' already exist. Use" \
                            " 'overwrite_output=True' to overwrite the file." \
                            % output_file)

        cmd += ' | '
        cmd += encoder
        if self._prop['vcodec'] == 'mpeg2video':
            cmd += ' -f 3'  # generic mpeg-2 video
        else:
            cmd += ' -f 0'  # generic mpeg-1 video
        if self._prop['vbitrate'] is not None:
            cmd += ' -b %d' % int(self._prop['vbitrate'])
        if self._prop['vbuffer'] is not None:
            cmd += ' -V %d' % int(self._prop['vbuffer'])
        if self._prop['qscale'] is not None:
            cmd += ' -q %s' % self._prop['qscale']

        # set movie frame rate:
        legal_fps = {
            '23.976': 1,
            '24': 2,
            '25': 3,
            '29.97': 4,
            '30': 5,
            '50': 6,
            '59.94': 7,
            '60': 8
        }
        fps = str(self._prop['fps'])
        if not fps in legal_fps:
            raise ValueError("fps must be %s, not %s" % \
                             (fps_convert.keys(), fps))
        cmd += ' -F %s' % legal_fps[fps]
        #cmd += ' --cbr' # constant bit rate
        gop_size = self._prop['gop_size']
        if gop_size is not None:
            # set min (-g) and max (-G) gop size to the same value:
            cmd += ' -g %s -G %s' % (gop_size, gop_size)

        # set aspect ratio:
        legal_aspects = {'1.0': 1, '1.3': 2, '1.7': 3, '2.21': 4}
        aspect = self._get_aspect_ratio()
        if aspect is not None:
            if aspect not in legal_aspects.values():
                aspect = str(aspect)
                for key in legal_aspects.keys():
                    if aspect.startswith(key):
                        aspect = legal_aspects[key]
                        break
                if aspect not in legal_aspects.values():
                    raise ValueError(
                        "aspect must be either 1:1, 4:3, 16:9, or 2.21:1," \
                        " not '%s'" % aspect)
            cmd += ' -a %s' % aspect

        # set output file:
        cmd += ' -o %s' % self._prop['output_file']
        if self._prop['quiet']:
            cmd += ' -v 0'  # verbosity level 0 (warnings and errors only)
        return cmd
示例#9
0
文件: movie.py 项目: terjekv/scitools
    def __init__(self, input_files, **kwargs):
        self._prop = {}
        self._prop.update(self._local_prop)
        self._prop['input_files'] = input_files
        for key in kwargs:
            if key in self._prop:
                self._prop[key] = kwargs[key]

        print '\n\n'  # provide some space before print statements

        # Determine which encoder to be used
        encoder = self._prop['encoder']
        if encoder is None:
            # No encoder given, find the first installed among the legal ones
            for enc in self._legal_encoders:
                if findprograms(enc):
                    encoder = enc
                    break
            if encoder is None:
                # No encoder is installed, fall back on html
                encoder = 'html'
            self._prop['encoder'] = encoder
        else:
            if not encoder in self._legal_encoders:
                raise ValueError("encoder must be %s, not '%s'" %
                                 (self._legal_encoders, encoder))
            if not encoder.startswith('html') and not findprograms(encoder):
                raise Exception("The selected encoder (%s) is not installed" \
                                % encoder)

        # Determine the file type of the input files
        if isinstance(input_files, (tuple, list)):
            file_ = input_files[0]
        elif isinstance(input_files, str):
            file_ = input_files
        else:
            raise ValueError("The input files must be given as either a "\
                             "list/tuple of strings or a string, not '%s'" % \
                             type(input_files))

        # Check that the input files do exist
        if isinstance(input_files, str):
            # Are input_files on ffmpeg/mpeg2enc format or Unix wildcard format?
            ffmpeg_format = r'(.+)%\d+d(\..+)'
            m = re.search(ffmpeg_format, input_files, re.DOTALL)
            if m:
                wildcard_format = m.group(1) + '*' + m.group(2)
            else:
                wildcard_format = input_files
            all_input_files = glob.glob(wildcard_format)
            if not all_input_files:
                print 'No files of the form %s exist.' % input_files
            else:
                print 'Found %d files of the format %s.' % \
                (len(all_input_files), input_files)
        else:  # list of specific filenames
            all_input_files = input_files
        error_encountered = False
        for f in all_input_files:
            if not os.path.isfile(f):
                print 'Input file %s does not exist.' % f
                error_encountered = True
        if error_encountered:
            raise IOError('Some input files were not found.')

        fname, ext = os.path.splitext(file_)
        if not ext:
            raise ValueError("Unable to determine file type from file name.")
        file_type = ext[1:]  # remove the . (dot)
        if not file_type in self._legal_file_types:
            raise TypeError("File type must be %s, not '%s'" % \
                            (self._legal_file_types, file_type))
        self._prop['file_type'] = file_type
示例#10
0
NOTES:

- 3D arrays are currently not supported.
"""


from .common import *
from scitools.globaldata import DEBUG, VERBOSE
from scitools.misc import findprograms

import os
import tempfile


MATLAB_CMD_STR = os.environ.get('MATLAB_CMD_STR', "matlab -nosplash -nojvm")
has_matlab = findprograms('matlab')


class Matlab2Backend(BaseClass):

    def __init__(self):
        BaseClass.__init__(self)
        self._init()

    def _init(self, *args, **kwargs):
        """Perform initialization that is special for this backend."""

        self.figure(self.getp('curfig'))
        # set show and interactive to False as deafult:
        self.setp(show=False, interactive=False)
        self._script = ""
示例#11
0
programs = {
    'gnuplot': 'plotting program',
    'gs': 'ghostscript, ps/pdf interpreter and previewer',
    'ps2pdf': 'ps/pdf converter, part of ghostscript',
    'convert': 'image conversion, part of the ImageMagick package',
    'animate': 'animation viewer, part of the ImageMagick package',
    'display': 'image viewer, part of the ImageMagick package',
    'latex': 'mathematical typesetting tool',
    'dvips': 'tool for converting latex to ps',
    'happydoc': 'generation of Python code documentation from doc strings',
    'epydoc': 'generation of Python code documentation from doc strings',
    'f2py': 'generator for Python interfaces to F77',
    'swig': 'generator for Python/Perl/Tcl interfaces to C/C++',
}

installed = findprograms(programs.keys())
for program in installed.keys():
    if installed[program] is not None:
        print "You have %s (%s)\n   in %s" % \
              (program, programs[program], installed[program])
    else:
        print "*** Program", program, "was not found on the system"
        if sys.platform.startswith('win') and program in ('latex', 'dvips'):
            print "*** You don't have latex/dvips but on Windows this is usual"
        elif sys.platform.startswith('win') and program == 'gs':
            # no link/script turning C:\gs\gs814... into 'gs', that's ok
            pass
        else:
            print "           .....(%s)" % programs[program]

# check if Gnuplot is compiled with PNG support
示例#12
0
文件: test1.py 项目: HunterAllman/kod
#!/usr/bin/env python
import os, shutil, glob
os.chdir(os.pardir)
shutil.copy('main.f.orig', 'main.f')
shutil.copy('F77WAVE.fcp.orig', 'F77WAVE.fcp')

# edit main.f such that solutions are dumped,
# also use a small grid
os.system("perl -pi.old~ -e 's#^C(\s+)call dump# $1call dump#' main.f")
os.system("perl -pi.old~ -e 's#^[^C]\s+PARAMETER \(n=(\d+)\)#      PARAMETER (n=31)#' main.f")
os.system("./make.sh")
os.chdir("Verify")
tmpfiles = glob.glob("tmp_*.mtv")
for file in tmpfiles: os.remove(file)
f = open('tmp.input', 'w')
f.write('20\n') # no of time steps
f.close()
os.system("../app < tmp.input")

# show on the screen:
from scitools.misc import findprograms
if findprograms(['plotmtv'], write_message=1):
    os.system("plotmtv -geometry 600x700 -nodate -3d tmp_*.mtv")
    

示例#13
0
- 3D arrays are currently not supported.
"""

from __future__ import division

from .common import *
from scitools.globaldata import DEBUG, VERBOSE
from scitools.misc import findprograms

import os
import tempfile


MATLAB_CMD_STR = os.environ.get('MATLAB_CMD_STR', "matlab -nosplash -nojvm")
has_matlab = findprograms('matlab')


class Matlab2Backend(BaseClass):
    def __init__(self):
        BaseClass.__init__(self)
        self._init()

    def _init(self, *args, **kwargs):
        """Perform initialization that is special for this backend."""

        self.figure(self.getp('curfig'))
        # set show and interactive to False as deafult:
        self.setp(show=False, interactive=False)
        self._script = ""
示例#14
0
programs = {
    "gnuplot": "plotting program",
    "gs": "ghostscript, ps/pdf interpreter and previewer",
    "ps2pdf": "ps/pdf converter, part of ghostscript",
    "convert": "image conversion, part of the ImageMagick package",
    "animate": "animation viewer, part of the ImageMagick package",
    "display": "image viewer, part of the ImageMagick package",
    "latex": "mathematical typesetting tool",
    "dvips": "tool for converting latex to ps",
    "happydoc": "generation of Python code documentation from doc strings",
    "epydoc": "generation of Python code documentation from doc strings",
    "f2py": "generator for Python interfaces to F77",
    "swig": "generator for Python/Perl/Tcl interfaces to C/C++",
}

installed = findprograms(programs.keys())
for program in installed.keys():
    if installed[program] is not None:
        print "You have %s (%s)\n   in %s" % (program, programs[program], installed[program])
    else:
        print "*** Program", program, "was not found on the system"
        if sys.platform.startswith("win") and program in ("latex", "dvips"):
            print "*** You don't have latex/dvips but on Windows this is usual"
        elif sys.platform.startswith("win") and program == "gs":
            # no link/script turning C:\gs\gs814... into 'gs', that's ok
            pass
        else:
            print "           .....(%s)" % programs[program]

# check if Gnuplot is compiled with PNG support
# (we test this on Unix only where PNG support can be forgotten in
示例#15
0
#!/usr/bin/env python
import os, shutil, glob

os.chdir(os.pardir)
shutil.copy('main.f.orig', 'main.f')
shutil.copy('F77WAVE.fcp.orig', 'F77WAVE.fcp')

# edit main.f such that solutions are dumped,
# also use a small grid
os.system("perl -pi.old~ -e 's#^C(\s+)call dump# $1call dump#' main.f")
os.system(
    "perl -pi.old~ -e 's#^[^C]\s+PARAMETER \(n=(\d+)\)#      PARAMETER (n=31)#' main.f"
)
os.system("./make.sh")
os.chdir("Verify")
tmpfiles = glob.glob("tmp_*.mtv")
for file in tmpfiles:
    os.remove(file)
f = open('tmp.input', 'w')
f.write('20\n')  # no of time steps
f.close()
os.system("../app < tmp.input")

# show on the screen:
from scitools.misc import findprograms
if findprograms(['plotmtv'], write_message=1):
    os.system("plotmtv -geometry 600x700 -nodate -3d tmp_*.mtv")