Skip to main content

Seabreeze-Server

A python TCP-Server which allows a OceanOptics Spectrometer to be connected to over a network

The purpose of this library is to allow OceanOptics spectrometers to be effectively wifi-enabled, so that data-aquisition can be handled by multiple computers (some potentially offsite), without having to fiddle with usb cords. Additionally, this opens up the possibility for open-source, web-based user interfaces to be developed for OceanOptics devices.

This package uses the seabreeze.cseabreeze backend to handle communications between the server and the spectrometer, by exposing the backend API functions to the seabreeze_server.server.SpectrometerManager object. (Alternatively, a physical spectrometer can also be emulated in software with the seatease package, but setting SpectrometerManager(emulate=True)). The TCP server is handled by the seabreeze_server.server.SeaBreezeServer class (based on the remote-object package), which exposes the SpectrometerManager object's methods and attributes to seabreeze_server.client.SeaBreezeClient instances.

Security Note

ONLY INTERACT WITH SERVERS THAT YOU TRUST. The seabreeze_server.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-seabreeze-server, leave it to the user to make wise decisions about what they chose to unpickle. Be smart.

Basic Use

On the server-side, connect and configure your spectrometer hardware for whatever kind of measurement you desire, then run something like:

HOST, PORT = 'your-ip', 9999
with seabreeze_server.server.SeaBreezeServer(
    (HOST, PORT),
    emulate = False
) as server:
    server.serve_forever()

See the socketserver.TCPServer documentation for more ideas about how to manage this server.

Then on the client-side, run something like the following:

HOST, PORT = 'your-ip', 9999
client = seabreeze_server.client.Client(HOST, PORT)

# Prints out currently plugged-in devices
print(
    "Available Devices:\n",
    "\n".join(["%d : %s" % (i,dev)\
                for i,dev in enumerate(client.list_devices())
             ])
)

# Select the first spectrometer
client.select_spectrometer(0)

# Set integration time to 10 ms
client.set_integration_time_micros(10*1000)

# Get wavelengths and intensities
wls = client.get_wavelengths()
i = client.get_intensities()

Installing (pip)

seabreeze-server is available via pip:

 $ pip install seabreeze-server

If you haven't previously installed seabreeze, you might need to do a bit of work, see 'SeaBreeze Setup' below for more details.

SeaBreeze Setup

Installing seabreeze can take some trial an error, especially on linux, make sure that after pip installing (or conda installing, whatever, you do you) you are also run the os setup script:

 $ pip install seabreeze
 $ seabreeze_os_setup

If you are still having trouble, check out the main seabreeze documentation.

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
 (venv) $ seabreeze_os_setup

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/]

Acknowledgements

The authors would like to thank Andreas Poehlmann and collaborators for creating the original python-seabreeze package, which this library depends heavily upon. His package has been indispensable to our research.

Metadata

Release files for seabreeze-server 0.2.1

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

Source distribution (sdist)

Source distribution for seabreeze-server 0.2.1
File Size Uploaded
seabreeze-server-0.2.1.tar.gz 6.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for seabreeze-server 0.2.1
File Interpreter ABI Platform
seabreeze_server-0.2.1-py3.7.egg Legacy Egg format - - Details
seabreeze_server-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 26.2 kB

Release files / seabreeze-server-0.2.1.tar.gz

Download URL seabreeze-server-0.2.1.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2bdcdd99c72887031bb27f248a2493ae35673733d9ec06dd7e4ee8172c977ab5
BLAKE2b-256 checksum
How to use checksums
7f15723cccf787c1319366ae117617b09a56ca381ced5f250d44b363906bc3f4
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 / seabreeze_server-0.2.1-py3.7.egg

Download URL seabreeze_server-0.2.1-py3.7.egg
Size 12.4 kB
Tags Egg
SHA-256 checksum
How to use checksums
c5934d0ad783a3e51f731ee7c879b53584d824195e593677c67d71318737d114
BLAKE2b-256 checksum
How to use checksums
a552de1231a29ac05a0684011e8861e6b7b1060479af917c3cec3654273951e1
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 / seabreeze_server-0.2.1-py3-none-any.whl

Download URL seabreeze_server-0.2.1-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d01121d7804ab7d02ec97206ba8ca0beae45736baaca93d6d57147c4d7bfb9d
BLAKE2b-256 checksum
How to use checksums
072ad7c6c6de796a055627c38d8a6bf6e7ca2fff5a55602e1ec796e509041312
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.1 This release

3 release files

0.2.0

3 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.1

2 release files

0.1

3 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