How to use the pydot.InvocationException function in pydot

To help you get started, we’ve selected a few pydot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rizar / attention-lvcsr / libs / Theano / theano / printing.py View on Github external
new_name = basename + '_' + str(idx)
            new_name = os.path.join(path, new_name + ext)
            if hasattr(scan_op.op, 'fn'):
                to_print = scan_op.op.fn
            else:
                to_print = scan_op.op.outputs
            pydotprint(to_print, new_name, compact, format, with_ids,
                       high_contrast, cond_highlight, colorCodes,
                       max_label_size, scan_graphs)

    if return_image:
        return g.create(prog='dot', format=format)
    else:
        try:
            g.write(outfile, prog='dot', format=format)
        except pd.InvocationException:
            # based on https://github.com/Theano/Theano/issues/2988
            version = getattr(pd, '__version__', "")
            if version and [int(n) for n in version.split(".")] < [1, 0, 28]:
                raise Exception("Old version of pydot detected, which can "
                                "cause issues with pydot printing. Try "
                                "upgrading pydot version to a newer one")
            raise

        if print_output_file:
            print('The output file is available at', outfile)
github kevinw / gitviz / pydot.py View on Github external
stderr_output = list()
            while True:
                data = stderr.read()
                if not data:
                    break
                stderr_output.append(data)
            stderr.close()
                
            if stderr_output:
                stderr_output = ''.join(stderr_output)
            
        #pid, status = os.waitpid(p.pid, 0)
        status = p.wait()
        
        if status != 0 :
            raise InvocationException(
                'Program terminated with status: %d. stderr follows: %s' % (
                    status, stderr_output) )
        elif stderr_output:
            print stderr_output
        
        # For each of the image files...
        #
        for img in self.shape_files:
        
            # remove it
            #
            os.unlink( os.path.join( tmp_dir, os.path.basename(img) ) )

        os.unlink(tmp_name)
        
        return stdout_output
github Theano / Theano / theano / printing.py View on Github external
new_name = basename + '_' + str(idx)
            new_name = os.path.join(path, new_name + ext)
            if hasattr(scan_op.op, 'fn'):
                to_print = scan_op.op.fn
            else:
                to_print = scan_op.op.outputs
            pydotprint(to_print, new_name, compact, format, with_ids,
                       high_contrast, cond_highlight, colorCodes,
                       max_label_size, scan_graphs)

    if return_image:
        return g.create(prog='dot', format=format)
    else:
        try:
            g.write(outfile, prog='dot', format=format)
        except pd.InvocationException:
            # based on https://github.com/Theano/Theano/issues/2988
            version = getattr(pd, '__version__', "")
            if version and [int(n) for n in version.split(".")] < [1, 0, 28]:
                raise Exception("Old version of pydot detected, which can "
                                "cause issues with pydot printing. Try "
                                "upgrading pydot version to a newer one")
            raise

        if print_output_file:
            print('The output file is available at', outfile)
github dmitriy-serdyuk / twinnet-asr / libs / Theano / theano / printing.py View on Github external
new_name = basename + '_' + str(idx)
            new_name = os.path.join(path, new_name + ext)
            if hasattr(scan_op.op, 'fn'):
                to_print = scan_op.op.fn
            else:
                to_print = scan_op.op.outputs
            pydotprint(to_print, new_name, compact, format, with_ids,
                       high_contrast, cond_highlight, colorCodes,
                       max_label_size, scan_graphs)

    if return_image:
        return g.create(prog='dot', format=format)
    else:
        try:
            g.write(outfile, prog='dot', format=format)
        except pd.InvocationException:
            # based on https://github.com/Theano/Theano/issues/2988
            version = getattr(pd, '__version__', "")
            if version and [int(n) for n in version.split(".")] < [1, 0, 28]:
                raise Exception("Old version of pydot detected, which can "
                                "cause issues with pydot printing. Try "
                                "upgrading pydot version to a newer one")
            raise

        if print_output_file:
            print('The output file is available at', outfile)
