Skip to content

Instantly share code, notes, and snippets.

@hanleybrand
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanleybrand/604f96ccaf11fc846b88 to your computer and use it in GitHub Desktop.
Save hanleybrand/604f96ccaf11fc846b88 to your computer and use it in GitHub Desktop.
Environment debugging for MDID3 - paste this to the bottom of your settings_local.py and run the server with `python manage.py run server`
import os
CL_DEBUG = True
PROJECT_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
ROOIBOS_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__)))
# This will print a fair amount of information helpful for debugging an installation
# if CL_DEBUG = True at the beginning of this file
# see http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html
if CL_DEBUG:
print "__name__ =", __name__
print "__file__ =", __file__
print "os.getpid() =", os.getpid()
print "os.getcwd() =", os.getcwd()
print "os.curdir =", os.path.abspath(os.curdir)
#print "sys.path =" # , repr(sys.path)
#for forks in sys.path:
# print forks
#print "sys.modules.keys() =", repr(sys.modules.keys())
print "sys.modules.has_key('rooibos') =", sys.modules.has_key('rooibos')
if sys.modules.has_key('rooibos'):
print "sys.modules['rooibos'].__name__ =", sys.modules['rooibos'].__name__
print "sys.modules['rooibos'].__file__ =", sys.modules['rooibos'].__file__
print "os.environ['DJANGO_SETTINGS_MODULE'] =", os.environ.get('DJANGO_SETTINGS_MODULE', None)
print '===============================\nDirectories\n==============================='
print 'project path: ', PROJECT_ROOT
print 'rooibos path: ', ROOIBOS_ROOT
print 'media root: ', MEDIA_ROOT
print 'scratch: ', SCRATCH_DIR
print 'auto-storage: ', AUTO_STORAGE_DIR
@hanleybrand
Copy link
Author

Because of the way django loads, this will repeat a few times in your terminal, but the last iteration is correct. If your base directory is /var/local/mdid/ then the output should look something like:

__name__ = rooibos.settings_local
__file__ = /var/local/mdid/rooibos/settings_local.pyc
os.getpid() = 5018
os.getcwd() = /var/local/mdid/rooibos
os.curdir = /var/local/mdid/rooibos
sys.modules.has_key('rooibos') = True
sys.modules['rooibos'].__name__ = rooibos
sys.modules['rooibos'].__file__ = /var/local/mdid/rooibos/__init__.pyc
os.environ['DJANGO_SETTINGS_MODULE'] = rooibos.settings
===============================
Directories
===============================
project path:   /var/local/mdid/
rooibos path:   /var/local/mdid/rooibos
media root:   /var/local/mdid/rooibos/static
scratch:        /var/local/mdid-data/mdid-scratch
auto-storage:   /var/local/mdid-data/mdid-collections

Uncomment the for forks in sys.path: to get lot more stuff (like all the python libraries available) in the console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment