← back to Oculus Prime Contents

Oculus Prime - Python Module

The Oculus Prime Python module, that you can import into your own python scripts, handles connection and conversation with the Oculus Prime Server Application. It connects to the server via the Telnet API, and supplies a handful of convenience conversing functions.

The module is the file You can find the current version in the Oculus Prime ROS repository: oculusprime_ros/src/

The module uses the standard Python socket interface to connect with the server. Once connected, it creates a file object using socket.makefile, to simplify conversing using newline-terminated blocks of text back and forth.


At the top of any python script, import the module by adding the line

import oculusprimesocket

NOTE: a copy of the module file needs to be in the same folder as your script.

If not connecting to the oculus prime server at localhost, specify a different address by adding the line: = ""

Substituting your preferred IP address or hostname.

Next, before you can converse with the server, your script has to call:


Now your script should be connected, and able to use the module’s conversation functions.


Server host address (default is "")

Server host port (default is 4444)

(Boolean) server connection status

(Boolean) persistent server connection, keep trying if server unavailable

Available Functions

Clear socket buffer of all incoming server messages

Make socket connection to server, blocking
Returns: True on successful connect, False otherwise

Search through unread output from server, compare to pattern, return match
pattern — regular expression pattern to be searched
Returns: first line containing match, or empty string if search fails
non blocking function

Send single line command to server
str — command to be sent

Read all incoming messages from server, do not return until search match
pattern — regular expression pattern to be searched
Returns: first line containing match, or empty string if server connection drops
blocking function


The following Python script imports the oculusprimesocket module. Then it connects to the Oculus Prime Server running on the same machine, turns on the camera using the publish command, then requests the ambient light level using the getlightlevel command.

It uses the module’s waitForReplySearch() function to wait for the server to write the result to the lightlevel state variable, then turns on the light if it’s too dark using the spotlight command.

It then disconnects and exits.

NEXT: More Script Examples

← back to Oculus Prime Contents

CART 0 items | US$
    Check Order Status
Follow →
instagram twitter facebook youtube
@XaxxonTech Twitter
© 2023 Xaxxon
Products Documentation Downloads Source Code
Warranty & Returns About Us Contact/Support News
instagram twitter facebook youtube