Created
February 5, 2015 14:30
-
-
Save magixx/df64a5bdbb2cbce28ea6 to your computer and use it in GitHub Desktop.
rpyc mock classic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MockClassicConnection(object): | |
"""Mock classic RPyC connection object. Useful when you want the same code to run remotely or locally. | |
""" | |
def __init__(self): | |
self._conn = None | |
self.namespace = {} | |
self.modules = ModuleNamespace(self.getmodule) | |
if is_py3k: | |
self.builtin = self.modules.builtins | |
else: | |
self.builtin = self.modules.__builtin__ | |
self.builtins = self.builtin | |
def execute(self, text): | |
execute(text, self.namespace) | |
def eval(self, text): | |
return eval(text, self.namespace) | |
def getmodule(self, name): | |
return __import__(name, None, None, "*") | |
def getconn(self): | |
return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment