#5767 custom_middleware.py: mercurial.hg - AttributeError: 'module' object has no attribute 'hg'

v1.0.0
closed
nobody
None
General
2015-08-20
2013-02-07
Anonymous
No

Originally created by: honyczek

I've installed Allura to openSUSE 12.2. All was good but I can't start taskd because of error:
~/logs/taskd.log:

11:43:28,391 INFO  [allura.command] Initialize command with config 'development.ini'
11:43:30,095 INFO  [allura.command] Loaded tools
11:43:30,095 INFO  [allura.command] Starting taskd, pid 2010
Traceback (most recent call last):
  File "/root/anvil/bin/paster", line 9, in <module>
    load_entry_point('PasteScript==1.7.4.2', 'console_scripts', 'paster')()
  File "/root/anvil/lib/python2.7/site-packages/paste/script/command.py", line   104, in run
    invoke(command, command_name, options, args[1:])
  File "/root/anvil/lib/python2.7/site-packages/paste/script/command.py", line 143, in invoke
      exit_code = runner.run(args)
  File "/root/anvil/lib/python2.7/site-packages/paste/script/command.py", line 238, in run
    result = self.command()
  File "/root/src/forge/Allura/allura/command/taskd.py", line 42, in command
    self.worker()
  File "/root/src/forge/Allura/allura/command/taskd.py", line 61, in worker
    wsgi_app = loadapp('config:%s#task' % self.args[0],relative_to=os.getcwd())
  File "/root/anvil/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/root/anvil/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/root/anvil/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/root/anvil/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/root/anvil/lib/python2.7/site-packages/paste/deploy/util.py", line 56, in fix_call
    val = callable(*args, **kw)
  File "/root/src/forge/Allura/allura/config/middleware.py", line 44, in make_app
    return _make_core_app(root, global_conf, full_stack, **app_conf)
  File "/root/src/forge/Allura/allura/config/middleware.py", line 123, in _make_core_app
    app = AlluraTimerMiddleware(app, app_conf)
  File "/root/anvil/lib/python2.7/site-packages/timermiddleware/__init__.py", line 150, in __init__
    for t in self.timers():
  File "/root/src/forge/Allura/allura/lib/custom_middleware.py", line 194, in timers
    ] + [Timer('sidebar', ep.load(), 'sidebar_menu') for ep in tool_entry_points]
  File "/root/src/forge/Allura/allura/lib/custom_middleware.py", line 212, in scm_lib_timers
    timers.append(Timer('hg_lib.{method_name}', mercurial.hg.localrepo.localrepository, 'heads',
AttributeError: 'module' object has no attribute 'hg'

To fix it I modified file ~/src/forge/Allura/allura/lib/custom_middleware.py:

diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py
index d302668..e371ed7 100644
--- a/Allura/allura/lib/custom_middleware.py
+++ b/Allura/allura/lib/custom_middleware.py
@@ -208,7 +208,7 @@ def scm_lib_timers(self):
            import git
            timers.append(Timer('git_lib.{method_name}', git.Repo, 'rev_parse', 'iter_commits', 'commit'))
        with pass_on_exc(ImportError):
-            import mercurial
+            import mercurial.hg
            timers.append(Timer('hg_lib.{method_name}', mercurial.hg.localrepo.localrepository, 'heads',
                'branchtags', 'tags'))
        return timers

Discussion

  • Dave Brondsema

    Dave Brondsema - 2013-02-07

    Hey there, thanks for this patch. I haven't seen this error so I'm curious what version of mercurial you have installed. (You can run pip freeze | grep mercurial to find out).

     
  • Anonymous - 2013-02-08

    Originally by: honyczek

    Hi, I've installed all packages according to your installation manual.

    Here is an output of requested command:

    (anvil)server:~/src/forge/Allura # pip freeze | grep mercurial
    Warning: cannot find svn location for Ming==0.3.2dev-20121101
    Warning: cannot find svn location for EasyWidgets==0.2dev-20130116
    mercurial==1.4.3
    

    Attaching full output of pip freeze.

     
  • Anonymous - 2013-02-08

    Originally by: *anonymous

    I have the same problem and the fix works.
    mercurial is also 1.4.3

     
  • Dave Brondsema

    Dave Brondsema - 2013-02-12
    • status: open --> code-review
    • qa: Dave Brondsema
    • milestone: limbo --> forge-feb-22
     
  • Dave Brondsema

    Dave Brondsema - 2013-02-12
    • status: code-review --> closed
     
  • Dave Brondsema

    Dave Brondsema - 2013-02-12

    Applied the fix and pushed it to the master branch.

     

Log in to post a comment.