Package: remote-object
python-remote-objectPython TCP server and client which allows clients to make calls and get returns
from a python object instantiated on the server.This package was originally developed to be used along sidepyUSB,serial,pyVISA, etc, where an external hardware component could be connected to a
computer for which a python-based API for the component already existed. This
package could then take an instance of that python driver, and allow other
computers (potentially off-site) to make API calls and so control the external
hardware remotely.For example, one could connect a raspberry pi up to their digital oscilloscope
via usb, and now your oscilloscope is "wifi-enabled"Security NoteONLY INTERACT WITH SERVERS THAT YOU TRUST. Theremote_object.client.Clientobject usespickle.loadto deserialize data and objects from the server. This
process is able to execute arbitrary code on your machine. This can easily be
exploited by malicious agents to compromise your system. Thepicklelibrary,
and by extensionpython-remote-object, leave it to the user to make wise
decisions about what they chose to unpickle. Be smart.InstallationPipTo get the current stable version, install using pip:$pip3installremote_objectDevelopment VersionTo get the development version, clone this repo, then inside the folder create apython3virtual environment, activate it, and install using setuptools:$python3-mvenvvenv$sourcevenv/bin/activate(venv)$python3setup.pyinstallBasic UseIf you have an instance of a python object,pyobj, using the base server
classremote_object.server.Serverwill allow you to create a TCP server
which hostspyobj.On the client end, you must create an instance of theremote_object.client.Clientobject pointed at the server's address and port. By default, calling a method
on theClientinstance will pass that call across the TCP connection to the
server, where theServerinstance will make that method call onpyobj. Any
errors or return values will then be passed back to theClientinstance and
raised or returned respectively.For example, the server might look like:fromremote_object.serverimportServerHOST,PORT='your-ip-address',9999classTest:def__init__(self):self.a="attribute a"def__repr__(self):return"<Test Class>"defb(self,message):return"method b: "+messagewithServer((HOST,PORT),Test())asserver:server.serve_forever()The client might then look like:fromremote_object.serverimportClientwithClient(HOST,PORT)asclient:print(client)# prints: <Remote Wrapper <Test Class>>print(client.a())# prints "attribute a"print(client.b("Hello!"))# prints "method b: Hello!"print(client.c())# raises AttributeErrorNote here that attributes are treated like methods without arguments, and
attempting to call method which does not exist will raise anAttributeError.Seeexamples/errorsfor additional info.DevelopmentFor development, clone this directory, then have fun! Pro-tip: setup a python
virtual environment in the main directory:$python3-mvenvvenv$sourcevenv/bin/activateInstalling(venv)$python3setup.pyinstallCreating source packages(venv)$python3setup.pysdistbdist_wheelUploading to PyPI(venv)$python3-mtwineuploaddist/*See: [https://packaging.python.org/tutorials/packaging-projects/]