Run files from profile startup directory
(self)
| 413 | sys.argv = save_argv |
| 414 | |
| 415 | def _run_startup_files(self): |
| 416 | """Run files from profile startup directory""" |
| 417 | startup_dirs = [self.profile_dir.startup_dir] + [ |
| 418 | os.path.join(p, 'startup') for p in chain(ENV_CONFIG_DIRS, SYSTEM_CONFIG_DIRS) |
| 419 | ] |
| 420 | startup_files = [] |
| 421 | |
| 422 | if self.exec_PYTHONSTARTUP and os.environ.get('PYTHONSTARTUP', False) and \ |
| 423 | not (self.file_to_run or self.code_to_run or self.module_to_run): |
| 424 | python_startup = os.environ['PYTHONSTARTUP'] |
| 425 | self.log.debug("Running PYTHONSTARTUP file %s...", python_startup) |
| 426 | try: |
| 427 | self._exec_file(python_startup) |
| 428 | except: |
| 429 | self.log.warning("Unknown error in handling PYTHONSTARTUP file %s:", python_startup) |
| 430 | self.shell.showtraceback() |
| 431 | for startup_dir in startup_dirs[::-1]: |
| 432 | startup_files += glob.glob(os.path.join(startup_dir, '*.py')) |
| 433 | startup_files += glob.glob(os.path.join(startup_dir, '*.ipy')) |
| 434 | if not startup_files: |
| 435 | return |
| 436 | |
| 437 | self.log.debug("Running startup files from %s...", startup_dir) |
| 438 | try: |
| 439 | for fname in sorted(startup_files): |
| 440 | self._exec_file(fname) |
| 441 | except: |
| 442 | self.log.warning("Unknown error in handling startup files:") |
| 443 | self.shell.showtraceback() |
| 444 | |
| 445 | def _run_exec_files(self): |
| 446 | """Run files from IPythonApp.exec_files""" |
no test coverage detected