Package: seabreeze-server
Seabreeze-ServerA python TCP-Server which allows a OceanOptics Spectrometer to be connected to
over a networkThe 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 theseabreeze.cseabreezebackend to handle communications
between the server and the spectrometer, by exposing the backend API functions
to theseabreeze_server.server.SpectrometerManagerobject. (Alternatively,
a physical spectrometer can also be emulated in software with theseateasepackage, but settingSpectrometerManager(emulate=True)). The TCP
server is handled by theseabreeze_server.server.SeaBreezeServerclass
(based on theremote-objectpackage), which exposes theSpectrometerManagerobject's methods and attributes toseabreeze_server.client.SeaBreezeClientinstances.Security NoteONLY INTERACT WITH SERVERS THAT YOU TRUST. Theseabreeze_server.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-seabreeze-server, leave it to the user to make wise
decisions about what they chose to unpickle. Be smart.Basic UseOn the server-side, connect and configure your spectrometer hardware for
whatever kind of measurement you desire, then run something like:HOST,PORT='your-ip',9999withseabreeze_server.server.SeaBreezeServer((HOST,PORT),emulate=False)asserver:server.serve_forever()See thesocketserver.TCPServerdocumentation for more ideas about
how to manage this server.Then on the client-side, run something like the following:HOST,PORT='your-ip',9999client=seabreeze_server.client.Client(HOST,PORT)# Prints out currently plugged-in devicesprint("Available Devices:\n","\n".join(["%d:%s"%(i,dev)\fori,devinenumerate(client.list_devices())]))# Select the first spectrometerclient.select_spectrometer(0)# Set integration time to 10 msclient.set_integration_time_micros(10*1000)# Get wavelengths and intensitieswls=client.get_wavelengths()i=client.get_intensities()Installing (pip)seabreeze-serveris available via pip:$pipinstallseabreeze-serverIf you haven't previously installedseabreeze, you might need to do a bit of
work, see 'SeaBreeze Setup' below for more details.SeaBreeze SetupInstallingseabreezecan take some trial an error, especially on linux,
make sure that afterpipinstalling (orcondainstalling, whatever,
you do you) you are also run the os setup script:$pipinstallseabreeze$seabreeze_os_setupIf you are still having trouble, check out the mainseabreezedocumentation.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.pyinstall(venv)$seabreeze_os_setupCreating source packages(venv)$python3setup.pysdistbdist_wheelUploading to PyPI(venv)$python3-mtwineuploaddist/*See: [https://packaging.python.org/tutorials/packaging-projects/]AcknowledgementsThe authors would like to thankAndreas Poehlmannand collaborators for creating the originalpython-seabreezepackage,
which this library depends heavily upon. His package has been indispensable
to our research.