Python: SNMP put into a Google Sheet:

from pysnmp.hlapi import *
import gspread
from oauth2client.service_account import ServiceAccountCredentials

# SNMP query function
def snmp_query(ip, community, oid):
errorIndication, errorStatus, errorIndex, varBinds = next(
getCmd(SnmpEngine(),
CommunityData(community),
UdpTransportTarget((ip, 161)),
ContextData(),
ObjectType(ObjectIdentity(oid)))
)

if errorIndication:
print(errorIndication)
elif errorStatus:
print(‘%s at %s’ % (errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex) – 1][0] or ‘?’))
else:
for varBind in varBinds:
return varBind[1].prettyPrint() Continue reading

Python OSC device – Motarized fader for volume + mute switch and solo switch

import reapy
import OSC

# Create an OSC client to send messages to Reaper
client = OSC.OSCClient()
client.connect(("127.0.0.1", 8000))

# Create an OSC server to receive messages from the fader and switches
server = OSC.OSCServer(("127.0.0.1", 9000))

def handle_volume(path, tags, args, source):
volume = args[0]
# Set the volume of the track using the Reaper API
reapy.connect()
track = reapy.Track(1)
track.volume = volume
reapy.disconnect()

# Add a callback for the volume fader
server.addMsgHandler("/volume", handle_volume)

def handle_mute(path, tags, args, source):
mute = args[0]
# Set the mute of the track using the Reaper API
reapy.connect()
track = reapy.Track(1)
track.mute = mute
reapy.disconnect()

# Add a callback for the mute switch
server.addMsgHandler("/mute", handle_mute)

def handle_solo(path, tags, args, source):
solo = args[0]
# Set the solo of the track using the Reaper API
reapy.connect()
track = reapy.Track(1)
track.solo = solo
reapy.disconnect()

# Add a callback for the solo switch
server.addMsgHandler("/solo", handle_solo)

# Run the OSC server
st = threading.Thread(target=server.serve_forever)
st.start()