MCPcopy
hub / github.com/django/django / handle

Method handle

django/core/management/commands/shell.py:258–283  ·  view source on GitHub ↗
(self, **options)

Source from the content-addressed store, hash-verified

256 return namespace
257
258 def handle(self, **options):
259 # Execute the command and exit.
260 if options["command"]:
261 exec(options["command"], {**globals(), **self.get_namespace(**options)})
262 return
263
264 # Execute stdin if it has anything to read and exit.
265 # Not supported on Windows due to select.select() limitations.
266 if (
267 sys.platform != "win32"
268 and not sys.stdin.isatty()
269 and select.select([sys.stdin], [], [], 0)[0]
270 ):
271 exec(sys.stdin.read(), {**globals(), **self.get_namespace(**options)})
272 return
273
274 available_shells = (
275 [options["interface"]] if options["interface"] else self.shells
276 )
277
278 for shell in available_shells:
279 try:
280 return getattr(self, shell)(options)
281 except ImportError:
282 pass
283 raise CommandError("Couldn't import {} interface.".format(shell))

Callers

nothing calls this directly

Calls 6

get_namespaceMethod · 0.95
CommandErrorClass · 0.90
selectMethod · 0.80
isattyMethod · 0.45
readMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected