Skip to content

Instantly share code, notes, and snippets.

@magixx
Created February 5, 2015 14:30
Show Gist options
  • Save magixx/df64a5bdbb2cbce28ea6 to your computer and use it in GitHub Desktop.
Save magixx/df64a5bdbb2cbce28ea6 to your computer and use it in GitHub Desktop.
rpyc mock classic
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