[issue3315] Importing Django model in an HG hook causes catastrophe
Nick Jennings
bugs at mercurial.selenic.com
Thu Mar 8 18:03:39 CST 2012
New submission from Nick Jennings <nick at silverbucket.net>:
See my original post here: http://stackoverflow.com/questions/9620997/using-
a-django-model-from-a-mercurial-python-hook
Basically, when I try to import a Django model in my mercurial hook, I get a
ton of errors, heres the top of my mercurial hook file:
#!/usr/bin/env python
import sys
path = '/opt'
if path not in sys.path:
sys.path.append(path)
from django.core.management import setup_environ
from mysite import settings
setup_environ(settings)
from mysite.myapp.models import Build
import datetime
Now, when it executes, I get the following error:
** unknown exception encountered, please report by visiting
** http://mercurial.selenic.com/wiki/BugTracker
** Python 2.7.2+ (default, Oct 4 2011, 20:06:09) [GCC 4.6.1]
** Mercurial Distributed SCM (version 1.9.1)
** Extensions loaded:
Traceback (most recent call last):
File "/usr/bin/hg", line 38, in <module>
mercurial.dispatch.run()
File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 27, in
run
sys.exit(dispatch(request(sys.argv[1:])))
File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 64, in
dispatch
return _runcatch(req)
File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 87, in
_runcatch
return _dispatch(req)
File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 679,
in _dispatch
cmdpats, cmdoptions)
File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 454,
in runcommand
ret = _runcommand(ui, options, cmd, d)
File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 733,
in _runcommand
return checkargs()
File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 687,
in checkargs
return cmdfunc()
File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 676,
in <lambda>
d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 385, in
check
return func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/mercurial/commands.py", line 3884,
in push
newbranch=opts.get('new_branch'))
File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 1428,
in push
lock=lock)
File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 1849,
in addchangegroup
source=srctype, url=url)
File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 224,
in hook
return hook.hook(self.ui, self, name, throw, **args)
File "/usr/lib/python2.7/dist-packages/mercurial/hook.py", line 160, in
hook
mod = extensions.loadpath(path, 'hghook.%s' % hname)
File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 45,
in loadpath
return imp.load_source(module_name, path)
File "/opt/unapse/belvedere/mercurial_hook.py", line 14, in <module>
from unapse.belvedere.models import Build
File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line
109, in _demandimport
mod = _origimport(name, globals, locals)
File "/opt/unapse/belvedere/models.py", line 1, in <module>
from django.db import models
File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line
109, in _demandimport
mod = _origimport(name, globals, locals)
File "/usr/lib/pymodules/python2.7/django/db/__init__.py", line 14, in
<module>
if not settings.DATABASES:
File "/usr/lib/pymodules/python2.7/django/utils/functional.py", line 276,
in __getattr__
self._setup()
File "/usr/lib/pymodules/python2.7/django/conf/__init__.py", line 42, in
_setup
self._wrapped = Settings(settings_module)
File "/usr/lib/pymodules/python2.7/django/conf/__init__.py", line 139, in
__init__
logging_config_func(self.LOGGING)
File "/usr/lib/python2.7/logging/config.py", line 776, in dictConfig
dictConfigClass(config).configure()
File "/usr/lib/python2.7/logging/config.py", line 575, in configure
'%r: %s' % (name, e))
ValueError: Unable to configure handler 'mail_admins': __import__() argument
1 must be string, not DictConfigurator
----------
messages: 19346
nosy: nkj
priority: bug
status: unread
title: Importing Django model in an HG hook causes catastrophe
____________________________________________________
Mercurial issue tracker <bugs at mercurial.selenic.com>
<http://mercurial.selenic.com/bts/issue3315>
____________________________________________________
More information about the Mercurial-devel
mailing list