如何从Linux框中通过RPyC调用pywin32

时间:2014-11-23 07:54:09

标签: python linux windows rpyc

说明:

我有一个带有Python 2.7和RPyC的Linux机器。另外,我有一个安装了相同Python版本的RP(Server 2008)盒子,RPyC和pywin32。 Windows框运行RPyC classic_server,Linux框用于运行RPyC客户端。通常,我正在构建infra来管理远程Linux框中的Active Directory(AD)服务器。对于AD管理,将在Windows机器上安装“pyad”模块。

问题:

通常,所有这些捆绑都按照承诺的方式工作。

In [3]: conn = rpyc.classic.connect("10.103.224.44")
In [4]: conn.modules.os.getcwd()
Out[4]: 'C:\\ldap-automation-project\\scripts'

但是当我尝试调用远程“pywin32”或“pyad”时,它失败了(pywin32是一个依赖项)。

In [7]: conn.modules.pywin32
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-7-31ec7f3bb520> in <module>()
----> 1 conn.modules.pywin32

/usr/lib/python2.7/site-packages/rpyc/core/service.pyc in __getattr__(self, name)
    119         return self.__cache[name]
    120     def __getattr__(self, name):
--> 121         return self[name]
    122 
    123 class SlaveService(Service):

/usr/lib/python2.7/site-packages/rpyc/core/service.pyc in __getitem__(self, name)
    116             name = ".".join(name)
    117         if name not in self.__cache:
--> 118             self.__cache[name] = self.__getmodule(name)
    119         return self.__cache[name]
    120     def __getattr__(self, name):

/usr/lib/python2.7/site-packages/rpyc/core/netref.pyc in __call__(_self, *args, **kwargs)
    194         def __call__(_self, *args, **kwargs):
    195             kwargs = tuple(kwargs.items())
--> 196             return syncreq(_self, consts.HANDLE_CALL, args, kwargs)
    197         __call__.__doc__ = doc
    198         return __call__

/usr/lib/python2.7/site-packages/rpyc/core/netref.pyc in syncreq(proxy, handler, *args)
     69         raise ReferenceError('weakly-referenced object no longer exists')
     70     oid = object.__getattribute__(proxy, "____oid__")
---> 71     return conn.sync_request(handler, oid, *args)
     72 
     73 def asyncreq(proxy, handler, *args):

/usr/lib/python2.7/site-packages/rpyc/core/protocol.pyc in sync_request(self, handler, *args)
    439         isexc, obj = self._sync_replies.pop(seq)
    440         if isexc:
--> 441             raise obj
    442         else:
    443             return obj

ImportError: No module named pywin32

========= Remote Traceback (1) =========
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line 305, in _dispatch_request
    res = self._HANDLERS[handler](self, *args)
  File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line 535, in _handle_call
    return self._local_objects[oid](*args, **dict(kwargs))
  File "C:\Python27\lib\site-packages\rpyc\core\service.py", line 163, in exposed_getmodule
    return __import__(name, None, None, "*")
ImportError: No module named pywin32

有什么想法吗?

0 个答案:

没有答案