Skip to content

Commit

Permalink
Merge pull request #121 from onovy/python3
Browse files Browse the repository at this point in the history
Add Python 3 support
  • Loading branch information
benlye authored Mar 31, 2020
2 parents b61cdb9 + ff2a2c0 commit 80bd613
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions octoprint_firmwareupdater/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ def __init__(self, reason, *args, **kwargs):
self.reason = reason

__plugin_name__ = "Firmware Updater"
__plugin_pythoncompat__ = ">=2.7,<4"

def __plugin_load__():
global __plugin_implementation__
Expand Down
4 changes: 2 additions & 2 deletions octoprint_firmwareupdater/methods/avrdude.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ def _flash_avrdude(self, firmware=None, printer_port=None):
self._console_logger.info(u"")
self._console_logger.info(avrdude_command)
try:
p = sarge.run(avrdude_command, cwd=working_dir, async=True, stdout=sarge.Capture(), stderr=sarge.Capture())
p = sarge.run(avrdude_command, cwd=working_dir, async_=True, stdout=sarge.Capture(), stderr=sarge.Capture())
p.wait_events()

while p.returncode is None:
output = p.stderr.read(timeout=0.5)
output = p.stderr.read(timeout=0.5).decode('utf-8')
if not output:
p.commands[0].poll()
continue
Expand Down
6 changes: 3 additions & 3 deletions octoprint_firmwareupdater/methods/bossac.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ def _flash_bossac(self, firmware=None, printer_port=None):
self._console_logger.info(u"")
self._console_logger.info(bossac_command)
try:
p = sarge.run(bossac_command, cwd=working_dir, async=True, stdout=sarge.Capture(buffer_size=1), stderr=sarge.Capture(buffer_size=1))
p = sarge.run(bossac_command, cwd=working_dir, async_=True, stdout=sarge.Capture(buffer_size=1), stderr=sarge.Capture(buffer_size=1))
p.wait_events()

while p.returncode is None:
output = p.stdout.read(timeout=0.5)
output = p.stdout.read(timeout=0.5).decode('utf-8')
if not output:
p.commands[0].poll()
continue
Expand All @@ -90,7 +90,7 @@ def _flash_bossac(self, firmware=None, printer_port=None):
if p.returncode == 0:
return True
else:
output = p.stderr.read(timeout=0.5)
output = p.stderr.read(timeout=0.5).decode('utf-8')
for line in output.split("\n"):
if line.endswith("\r"):
line = line[:-1]
Expand Down
8 changes: 4 additions & 4 deletions octoprint_firmwareupdater/methods/dfuprog.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ def _flash_dfuprog(self, firmware=None, printer_port=None):
self._send_status("progress", subtype="writing")
self._console_logger.info(dfuprog_command)
try:
p = sarge.run(dfuprog_command, cwd=working_dir, async=True, stdout=sarge.Capture(buffer_size=1), stderr=sarge.Capture(buffer_size=1))
p = sarge.run(dfuprog_command, cwd=working_dir, async_=True, stdout=sarge.Capture(buffer_size=1), stderr=sarge.Capture(buffer_size=1))
p.wait_events()

while p.returncode is None:
output = p.stderr.read(timeout=0.5)
output = p.stderr.read(timeout=0.5).decode('utf-8')
if not output:
p.commands[0].poll()
continue
Expand Down Expand Up @@ -100,11 +100,11 @@ def _erase_dfuprog(self):
self._logger.info(u"Running '{}' in {}".format(dfuprog_erasecommand, working_dir))
self._console_logger.info(dfuprog_erasecommand)
try:
p = sarge.run(dfuprog_erasecommand, cwd=working_dir, async=True, stdout=sarge.Capture(buffer_size=1), stderr=sarge.Capture(buffer_size=1))
p = sarge.run(dfuprog_erasecommand, cwd=working_dir, async_=True, stdout=sarge.Capture(buffer_size=1), stderr=sarge.Capture(buffer_size=1))
p.wait_events()

while p.returncode is None:
output = p.stderr.read(timeout=0.5)
output = p.stderr.read(timeout=0.5).decode('utf-8')
if not output:
p.commands[0].poll()
continue
Expand Down
6 changes: 3 additions & 3 deletions octoprint_firmwareupdater/methods/stm32flash.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ def _flash_stm32flash(self, firmware=None, printer_port=None):
self._console_logger.info(stm32flash_command)

try:
p = sarge.run(stm32flash_command, cwd=working_dir, async=True, stdout=sarge.Capture(), stderr=sarge.Capture())
p = sarge.run(stm32flash_command, cwd=working_dir, async_=True, stdout=sarge.Capture(), stderr=sarge.Capture())
p.wait_events()

while p.returncode is None:
output = p.stdout.read(timeout=0.5)
output = p.stdout.read(timeout=0.5).decode('utf-8')
if not output:
p.commands[0].poll()
continue
Expand All @@ -95,7 +95,7 @@ def _flash_stm32flash(self, firmware=None, printer_port=None):
if p.returncode == 0:
return True
else:
output = p.stderr.read(timeout=0.5)
output = p.stderr.read(timeout=0.5).decode('utf-8')
for line in output.split("\n"):
if line.endswith("\r"):
line = line[:-1]
Expand Down

0 comments on commit 80bd613

Please sign in to comment.