Just what the title says!
import maya.cmds as cmds
swatchState= cmds.renderThumbnailUpdate(q=True)
if swatchState == 0:
cmds.renderThumbnailUpdate (1)
print("\nSwatches turned ON")
else:
cmds.renderThumbnailUpdate (0)
print("\nSwatches turned OFF")