lordmauve / chopsticks

Chopsticks is an orchestration library: it lets you execute Python code on remote hosts over SSH.
https://chopsticks.readthedocs.io/
Apache License 2.0
158 stars 16 forks source link

ImportError from deserialise_func #56

Open nirmalagarwal opened 6 years ago

nirmalagarwal commented 6 years ago

My Env:

Sample program

from chopsticks.tunnel import Local

import git

def do_it():
    repo=git.Repo('/my_git_repo')
    return repo.working_dir

local_tun = Local('localhost')
print(local_tun.call(do_it))

on python 2.7 the above code fails with

Traceback (most recent call last):
  File "test.py", line 11, in <module>
    print(local_tun.call(do_it))
  File "/usr/local/lib/python2.7/dist-packages/chopsticks-1.0-py2.7.egg/chopsticks/tunnel.py", line 299, in call
    raise RemoteException(ret.msg)
chopsticks.tunnel.RemoteException: Host 'localhost' raised exception; traceback follows
    Traceback (most recent call last):
      File "bubble.py", line 172, in wrapper
      File "bubble.py", line 236, in do_call
      File "chopsticks://chopsticks/serialise_main.py", line 143, in execute_func
        f = deserialise_func(*func_data)
      File "chopsticks://chopsticks/serialise_main.py", line 132, in deserialise_func
        __import__(mod)
    ImportError: No module named glob

On python 3.5 , code works fine.

When I tried to debug using rpdb, I found the below list of imports from deserialise_func

(Pdb) p imports  
set(['git.index.glob', 'git.index.stat', 'git.contextlib', 'git.logging', 'git.objects.mimetypes', 'git.platform', 'git.repo.git', 'git.index.sys', 'git.sys', 'git.objects.git', 'git.objects.logging', 'git.subprocess', 'git.objects.time', 'git.collections', 'git.os', 'git.config', 'git.functools', 'git.objects.calendar', 'git.refs.remote', 'git.objects.submodule.io', 'git.refs', 'git.locale', 'git.refs.git', 'git.diff', 'git.repo.fun', 'git.odict', 'git.objects.io', 'git.index', 'git.objects.os', 'git.objects', 'git.refs.symbolic', 'git.refs.log', 'git.index.typ', 'git.objects.submodule.util', 'git.repo.collections', 'git.objects.collections', 'git.repo.logging', 'git.objects.submodule.unittest', 'git.refs.tag', 'git.objects.fun', 'git.objects.submodule.base', 'git.objects.string', 'git.objects.util', 'git.db', 'git.objects.base', 'git.index.functools', 'git.util', 'git.objects.commit', 'git.getpass', 'git.refs.os', 'git.stat', 'git.ConfigParser', 'git.codecs', 'git.objects.blob', 'git.objects.tree', 'git.inspect', 'git.objects.submodule', 'git.objects.submodule.logging', 'git.objects.datetime', 'git.repo.string', 'git', 'git.refs.time', 'git.objects.gitdb', 'git.re', 'git.abc', 'git.index.os', 'git.index.fun', 'git.shutil', 'git.objects.stat', 'git.cmd', 'git.refs.reference', 'git.threading', 'git.index.subprocess', 'git.signal', 'git.refs.re', 'git.unittest', 'git.compat', 'git.objects.tag', 'git.index.git', 'git.time', 'git.index.struct', 'git.objects.submodule.git', 'git.repo', 'git.refs.head', 'git.repo.gitdb', 'git.gitdb', 'git.objects.submodule.weakref', 'git.index.base', 'git.index.util', 'git.io', 'git.index.gitdb', 'git.exc', 'git.objects.submodule.root', 'git.repo.re', 'git.remote', 'git.objects.re', 'git.repo.os', 'git.repo.gc', 'git.index.io', 'git.git', 'git.repo.sys', 'git.objects.submodule.os', 'git.objects.submodule.stat', 'git.refs.gitdb', 'git.index.tempfile', 'git.objects.submodule.uuid', 'git.index.binascii', 'git.repo.base'])