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

Python 3 data type fixes #35

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions src/chiplotle/geometry/shapes/star_crisscross.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
standard_library.install_aliases()
from chiplotle.geometry.core.polygon import Polygon
import math
from fractions import gcd


def star_crisscross(
Expand Down Expand Up @@ -61,9 +60,9 @@ def star_crisscross(
if jump_size is None:
jump_size = int(num_points / 2)

if gcd(num_points, jump_size) != 1:
if math.gcd(num_points, jump_size) != 1:
if find_valid_jump_size:
while gcd(num_points, jump_size) != 1:
while math.gcd(num_points, jump_size) != 1:
jump_size -= 1
else:
invalid_star = [[half_width, half_height], [half_width, half_height]]
Expand Down
3 changes: 2 additions & 1 deletion src/chiplotle/plotters/baseplotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def write(self, data):
else:
print(c, type(c))
result.append(c)
data = b"".join(result)
data = "".join(result)
data = bytes(data, 'utf-8')
else:
raise TypeError("Unknown type {}, can't write to serial".format(type(data)))
self._write_bytes_to_port(data)
Expand Down
2 changes: 1 addition & 1 deletion src/chiplotle/tools/mathtools/lcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from future import standard_library

standard_library.install_aliases()
from fractions import gcd
from math import gcd


def lcm(a, b):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def instantiate_plotter_from_id(serial, id):
- `id` is a string of the plotter ID.
"""
## massage id...
id = id.replace("-", "").strip("\r")
id = id.replace(b"-", b"").strip(b"\r")
## find a plotter within existing plotters that matches ID
## and instantiate.
for plt_str in dir(plotters):
if id in plt_str:
if str(id) in plt_str:
plotter = getattr(plotters, plt_str)(serial)
return plotter
5 changes: 1 addition & 4 deletions src/chiplotle/tools/serialtools/what_plotter_in_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ def what_plotter_in_port(port, wait_time=10):
t = time.time()
while time.time() - t < wait_time:
if ser.inWaiting() > 0:
try:
id = ser.readline(eol="\r").strip("\r") # <-- old pyserial
except:
id = ser.readline().strip("\r")
id = ser.readline().strip(b"\r")

## if not just a repeater...
if id != "OI;":
Expand Down