Show More
@@ -71,8 +71,20 b" default_dest = os.path.join(static, 'mathjax')" | |||||
71 |
|
71 | |||
72 | def check_perms(dest, replace=False): |
|
72 | def check_perms(dest, replace=False): | |
73 | parent = os.path.abspath(os.path.join(dest, os.path.pardir)) |
|
73 | parent = os.path.abspath(os.path.join(dest, os.path.pardir)) | |
74 | if not os.access(parent, os.W_OK): |
|
74 | components = dest.split(os.path.sep) | |
|
75 | subpaths = [ os.path.sep+os.path.sep.join(components[1:i]) for i in range(1,len(components))] | |||
|
76 | ||||
|
77 | existing_path = filter(os.path.exists, subpaths) | |||
|
78 | last_writable = existing_path[-1] | |||
|
79 | if not os.access(last_writable, os.W_OK): | |||
75 | raise IOError("Need have write access to %s" % parent) |
|
80 | raise IOError("Need have write access to %s" % parent) | |
|
81 | not_existing = [ path for path in subpaths if path not in existing_path] | |||
|
82 | # subfolder we will create, will obviously be writable | |||
|
83 | # should we still considere checking separately that | |||
|
84 | # ipython profiles have been created ? | |||
|
85 | for folder in not_existing: | |||
|
86 | os.mkdir(folder) | |||
|
87 | ||||
76 | if os.path.exists(dest): |
|
88 | if os.path.exists(dest): | |
77 | if replace: |
|
89 | if replace: | |
78 | if not os.access(dest, os.W_OK): |
|
90 | if not os.access(dest, os.W_OK): |
General Comments 0
You need to be logged in to leave comments.
Login now