Commits

Georg Brandl committed b53767c

#301: use errno values from errno module.

  • Participants
  • Parent commits 87bf956

Comments (0)

Files changed (4)

File sphinx/builders/__init__.py

 from docutils import nodes
 
 from sphinx import package_dir, locale
-from sphinx.util import SEP, relative_uri
+from sphinx.util import SEP, EEXIST, relative_uri
 from sphinx.environment import BuildEnvironment
 from sphinx.util.console import bold, purple, darkgreen, term_width_line
 
                     path.join(self.doctreedir, ENV_PICKLE_FILENAME))
                 self.info('done')
             except Exception, err:
-                if type(err) is IOError and err.errno == 2:
+                if type(err) is IOError and err.errno == EEXIST:
                     self.info('not found')
                 else:
                     self.info('failed: %s' % err)

File sphinx/ext/graphviz.py

 from docutils import nodes
 
 from sphinx.errors import SphinxError
-from sphinx.util import ensuredir
+from sphinx.util import ensuredir, ENOENT
 from sphinx.util.compat import Directive
 
 
     try:
         p = Popen(dot_args, stdout=PIPE, stdin=PIPE, stderr=PIPE)
     except OSError, err:
-        if err.errno != 2:   # No such file or directory
+        if err.errno != ENOENT:   # No such file or directory
             raise
         self.builder.warn('dot command %r cannot be run (needed for graphviz '
                           'output), check the graphviz_dot setting' %

File sphinx/ext/pngmath.py

 from docutils import nodes
 
 from sphinx.errors import SphinxError
-from sphinx.util import ensuredir
+from sphinx.util import ensuredir, ENOENT
 from sphinx.util.png import read_png_depth, write_png_depth
 from sphinx.ext.mathbase import setup_math as mathbase_setup, wrap_displaymath
 
         try:
             p = Popen(ltx_args, stdout=PIPE, stderr=PIPE)
         except OSError, err:
-            if err.errno != 2:   # No such file or directory
+            if err.errno != ENOENT:   # No such file or directory
                 raise
             self.builder.warn('LaTeX command %r cannot be run (needed for math '
                               'display), check the pngmath_latex setting' %
     try:
         p = Popen(dvipng_args, stdout=PIPE, stderr=PIPE)
     except OSError, err:
-        if err.errno != 2:   # No such file or directory
+        if err.errno != ENOENT:   # No such file or directory
             raise
         self.builder.warn('dvipng command %r cannot be run (needed for math '
                           'display), check the pngmath_dvipng setting' %

File sphinx/util/__init__.py

 import docutils
 import sphinx
 
+# Errnos that we need.
+EEXIST = getattr(errno, 'EEXIST', 0)
+ENOENT = getattr(errno, 'ENOENT', 0)
 
 # Generally useful regular expressions.
 ws_re = re.compile(r'\s+')
         os.makedirs(path)
     except OSError, err:
         # 0 for Jython/Win32
-        if err.errno not in [0, getattr(errno, 'EEXIST', 0)]:
+        if err.errno not in [0, EEXIST]:
             raise