##// END OF EJS Templates
add startup_dir to profiles...
MinRK -
Show More
@@ -59,9 +59,11 b' class ProfileDir(LoggingConfigurable):'
59 59
60 60 security_dir_name = Unicode('security')
61 61 log_dir_name = Unicode('log')
62 startup_dir_name = Unicode('startup')
62 63 pid_dir_name = Unicode('pid')
63 64 security_dir = Unicode(u'')
64 65 log_dir = Unicode(u'')
66 startup_dir = Unicode(u'')
65 67 pid_dir = Unicode(u'')
66 68
67 69 location = Unicode(u'', config=True,
@@ -81,6 +83,7 b' class ProfileDir(LoggingConfigurable):'
81 83 # ensure config files exist:
82 84 self.security_dir = os.path.join(new, self.security_dir_name)
83 85 self.log_dir = os.path.join(new, self.log_dir_name)
86 self.startup_dir = os.path.join(new, self.startup_dir_name)
84 87 self.pid_dir = os.path.join(new, self.pid_dir_name)
85 88 self.check_dirs()
86 89
@@ -91,6 +94,13 b' class ProfileDir(LoggingConfigurable):'
91 94 if not os.path.isdir(self.log_dir):
92 95 os.mkdir(self.log_dir)
93 96
97 def _startup_dir_changed(self, name, old, new):
98 self.check_startup_dir()
99
100 def check_startup_dir(self):
101 if not os.path.isdir(self.startup_dir):
102 os.mkdir(self.startup_dir)
103
94 104 def _security_dir_changed(self, name, old, new):
95 105 self.check_security_dir()
96 106
@@ -22,6 +22,7 b' Authors'
22 22
23 23 from __future__ import absolute_import
24 24
25 import glob
25 26 import os
26 27 import sys
27 28
@@ -175,6 +176,7 b' class InteractiveShellApp(Configurable):'
175 176
176 177 def init_code(self):
177 178 """run the pre-flight code, specified via exec_lines"""
179 self._run_startup_files()
178 180 self._run_exec_lines()
179 181 self._run_exec_files()
180 182 self._run_cmd_line_code()
@@ -230,6 +232,22 b' class InteractiveShellApp(Configurable):'
230 232 finally:
231 233 sys.argv = save_argv
232 234
235 def _run_startup_files(self):
236 """Run files from profile startup directory"""
237 startup_dir = self.profile_dir.startup_dir
238 startup_files = glob.glob(os.path.join(startup_dir, '*.py'))
239 startup_files += glob.glob(os.path.join(startup_dir, '*.ipy'))
240 if not startup_files:
241 return
242
243 self.log.debug("Running startup files from %s...", startup_dir)
244 try:
245 for fname in sorted(startup_files):
246 self._exec_file(fname)
247 except:
248 self.log.warn("Unknown error in handling startup files:")
249 self.shell.showtraceback()
250
233 251 def _run_exec_files(self):
234 252 """Run files from IPythonApp.exec_files"""
235 253 if not self.exec_files:
General Comments 0
You need to be logged in to leave comments. Login now