##// END OF EJS Templates
Cleanup
Jonathan Frederic -
Show More
@@ -23,8 +23,9 b' from io import TextIOWrapper, BytesIO'
23 # IPython imports
23 # IPython imports
24 from IPython.nbconvert.utils.pandoc import pandoc
24 from IPython.nbconvert.utils.pandoc import pandoc
25 from IPython.nbconvert.utils.exceptions import ConversionException
25 from IPython.nbconvert.utils.exceptions import ConversionException
26 from IPython.utils.process import find_cmd, FindCmdError, getoutput
26 from IPython.utils.process import get_output_error_code
27 from IPython.utils.py3compat import cast_bytes
27 from IPython.utils.py3compat import cast_bytes
28 from IPython.utils.version import check_version
28
29
29 #-----------------------------------------------------------------------------
30 #-----------------------------------------------------------------------------
30 # Functions
31 # Functions
@@ -108,23 +109,13 b' def _verify_node(cmd):'
108 cmd : string
109 cmd : string
109 Node command to verify (i.e 'node')."""
110 Node command to verify (i.e 'node')."""
110 try:
111 try:
111 find_cmd(node_cmd)
112 out, err, return_code = get_output_error_code([cmd, '--version'])
112 except FindCmdError:
113 except OSError:
113 return False
114 # Command not found
114 else:
115 # Remove the version 'v' prefix from the output and strip whitespace.
116 version_str = getoutput(cmd + ' --version').replace('v', '').strip()
117 try:
118 # Make sure the node version is atleast 0.9.12
119 version_numbers = [int(x) for x in version_str.split('.')]
120 if version_numbers[0] > 0 or version_numbers[1] > 9 or (version_numbers[1] == 9 and version_numbers[2] >= 12):
121 return True
122 else:
123 return False
124 except:
125 return False
115 return False
116 return return_code == 0 and check_version(out.lstrip('v'), '0.9.12')
126
117
127 # prefer md2html via marked if node.js is available
118 # prefer md2html via marked if node.js >= 0.9.12 is available
128 # node is called nodejs on debian, so try that first
119 # node is called nodejs on debian, so try that first
129 node_cmd = 'nodejs'
120 node_cmd = 'nodejs'
130 if _verify_node(node_cmd):
121 if _verify_node(node_cmd):
General Comments 0
You need to be logged in to leave comments. Login now