github vincenthEE / DotEditor / pydot.py View on Github external
[ 'twopi', '-Tdot', '-s10' ]
        """
        
        if prog is None:
            prog = self.prog
            
        if isinstance(prog, (list, tuple)):
            prog, args = prog[0], prog[1:]
        else:
            args = []
        
            
        if self.progs is None:
            self.progs = find_graphviz()
            if self.progs is None:
                raise InvocationException(
                    'GraphViz\'s executables not found' )
                
        if not self.progs.has_key(prog):
            raise InvocationException(
                'GraphViz\'s executable "%s" not found' % prog )
            
        if not os.path.exists( self.progs[prog] ) or not os.path.isfile( self.progs[prog] ):
            raise InvocationException(
                'GraphViz\'s executable "%s" is not a file or doesn\'t exist' % self.progs[prog] )
            
            
        tmp_fd, tmp_name = tempfile.mkstemp()
        os.close(tmp_fd)
        self.write(tmp_name)
        tmp_dir = os.path.dirname(tmp_name )
github vincenthEE / DotEditor / pydot.py View on Github external
else:
            args = []
        
            
        if self.progs is None:
            self.progs = find_graphviz()
            if self.progs is None:
                raise InvocationException(
                    'GraphViz\'s executables not found' )
                
        if not self.progs.has_key(prog):
            raise InvocationException(
                'GraphViz\'s executable "%s" not found' % prog )
            
        if not os.path.exists( self.progs[prog] ) or not os.path.isfile( self.progs[prog] ):
            raise InvocationException(
                'GraphViz\'s executable "%s" is not a file or doesn\'t exist' % self.progs[prog] )
            
            
        tmp_fd, tmp_name = tempfile.mkstemp()
        os.close(tmp_fd)
        self.write(tmp_name)
        tmp_dir = os.path.dirname(tmp_name )
        
        # For each of the image files...
        #
        for img in self.shape_files:
        
            # Get its data
            #
            f = file(img, 'rb')
            f_data = f.read()
github kevinw / gitviz / pydot.py View on Github external
if prog is None:
            prog = self.prog
            
        if isinstance(prog, (list, tuple)):
            prog, args = prog[0], prog[1:]
        else:
            args = []
            
        if self.progs is None:
            self.progs = find_graphviz()
            if self.progs is None:
                raise InvocationException(
                    'GraphViz\'s executables not found' )
                
        if not self.progs.has_key(prog):
            raise InvocationException(
                'GraphViz\'s executable "%s" not found' % prog )
            
        if not os.path.exists( self.progs[prog] ) or not os.path.isfile( self.progs[prog] ):
            raise InvocationException(
                'GraphViz\'s executable "%s" is not a file or doesn\'t exist' % self.progs[prog] )
            
            
        tmp_fd, tmp_name = tempfile.mkstemp()
        os.close(tmp_fd)
        self.write(tmp_name)
        tmp_dir = os.path.dirname(tmp_name )
        
        # For each of the image files...
        #
        for img in self.shape_files:
github kevinw / gitviz / pydot.py View on Github external
[ 'twopi', '-Tdot', '-s10' ]
        """
        
        if prog is None:
            prog = self.prog
            
        if isinstance(prog, (list, tuple)):
            prog, args = prog[0], prog[1:]
        else:
            args = []
            
        if self.progs is None:
            self.progs = find_graphviz()
            if self.progs is None:
                raise InvocationException(
                    'GraphViz\'s executables not found' )
                
        if not self.progs.has_key(prog):
            raise InvocationException(
                'GraphViz\'s executable "%s" not found' % prog )
            
        if not os.path.exists( self.progs[prog] ) or not os.path.isfile( self.progs[prog] ):
            raise InvocationException(
                'GraphViz\'s executable "%s" is not a file or doesn\'t exist' % self.progs[prog] )
            
            
        tmp_fd, tmp_name = tempfile.mkstemp()
        os.close(tmp_fd)
        self.write(tmp_name)
        tmp_dir = os.path.dirname(tmp_name )