let python sub processes use python3

This commit is contained in:
Dave Conway-Jones
2018-07-07 19:24:35 +01:00
parent 88f7f52f99
commit b4fca36ab6
12 changed files with 62 additions and 74 deletions

View File

@@ -6,10 +6,6 @@ import sys
bounce = 20 # bounce time in mS to apply
if sys.version_info >= (3,0):
print("Sorry - currently only configured to work with python 2.x")
sys.exit(1)
if len(sys.argv) > 1:
cmd = sys.argv[1].lower()
pin = int(sys.argv[2])
@@ -17,7 +13,7 @@ if len(sys.argv) > 1:
GPIO.setwarnings(False)
if cmd == "pwm":
#print "Initialised pin "+str(pin)+" to PWM"
#print("Initialised pin "+str(pin)+" to PWM")
GPIO.setup(pin,GPIO.OUT)
p = GPIO.PWM(pin, 100)
p.start(0)
@@ -32,10 +28,10 @@ if len(sys.argv) > 1:
GPIO.cleanup(pin)
sys.exit(0)
except Exception as ex:
print "bad data: "+data
print("bad data: "+data)
elif cmd == "buzz":
#print "Initialised pin "+str(pin)+" to Buzz"
#print("Initialised pin "+str(pin)+" to Buzz")
GPIO.setup(pin,GPIO.OUT)
p = GPIO.PWM(pin, 100)
p.stop()
@@ -54,10 +50,10 @@ if len(sys.argv) > 1:
GPIO.cleanup(pin)
sys.exit(0)
except Exception as ex:
print "bad data: "+data
print("bad data: "+data)
elif cmd == "out":
#print "Initialised pin "+str(pin)+" to OUT"
#print("Initialised pin "+str(pin)+" to OUT")
GPIO.setup(pin,GPIO.OUT)
if len(sys.argv) == 4:
GPIO.output(pin,int(sys.argv[3]))
@@ -78,9 +74,9 @@ if len(sys.argv) > 1:
GPIO.output(pin,data)
elif cmd == "in":
#print "Initialised pin "+str(pin)+" to IN"
#print("Initialised pin "+str(pin)+" to IN")
def handle_callback(chan):
print GPIO.input(chan)
print(GPIO.input(chan))
if len(sys.argv) == 4:
if sys.argv[3].lower() == "up":
@@ -91,7 +87,7 @@ if len(sys.argv) > 1:
GPIO.setup(pin,GPIO.IN)
else:
GPIO.setup(pin,GPIO.IN)
print GPIO.input(pin)
print(GPIO.input(pin))
GPIO.add_event_detect(pin, GPIO.BOTH, callback=handle_callback, bouncetime=bounce)
while True:
@@ -104,7 +100,7 @@ if len(sys.argv) > 1:
sys.exit(0)
elif cmd == "byte":
#print "Initialised BYTE mode - "+str(pin)+
#print("Initialised BYTE mode - "+str(pin)+)
list = [7,11,13,12,15,16,18,22]
GPIO.setup(list,GPIO.OUT)
@@ -127,7 +123,7 @@ if len(sys.argv) > 1:
GPIO.output(list[bit], data & mask)
elif cmd == "borg":
#print "Initialised BORG mode - "+str(pin)+
#print("Initialised BORG mode - "+str(pin)+)
GPIO.setup(11,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
GPIO.setup(15,GPIO.OUT)
@@ -154,10 +150,10 @@ if len(sys.argv) > 1:
data = 0
elif cmd == "rev":
print GPIO.RPI_REVISION
print(GPIO.RPI_REVISION)
elif cmd == "ver":
print GPIO.VERSION
print(GPIO.VERSION)
elif cmd == "mouse": # catch mice button events
file = open( "/dev/input/mice", "rb" )
@@ -171,7 +167,7 @@ if len(sys.argv) > 1:
button = ord( buf[0] ) & pin # mask out just the required button(s)
if button != oldbutt: # only send if changed
oldbutt = button
print button
print(button)
while True:
try:
@@ -181,4 +177,4 @@ if len(sys.argv) > 1:
sys.exit(0)
else:
print "Bad parameters - in|out|pwm|buzz|byte|borg|mouse|ver pin {value|up|down}"
print("Bad parameters - in|out|pwm|buzz|byte|borg|mouse|ver pin {value|up|down}")

View File

@@ -1,6 +1,6 @@
{
"name" : "node-red-node-ledborg",
"version" : "0.0.19",
"version" : "0.0.20",
"description" : "A Node-RED node to control a PiBorg LedBorg board for a Raspberry Pi.",
"dependencies" : {
},