##// END OF EJS Templates
create static/custom in skeleton profiles
MinRK -
Show More
@@ -11,7 +11,7 b' Authors:'
11 """
11 """
12
12
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14 # Copyright (C) 2008-2011 The IPython Development Team
14 # Copyright (C) 2011 The IPython Development Team
15 #
15 #
16 # Distributed under the terms of the BSD License. The full license is in
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
17 # the file COPYING, distributed as part of this software.
@@ -60,10 +60,12 b' class ProfileDir(LoggingConfigurable):'
60 log_dir_name = Unicode('log')
60 log_dir_name = Unicode('log')
61 startup_dir_name = Unicode('startup')
61 startup_dir_name = Unicode('startup')
62 pid_dir_name = Unicode('pid')
62 pid_dir_name = Unicode('pid')
63 static_dir_name = Unicode('static')
63 security_dir = Unicode(u'')
64 security_dir = Unicode(u'')
64 log_dir = Unicode(u'')
65 log_dir = Unicode(u'')
65 startup_dir = Unicode(u'')
66 startup_dir = Unicode(u'')
66 pid_dir = Unicode(u'')
67 pid_dir = Unicode(u'')
68 static_dir = Unicode(u'')
67
69
68 location = Unicode(u'', config=True,
70 location = Unicode(u'', config=True,
69 help="""Set the profile location directly. This overrides the logic used by the
71 help="""Set the profile location directly. This overrides the logic used by the
@@ -84,6 +86,7 b' class ProfileDir(LoggingConfigurable):'
84 self.log_dir = os.path.join(new, self.log_dir_name)
86 self.log_dir = os.path.join(new, self.log_dir_name)
85 self.startup_dir = os.path.join(new, self.startup_dir_name)
87 self.startup_dir = os.path.join(new, self.startup_dir_name)
86 self.pid_dir = os.path.join(new, self.pid_dir_name)
88 self.pid_dir = os.path.join(new, self.pid_dir_name)
89 self.static_dir = os.path.join(new, self.static_dir_name)
87 self.check_dirs()
90 self.check_dirs()
88
91
89 def _log_dir_changed(self, name, old, new):
92 def _log_dir_changed(self, name, old, new):
@@ -153,11 +156,29 b' class ProfileDir(LoggingConfigurable):'
153 def check_pid_dir(self):
156 def check_pid_dir(self):
154 self._mkdir(self.pid_dir, 0o40700)
157 self._mkdir(self.pid_dir, 0o40700)
155
158
159 def _static_dir_changed(self, name, old, new):
160 self.check_startup_dir()
161
162 def check_static_dir(self):
163 self._mkdir(self.static_dir)
164 custom = os.path.join(self.static_dir, 'custom')
165 self._mkdir(custom)
166 from IPython.html import DEFAULT_STATIC_FILES_PATH
167 for fname in ('custom.js', 'custom.css'):
168 src = os.path.join(DEFAULT_STATIC_FILES_PATH, 'custom', fname)
169 dest = os.path.join(custom, fname)
170 if not os.path.exists(src):
171 self.log.warn("Could not copy default file to static dir. Source file %s does not exist.", src)
172 continue
173 if not os.path.exists(dest):
174 shutil.copy(src, dest)
175
156 def check_dirs(self):
176 def check_dirs(self):
157 self.check_security_dir()
177 self.check_security_dir()
158 self.check_log_dir()
178 self.check_log_dir()
159 self.check_pid_dir()
179 self.check_pid_dir()
160 self.check_startup_dir()
180 self.check_startup_dir()
181 self.check_static_dir()
161
182
162 def copy_config_file(self, config_file, path=None, overwrite=False):
183 def copy_config_file(self, config_file, path=None, overwrite=False):
163 """Copy a default config file into the active profile directory.
184 """Copy a default config file into the active profile directory.
General Comments 0
You need to be logged in to leave comments. Login now