nec_control/bulkaction.py

32 lines
735 B
Python
Executable File

#!/usr/bin/env python
import sys, os
mydir = os.path.dirname(__file__)
sys.path.append(mydir)
sys.path.append(mydir + os.sep + 'include')
import config
from control import nec_control
action = sys.argv[1]
if not (action == "powerOn" or action == "powerOff"):
print("Syntax error")
print("Usage:")
print(" " + sys.argv[0] + " [ powerOn | powerOff ]")
sys.exit()
for i in config.displays:
try:
display = nec_control(i['address'], i['id'])
if action == "powerOn":
display.powerOn()
elif action == "powerOff":
display.powerOff()
del(display)
except:
print(i['address'] + ': Connection error')
else:
print(i['address'] + ': Success')