From 5fe1a213f9a958c5ea382e746715d3b8e242226b 2012-12-28 17:46:38 From: Bussonnier Matthias Date: 2012-12-28 17:46:38 Subject: [PATCH] fix testing all subpath where to install mathjax --- diff --git a/IPython/external/mathjax.py b/IPython/external/mathjax.py index 9ac9d31..37590fe 100644 --- a/IPython/external/mathjax.py +++ b/IPython/external/mathjax.py @@ -71,8 +71,20 @@ default_dest = os.path.join(static, 'mathjax') def check_perms(dest, replace=False): parent = os.path.abspath(os.path.join(dest, os.path.pardir)) - if not os.access(parent, os.W_OK): + components = dest.split(os.path.sep) + subpaths = [ os.path.sep+os.path.sep.join(components[1:i]) for i in range(1,len(components))] + + existing_path = filter(os.path.exists, subpaths) + last_writable = existing_path[-1] + if not os.access(last_writable, os.W_OK): raise IOError("Need have write access to %s" % parent) + not_existing = [ path for path in subpaths if path not in existing_path] + # subfolder we will create, will obviously be writable + # should we still considere checking separately that + # ipython profiles have been created ? + for folder in not_existing: + os.mkdir(folder) + if os.path.exists(dest): if replace: if not os.access(dest, os.W_OK):