Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
2nd stage of Py3 update with futurize --stage2
THIS IS NOT TESTED ON HARDWARE (I HAVE NO IOLABS BOX)
  • Loading branch information
peircej committed Apr 14, 2019
commit 164b39253f10b2ca90ea3676efdf867b20323426
9 changes: 6 additions & 3 deletions examples/simonsays.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import print_function

from builtins import input
from builtins import zip
from builtins import range
from ioLabs import USBBox, REPORT
import time

Expand All @@ -13,7 +16,7 @@ def flash(usbbox,led_mask=0xFF,rate=1,count=1):

# ensure light off first
usbbox.commands.p2set(0x00)
for i in xrange(count):
for i in range(count):
usbbox.commands.p2set(led_mask)
time.sleep(rate/2.0)
usbbox.commands.p2set(0x00)
Expand All @@ -34,7 +37,7 @@ def simon_says(usbbox,num):

# create a random sequence (0-7)
import random
order=[random.choice(xrange(8)) for i in range(num)]
order=[random.choice(range(8)) for i in range(num)]
print("simon says:", " ".join([BUTTON_COLORS[i] for i in order]))

# flash LEDs once
Expand Down Expand Up @@ -133,7 +136,7 @@ def key_report(report):
usbbox.commands.dirset(0,0,0)

while True:
command=raw_input("play game y/n [y]: ").strip()
command=input("play game y/n [y]: ").strip()
if command == '':
command = 'y'
if command.lower() != 'y':
Expand Down
8 changes: 5 additions & 3 deletions examples/simonsays2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import print_function

from builtins import input
from builtins import range
from ioLabs import USBBox, REPORT
import time

Expand All @@ -12,7 +14,7 @@ def flash(usbbox,led_mask=0xFF,rate=1,count=1):

# ensure light off first
usbbox.leds.state=0x00
for i in xrange(count):
for i in range(count):
usbbox.leds.state=led_mask
time.sleep(rate/2.0)
usbbox.leds.state=0x00
Expand All @@ -33,7 +35,7 @@ def simon_says(usbbox,num):

# create a random sequence (0-7)
import random
order=[random.choice(xrange(8)) for i in range(num)]
order=[random.choice(range(8)) for i in range(num)]
print("simon says:", " ".join([BUTTON_COLORS[i] for i in order]))

# flash LEDs once
Expand Down Expand Up @@ -116,7 +118,7 @@ def simon_says(usbbox,num):
usbbox.disable_loopback()

while True:
command=raw_input("play game y/n [y]: ").strip()
command=input("play game y/n [y]: ").strip()
if command == '':
command = 'y'
if command.lower() != 'y':
Expand Down
1 change: 1 addition & 0 deletions hid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
and interacting with those devices.
'''

from builtins import object
import logging

import os
Expand Down
5 changes: 4 additions & 1 deletion hid/cparser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
from builtins import next
from past.builtins import basestring
from builtins import object
from ctypes import *
import re

Expand Down Expand Up @@ -71,7 +74,7 @@ def __init__(self,s):

self.i=-1

def next(self):
def __next__(self):
if self.empty():
raise ValueError('no more tokens found parsing - %s' % self.s)
self.i+=1
Expand Down
6 changes: 4 additions & 2 deletions hid/osx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Refer to the hid module for available functions
'''

from builtins import range
from builtins import object
from ctypes import *
from ctypes.util import find_library

Expand Down Expand Up @@ -186,7 +188,7 @@ class IOHIDDeviceInterface122(Structure):

########################################################
# class to handle COM object references
class COMObjectRef:
class COMObjectRef(object):
def __init__(self,ref):
self.ref=ref
logging.info("created: %s",self)
Expand All @@ -195,7 +197,7 @@ def __del__(self):
logging.info("releasing: %s",self)
self.Release()

def __nonzero__(self):
def __bool__(self):
return self.ref is not None

def __str__(self):
Expand Down
Loading