From 6474f252530dcdae334387b85f4409c98759fea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 8 Aug 2014 12:20:46 +0200 Subject: [PATCH] Be able to cope with more types of SD card file list Now only takes a look at the last contained item in a split for whitespace of the filename. If that's parseable as an integer, it's probably the size of the file and everything before that the filename. If not, the whole line is the filename, regardless of how many whitespace in contains in between. See #534 --- src/octoprint/util/comm.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 0b3da3d8..963a4d86 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -646,19 +646,20 @@ class MachineCom(object): ##~~ SD file list # if we are currently receiving an sd file list, each line is just a filename, so just read it and abort processing if self._sdFileList and not "End file list" in line: - fileinfo = line.strip().split(None, 2) + preprocessed_line = line.strip().lower() + fileinfo = preprocessed_line.rsplit(None, 1) if len(fileinfo) > 1: - # we got extended file information here, so let's split filename and size and try to make them a bit nicer + # we might have extended file information here, so let's split filename and size and try to make them a bit nicer filename, size = fileinfo - filename = filename.lower() try: size = int(size) except ValueError: - # whatever that was, it was not an integer, so we'll just ignore it and set size to None + # whatever that was, it was not an integer, so we'll just use the whole line as filename and set size to None + filename = preprocessed_line size = None else: # no extended file information, so only the filename is there and we set size to None - filename = fileinfo[0].lower() + filename = preprocessed_line size = None if isGcodeFileName(filename):