##// END OF EJS Templates
make destination configurable
Matthias BUSSONNIER -
Show More
@@ -58,13 +58,13 b' from IPython.utils.path import locate_profile'
58
58
59 # Where mathjax will be installed.
59 # Where mathjax will be installed.
60
60
61 dest = os.path.join(locate_profile('default'), 'static')
61 default_dest = os.path.join(locate_profile('default'), 'static')
62
62
63 ##
63 ##
64
64
65 # Test for access to install mathjax.
65 # Test for access to install mathjax.
66
66
67 def check_perms(replace=False):
67 def check_perms(replace=False, dest=default_dest):
68 if not os.access(static, os.W_OK):
68 if not os.access(static, os.W_OK):
69 raise IOError("Need have write access to %s" % static)
69 raise IOError("Need have write access to %s" % static)
70 if os.path.exists(dest):
70 if os.path.exists(dest):
@@ -115,7 +115,7 b' def extract_zip( fd, dest ) :'
115
115
116 ##
116 ##
117
117
118 def install_mathjax(tag='v2.0', replace=False, file=None, extractor=extract_tar ):
118 def install_mathjax(tag='v2.0', dest=default_dest, replace=False, file=None, extractor=extract_tar ):
119 """Download and/or install MathJax for offline use.
119 """Download and/or install MathJax for offline use.
120
120
121 This will install mathjax to the 'static' dir in the IPython notebook
121 This will install mathjax to the 'static' dir in the IPython notebook
@@ -129,6 +129,8 b" def install_mathjax(tag='v2.0', replace=False, file=None, extractor=extract_tar "
129
129
130 replace : bool [False]
130 replace : bool [False]
131 Whether to remove and replace an existing install.
131 Whether to remove and replace an existing install.
132 dest : str [path to default profile]
133 Where to locally install mathjax
132 tag : str ['v2.0']
134 tag : str ['v2.0']
133 Which tag to download. Default is 'v2.0', the current stable release,
135 Which tag to download. Default is 'v2.0', the current stable release,
134 but alternatives include 'v1.1a' and 'master'.
136 but alternatives include 'v1.1a' and 'master'.
@@ -138,7 +140,7 b" def install_mathjax(tag='v2.0', replace=False, file=None, extractor=extract_tar "
138 Method tu use to untar/unzip/... `file`
140 Method tu use to untar/unzip/... `file`
139 """
141 """
140
142
141 if not check_perms(replace) :
143 if not check_perms(replace, dest=dest) :
142 return
144 return
143
145
144 if file is None :
146 if file is None :
@@ -153,7 +155,7 b" def install_mathjax(tag='v2.0', replace=False, file=None, extractor=extract_tar "
153
155
154 ##
156 ##
155
157
156 def test_func( remove ) :
158 def test_func( remove, dest=default_dest) :
157 """See if mathjax appears to be installed correctly"""
159 """See if mathjax appears to be installed correctly"""
158 if not os.path.isdir( dest ) :
160 if not os.path.isdir( dest ) :
159 print "%s directory not found"%dest
161 print "%s directory not found"%dest
@@ -191,7 +193,7 b' def main( args ) :'
191
193
192 # undocumented test interface
194 # undocumented test interface
193 if '-test' in args :
195 if '-test' in args :
194 return test_func( replace )
196 return test_func( replace, dest=dest)
195
197
196 # do it
198 # do it
197 if len(args) == 0 :
199 if len(args) == 0 :
General Comments 0
You need to be logged in to leave comments. Login now