Skip to content

Instantly share code, notes, and snippets.

@zunayed
Last active August 29, 2015 14:06
Show Gist options
  • Save zunayed/fcff48a276c28f9839d2 to your computer and use it in GitHub Desktop.
Save zunayed/fcff48a276c28f9839d2 to your computer and use it in GitHub Desktop.
Watching variables while debugging for prestige projects

I finally took Josh's advice and started digging deeper into Pycharms visual debugger. But I quickly ran into an issue using envdir for our prestige projects. There doesn't seem like there is a way to prepend the django manage.py command with envdir. So I modified the manage.py file with these few lines to load your envdir/ folder. The added benefit of this is you can just type python /manage.py runserver. Otherwise you would have to manually enter all the required Enviromental variables into pycharm by hand and also track the changes. I figured I share this.

if 'local' in sys.argv:
    env_dir = os.path.join('local', 'envdir')
else:
    env_dir = 'envdir/dev'

env_variables = glob.glob(os.path.join(project_path, env_dir, '*'))
for env_var in env_variables:
    with open(env_var, 'r') as env_var_file:
        os.environ.setdefault(
            env_var.split(os.sep)[-1],
            env_var_file.read().strip()
        )

In action -

alt text

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