Skip to main content

python-remote-object

Python 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 side pyUSB, 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 Note

ONLY INTERACT WITH SERVERS THAT YOU TRUST. The remote_object.client.Client object uses pickle.load to 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. The pickle library, and by extension python-remote-object, leave it to the user to make wise decisions about what they chose to unpickle. Be smart.

Installation

Pip

To get the current stable version, install using pip:

 $ pip3 install remote_object

Development Version

To get the development version, clone this repo, then inside the folder create a python3 virtual environment, activate it, and install using setuptools:

 $ python3 -m venv venv
 $ source venv/bin/activate
 (venv) $ python3 setup.py install

Basic Use

If you have an instance of a python object, pyobj, using the base server class remote_object.server.Server will allow you to create a TCP server which hosts pyobj.

On the client end, you must create an instance of the remote_object.client.Client object pointed at the server's address and port. By default, calling a method on the Client instance will pass that call across the TCP connection to the server, where the Server instance will make that method call on pyobj. Any errors or return values will then be passed back to the Client instance and raised or returned respectively.

For example, the server might look like:

from remote_object.server import Server

HOST, PORT = 'your-ip-address', 9999

class Test:
    def __init__(self):
        self.a = "attribute a"

    def __repr__(self):
        return "<Test Class>"

    def b(self,message):
        return "method b: " + message

with Server((HOST, PORT),Test()) as server:
    server.serve_forever()

The client might then look like:

from remote_object.server import Client

with Client(HOST, PORT) as client:
    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 AttributeError

Note here that attributes are treated like methods without arguments, and attempting to call method which does not exist will raise an AttributeError.

See examples/errors for additional info.

Development

For development, clone this directory, then have fun! Pro-tip: setup a python virtual environment in the main directory:

 $ python3 -m venv venv
 $ source venv/bin/activate

Installing

 (venv) $ python3 setup.py install

Creating source packages

 (venv) $ python3 setup.py sdist bdist_wheel

Uploading to PyPI

 (venv) $ python3 -m twine upload dist/*

See: [https://packaging.python.org/tutorials/packaging-projects/]

Metadata

Release files for remote-object 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for remote-object 0.2.4
File Size Uploaded
remote-object-0.2.4.tar.gz 6.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for remote-object 0.2.4
File Interpreter ABI Platform
remote_object-0.2.4-py3.7.egg Legacy Egg format - - Details
remote_object-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 29.8 kB

Release files / remote-object-0.2.4.tar.gz

Download URL remote-object-0.2.4.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4c167763bbc47ec4327516f315d4016ad8dfa2dad3dbc8c92927bbcd1d439136
BLAKE2b-256 checksum
How to use checksums
b4d09a5b02e0e915d0871932b7c27b52e0e0e75cad270449d57e86a0df596781
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Release files / remote_object-0.2.4-py3.7.egg

Download URL remote_object-0.2.4-py3.7.egg
Size 14.2 kB
Tags Egg
SHA-256 checksum
How to use checksums
52cacd4538c85761ce6f572e059e13317ed3bb91f6a3acaf1ec197d34c25a73a
BLAKE2b-256 checksum
How to use checksums
47397110d1ecf975a40527bb3e5fc8bf97a2815712582b555ded99717fd46647
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Release files / remote_object-0.2.4-py3-none-any.whl

Download URL remote_object-0.2.4-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e37928f94f5201603236ad5da96e8b74b85759af891d6e58e05466059afbb031
BLAKE2b-256 checksum
How to use checksums
3227a46ae71fedcef2dd36a173c5ccf48bfa6f7a75da1a67e18ff709bbd6931b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Release history Release notifications | RSS feed

This release

0.2.4 This release

3 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page