Login

manage.py for eclipse with pydev debugging

Author:
nickvlku
Posted:
June 10, 2009
Language:
Python
Version:
1.0
Tags:
debugging pydev eclipse
Score:
2 (after 2 ratings)

This code is referenced in a screencast focused on showing a user how to configure Eclipse with PyDev to give you code complete, and breakpoints inside the IDE.

It comes from a 2007 blog post (I've replicated it in case that post ever disappears.)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
from django.core.management import execute_manager
try:
   import settings # Assumed to be in the same directory.
except ImportError:
   import sys
   sys.stderr.write("Error: Can't find the file 'settings.py' in the  directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
   sys.exit(1)

if __name__ == "__main__":


   import sys

   if len(sys.argv) > 1:
       command = sys.argv[1]

   if settings.DEBUG and (command == "runserver" or command == "testserver"):

       # Make pydev debugger works for auto reload.
       try:
           import pydevd
       except ImportError:
           sys.stderr.write("Error: " +
               "You must add org.python.pydev.debug.pysrc to your PYTHONPATH.")
           sys.exit(1)

       from django.utils import autoreload
       m = autoreload.main
       def main(main_func, args=None, kwargs=None):
           import os
           if os.environ.get("RUN_MAIN") == "true":
               def pydevdDecorator(func):
                   def wrap(*args, **kws):
                       pydevd.settrace(suspend=False, port=5678)
                       return func(*args, **kws)
                   return wrap
               main_func = pydevdDecorator(main_func)

           return m(main_func, args, kwargs)

       autoreload.main = main

       execute_manager(settings)

More like this

  1. Truncate string after a given number of chars keeping whole words by rix 6 years, 5 months ago
  2. Convert multiple select for m2m to multiple checkboxes in django admin form by abidibo 2 years, 1 month ago
  3. Handling choices the right way by mallipeddi 7 years, 6 months ago
  4. BabelMiddleware by skam 7 years, 10 months ago
  5. Date/time util template filters by marinho 7 years, 6 months ago

Comments

Please login first before commenting.