MCPcopy Create free account
hub / github.com/ipython/ipython / _run_cmd_line_code

Method _run_cmd_line_code

IPython/core/shellapp.py:399–428  ·  view source on GitHub ↗

Run code or file specified at the command-line

(self)

Source from the content-addressed store, hash-verified

397 self.shell.showtraceback()
398
399 def _run_cmd_line_code(self):
400 """Run code or file specified at the command-line"""
401 if self.code_to_run:
402 line = self.code_to_run
403 try:
404 self.log.info("Running code given at command line (c=): %s" %
405 line)
406 self.shell.run_cell(line, store_history=False)
407 except:
408 self.log.warning("Error in executing line in user namespace: %s" %
409 line)
410 self.shell.showtraceback()
411 if not self.interact:
412 self.exit(1)
413
414 # Like Python itself, ignore the second if the first of these is present
415 elif self.file_to_run:
416 fname = self.file_to_run
417 if os.path.isdir(fname):
418 fname = os.path.join(fname, "__main__.py")
419 if not os.path.exists(fname):
420 self.log.warning("File '%s' doesn't exist", fname)
421 if not self.interact:
422 self.exit(2)
423 try:
424 self._exec_file(fname, shell_futures=True)
425 except:
426 self.shell.showtraceback(tb_offset=4)
427 if not self.interact:
428 self.exit(1)
429
430 def _run_module(self):
431 """Run module specified at the command-line."""

Callers 1

init_codeMethod · 0.95

Calls 4

_exec_fileMethod · 0.95
infoMethod · 0.80
showtracebackMethod · 0.80
run_cellMethod · 0.45

Tested by

no test coverage detected