aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2024-03-21 22:10:27 -0400
committerKevin O'Connor <kevin@koconnor.net>2024-04-02 21:59:55 -0400
commit9e1cbdcee3defd9ce173316a96074de5b13e7a74 (patch)
tree0b9374e6a11c4ab703b3f839c5df9310540dc003 /klippy
parent0aacbc39736c933491690bf8174a0658acf4482f (diff)
downloadkutter-9e1cbdcee3defd9ce173316a96074de5b13e7a74.tar.gz
kutter-9e1cbdcee3defd9ce173316a96074de5b13e7a74.tar.xz
kutter-9e1cbdcee3defd9ce173316a96074de5b13e7a74.zip
virtual_sdcard: Fix handling of unicode characters on Python2
Commit 600e89ae fixed unicode handling on Python3, but broke Python2 support. Use an alternate implementation that should work for both Python3 and Python2. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/extras/virtual_sdcard.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/klippy/extras/virtual_sdcard.py b/klippy/extras/virtual_sdcard.py
index 1bb914ab..d49ebbcc 100644
--- a/klippy/extras/virtual_sdcard.py
+++ b/klippy/extras/virtual_sdcard.py
@@ -1,9 +1,9 @@
# Virtual sdcard support (print files directly from a host g-code file)
#
-# Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net>
+# Copyright (C) 2018-2024 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import os, logging, io
+import os, sys, logging, io
VALID_GCODE_EXTS = ['gcode', 'g', 'gco']
@@ -258,7 +258,10 @@ class VirtualSD:
# Dispatch command
self.cmd_from_sd = True
line = lines.pop()
- next_file_position = self.file_position + len(line.encode()) + 1
+ if sys.version_info.major >= 3:
+ next_file_position = self.file_position + len(line.encode()) + 1
+ else:
+ next_file_position = self.file_position + len(line) + 1
self.next_file_position = next_file_position
try:
self.gcode.run_script(line)