Skip to content

Commit

Permalink
Define raw_input() in Python 3 (node-red#473)
Browse files Browse the repository at this point in the history
Many thanks
  • Loading branch information
cclauss authored and dceejay committed Aug 12, 2018
1 parent 335c46a commit 8fe2478
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 3 deletions.
5 changes: 5 additions & 0 deletions hardware/LEDborg/nrgpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import RPi.GPIO as GPIO
import sys

try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3

bounce = 20 # bounce time in mS to apply

if len(sys.argv) > 1:
Expand Down
8 changes: 7 additions & 1 deletion hardware/PiLcd/nrlcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
import RPi.GPIO as GPIO
import time
import sys
import os, select
import os
import select

try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3

# Turn off warnings if you run it a second time...
GPIO.setwarnings(False)
Expand Down
5 changes: 5 additions & 0 deletions hardware/PiLiter/nrgpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import RPi.GPIO as GPIO
import sys

try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3

bounce = 20 # bounce time in mS to apply

if len(sys.argv) > 1:
Expand Down
7 changes: 6 additions & 1 deletion hardware/Pibrella/nrgpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
import subprocess
from time import sleep

try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3

bounce = 25;

if len(sys.argv) > 2:
Expand Down Expand Up @@ -177,7 +182,7 @@ def getMouseEvent():
elif cmd == "kbd": # catch keyboard button events
try:
while not os.path.isdir("/dev/input/by-path"):
time.sleep(10)
sleep(10)
infile = subprocess.check_output("ls /dev/input/by-path/ | grep -m 1 'kbd'", shell=True).strip()
infile_path = "/dev/input/by-path/" + infile
EVENT_SIZE = struct.calcsize('llHHI')
Expand Down
5 changes: 5 additions & 0 deletions hardware/neopixel/neopix.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
from neopixel import Adafruit_NeoPixel as PixelStrip, Color
__version__ = "legacy"

try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3

# LED strip configuration:
LED_COUNT = 8 # Number of LED pixels.
LED_PIN = 18 # GPIO pin connected to the pixels (must support PWM!).
Expand Down
6 changes: 6 additions & 0 deletions hardware/sensehat/sensehat.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@

from sense_hat import SenseHat

try:
StandardError # Python 2
except NameError:
StandardError = Exception # Python 3


EVENT_FORMAT = 'llHHI'
EVENT_SIZE = struct.calcsize(EVENT_FORMAT)
EVENT_NAMES = {103:'U',105:'L',106:'R',108:'D',28:'E'}
Expand Down
3 changes: 2 additions & 1 deletion hardware/unicorn/unihat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/python

# Import library functions we need
from __future__ import print_function
import sys
import os
import unicornhat as UH
Expand Down Expand Up @@ -64,4 +65,4 @@
except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program
sys.exit(0)
except Exception as ex:
print "bad data: "+data
print("bad data: "+data)

0 comments on commit 8fe2478

Please sign in to comment.