Issue #30 resolved

demandimport error - ImportError: No module named fs

Kim Rydhof Thor Hansen
created an issue

This might be the same problem as #29, but the error is a little different.

I have it using Debian unstable with mecurial_keyring directly from the repository.

kim@leon:~/ange/baystow/csav$ hg in --traceback 
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 97, in _runcatch
    return _dispatch(req)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 778, in _dispatch
    cmdpats, cmdoptions)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 549, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 869, in _runcommand
    return checkargs()
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 840, in checkargs
    return cmdfunc()
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 775, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 506, in check
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/mercurial/commands.py", line 3872, in incoming
    return hg.incoming(ui, repo, source, opts)
  File "/usr/lib/python2.7/dist-packages/mercurial/hg.py", line 548, in incoming
    return _incoming(display, subreporecurse, ui, repo, source, opts)
  File "/usr/lib/python2.7/dist-packages/mercurial/hg.py", line 500, in _incoming
    other = peer(repo, opts, source)
  File "/usr/lib/python2.7/dist-packages/mercurial/hg.py", line 122, in peer
    return _peerorrepo(rui, path, create).peer()
  File "/usr/lib/python2.7/dist-packages/mercurial/hg.py", line 102, in _peerorrepo
    obj = _peerlookup(path).instance(ui, path, create)
  File "/usr/lib/python2.7/dist-packages/mercurial/httppeer.py", line 238, in instance
    inst._fetchcaps()
  File "/usr/lib/python2.7/dist-packages/mercurial/httppeer.py", line 57, in _fetchcaps
    self.caps = set(self._call('capabilities').split())
  File "/usr/lib/python2.7/dist-packages/mercurial/httppeer.py", line 171, in _call
    fp = self._callstream(cmd, **args)
  File "/usr/lib/python2.7/dist-packages/mercurial/httppeer.py", line 118, in _callstream
    resp = self.urlopener.open(req)
  File "/usr/lib/python2.7/urllib2.py", line 410, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 442, in error
    result = self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1085, in http_error_401
    host, req, headers)
  File "/usr/lib/python2.7/dist-packages/mercurial/url.py", line 407, in http_error_auth_reqed
    self, auth_header, host, req, headers)
  File "/home/kim/.hgext/mercurial_keyring.hg/mercurial_keyring.py", line 394, in digest_http_error_auth_reqed
    return digest_http_error_auth_reqed.orig(self, authreq, host, req, headers)
  File "/usr/lib/python2.7/urllib2.py", line 970, in http_error_auth_reqed
    return self.retry_http_digest_auth(req, authreq)
  File "/usr/lib/python2.7/urllib2.py", line 975, in retry_http_digest_auth
    auth = self.get_authorization(req, chal)
  File "/usr/lib/python2.7/urllib2.py", line 1010, in get_authorization
    user, pw = self.passwd.find_user_password(realm, req.get_full_url())
  File "/home/kim/.hgext/mercurial_keyring.hg/mercurial_keyring.py", line 380, in find_user_password
    return self._pwd_handler.find_auth(self, realm, authuri, req)
  File "/home/kim/.hgext/mercurial_keyring.hg/mercurial_keyring.py", line 231, in find_auth
    pwd = password_store.get_http_password(keyring_url, user)
  File "/home/kim/.hgext/mercurial_keyring.hg/mercurial_keyring.py", line 114, in get_http_password
    self._format_http_key(url, username))
  File "/usr/lib/python2.7/dist-packages/keyring/core.py", line 36, in get_password
    return _keyring_backend.get_password(service_name, username)
  File "/usr/lib/python2.7/dist-packages/keyring/backends/pyfs.py", line 167, in get_password
    password_base64 = self.config.get(service, username).encode()
  File "/usr/lib/python2.7/dist-packages/keyring/backends/pyfs.py", line 152, in config
    f = self._open()
  File "/usr/lib/python2.7/dist-packages/keyring/backends/pyfs.py", line 97, in _open
    except fs.errors.ResourceNotFoundError:
  File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 86, in __getattribute__
    self._load()
  File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 58, in _load
    mod = _origimport(head, globals, locals)
ImportError: No module named fs
abort: No module named fs!
kim@leon:~/ange/baystow/csav$ 

Comments (5)

  1. Kim Rydhof Thor Hansen reporter

    I would like to help you by finding out which modules to blacklist, but as I know next to nothing about Python and the Mercurial code I need a little guidance.

    Where should I do the blacklisting? I have found the "blocked_module" list in mercurial_keyring.py:69, it that it?

    How do I figure out which modules to try and block? I tried inserting "fs" in the blocked_module list but that didn't help.

    Thanks for the plugin, it makes working with mercurial over https as painless as using ssh. Kim Hansen.

  2. Marcin Kasperski repo owner

    Where should I do the blacklisting? I have found the "blocked_module" list in mercurial_keyring.py:69, it that it?

    Yes. Add new item(s) to this list, save the file, run sudo python setup.py install to install changed version, retest.

    How do I figure out which modules to try and block? I tried inserting "fs" in the blocked_module list but that didn't help.

    This is unfortunately the hard part. In general this mixes guessing and taking a look at the sources of keyring backend in charge. Here backtrace contains pyfs backend which starts from this file: https://bitbucket.org/kang/python-keyring-lib/src/0a5868df092005c73c4f999495236757371be191/keyring/backends/pyfs.py?at=default There are imports of things like 'fs.opener', 'fs.errors' etc, I would try blacklisting them all.

  3. Log in to comment