Run files from profile startup directory
(self)
| 354 | sys.argv = save_argv |
| 355 | |
| 356 | def _run_startup_files(self): |
| 357 | """Run files from profile startup directory""" |
| 358 | startup_dirs = [self.profile_dir.startup_dir] + [ |
| 359 | os.path.join(p, 'startup') for p in chain(ENV_CONFIG_DIRS, SYSTEM_CONFIG_DIRS) |
| 360 | ] |
| 361 | startup_files = [] |
| 362 | |
| 363 | if self.exec_PYTHONSTARTUP and os.environ.get('PYTHONSTARTUP', False) and \ |
| 364 | not (self.file_to_run or self.code_to_run or self.module_to_run): |
| 365 | python_startup = os.environ['PYTHONSTARTUP'] |
| 366 | self.log.debug("Running PYTHONSTARTUP file %s...", python_startup) |
| 367 | try: |
| 368 | self._exec_file(python_startup) |
| 369 | except: |
| 370 | self.log.warning("Unknown error in handling PYTHONSTARTUP file %s:", python_startup) |
| 371 | self.shell.showtraceback() |
| 372 | for startup_dir in startup_dirs[::-1]: |
| 373 | startup_files += glob.glob(os.path.join(startup_dir, '*.py')) |
| 374 | startup_files += glob.glob(os.path.join(startup_dir, '*.ipy')) |
| 375 | if not startup_files: |
| 376 | return |
| 377 | |
| 378 | self.log.debug("Running startup files from %s...", startup_dir) |
| 379 | try: |
| 380 | for fname in sorted(startup_files): |
| 381 | self._exec_file(fname) |
| 382 | except: |
| 383 | self.log.warning("Unknown error in handling startup files:") |
| 384 | self.shell.showtraceback() |
| 385 | |
| 386 | def _run_exec_files(self): |
| 387 | """Run files from IPythonApp.exec_files""" |
no test coverage detected