PY-17107: Removing outdated deprecated code
[idea/community.git] / python / helpers / pycharm / django_manage_shell.py
1 #!/usr/bin/env python
2 from fix_getpass import fixGetpass
3 import os
4 from django.core import management
5 import sys
6
7 try:
8   from runpy import run_module
9 except ImportError:
10   from runpy_compat import run_module
11
12
13 def run(working_dir):
14   sys.path.insert(0, working_dir)
15   manage_file = os.getenv('PYCHARM_DJANGO_MANAGE_MODULE')
16   if not manage_file:
17     manage_file = 'manage'
18
19   def execute_manager(settings_mod, argv = None):
20       management.setup_environ(settings_mod)
21
22   management.execute_manager = execute_manager
23
24   def execute_from_command_line(argv=None):
25     pass
26
27   management.execute_from_command_line = execute_from_command_line
28
29   fixGetpass()
30
31   run_module(manage_file, None, '__main__', True)
32