Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py3k compatibility #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
30 changes: 15 additions & 15 deletions try.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from __future__ import print_function
import hid
import time

for d in hid.enumerate(0, 0):
keys = d.keys()
keys.sort()
for key in keys:
print "%s : %s" % (key, d[key])
print ""
for key in sorted(keys):
print("%s : %s" % (key, d[key]))
print("")

try:
print "Opening device"
print("Opening device")
h = hid.device(0x461, 0x20)
#h = hid.device(0x1941, 0x8021) # Fine Offset USB Weather Station

print "Manufacturer: %s" % h.get_manufacturer_string()
print "Product: %s" % h.get_product_string()
print "Serial No: %s" % h.get_serial_number_string()
print("Manufacturer: %s" % h.get_manufacturer_string())
print("Product: %s" % h.get_product_string())
print("Serial No: %s" % h.get_serial_number_string())

# try non-blocking mode by uncommenting the next line
#h.set_nonblocking(1)
Expand All @@ -27,18 +27,18 @@
h.write([0x80, i, j])
d = h.read(5)
if d:
print d
print(d)
time.sleep(0.05)

print "Closing device"
print("Closing device")
h.close()

except IOError, ex:
print ex
print "You probably don't have the hard coded test hid. Update the hid.device line"
print "in this script with one from the enumeration list output above and try again."
except IOError as ex:
print(ex)
print("You probably don't have the hard coded test hid. Update the hid.device line")
print("in this script with one from the enumeration list output above and try again.")

print "Done"
print("Done")



Expand Down