diff --git a/flashair.py b/flashair.py index d45b181..0997c9a 100755 --- a/flashair.py +++ b/flashair.py @@ -58,8 +58,10 @@ def get_files(self): print('error', r.status_code) sys.exit(1) - for line in r.text.split()[1:]: + for line in r.text.split("\r\n")[1:]: # this code has to handle commas in file name and directory name. in data that's comma-delimited + if not len(line.strip()): + continue first, size, attrib, date, time=line.rsplit(',', 4) - file=first[len(self.dir):] + file=first[len(self.dir):].strip(',') # to strip the comma on higher levels self.files.append((file, int(size), int(attrib))) diff --git a/sdls b/sdls index 949f101..77376ad 100755 --- a/sdls +++ b/sdls @@ -1,4 +1,4 @@ -#! /usr/bin/python3 +#!/usr/bin/env python3 # list files on Toshiba FlashAir SD card via wi-fi # see https://www.flashair-developers.com/en/documents/api/ @@ -38,9 +38,6 @@ for file, size, attrib in card.files: else: # this is a file # comma-formatted number - kb=size/1024 - mb=size/1048576 - gb=size/1073741824 output.append((size, file, '{:,}'.format(size), fmt(size))) sum+=size diff --git a/sdput b/sdput index da9187f..550b8c8 100755 --- a/sdput +++ b/sdput @@ -1,4 +1,4 @@ -#! /usr/bin/python3 +#!/usr/bin/env python3 # put files on Toshiba FlashAir SD card via wi-fi # see https://www.flashair-developers.com/en/documents/api/ diff --git a/sdrm b/sdrm index d21903a..551bb68 100755 --- a/sdrm +++ b/sdrm @@ -1,4 +1,4 @@ -#! /usr/bin/python3 +#!/usr/bin/env python3 # delete files from Toshiba FlashAir SD card via wi-fi # see https://www.flashair-developers.com/en/documents/api/