From d7a41bb19146d66139cf9201089716aab61787fc Mon Sep 17 00:00:00 2001 From: Gleb Gusev Date: Fri, 17 Aug 2018 07:52:47 +0200 Subject: [PATCH 1/3] FIxed python interpreter definintion line --- sdls | 2 +- sdput | 2 +- sdrm | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sdls b/sdls index 949f101..e4ad7c2 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/ 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/ From fcd13f68efa0c13bf4a1a8c95d7226501f444b44 Mon Sep 17 00:00:00 2001 From: Gleb Gusev Date: Fri, 17 Aug 2018 07:53:05 +0200 Subject: [PATCH 2/3] Got rid of leftovers --- sdls | 3 --- 1 file changed, 3 deletions(-) diff --git a/sdls b/sdls index e4ad7c2..77376ad 100755 --- a/sdls +++ b/sdls @@ -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 From ad73fae94bcf1fcb66e5ab17fe9346a32e17e2b5 Mon Sep 17 00:00:00 2001 From: Gleb Gusev Date: Fri, 17 Aug 2018 07:54:24 +0200 Subject: [PATCH 3/3] Fixed directory listing for 2nd and higher levels of hierarchy --- flashair.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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)))