-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsdtree
More file actions
executable file
·34 lines (30 loc) · 791 Bytes
/
sdtree
File metadata and controls
executable file
·34 lines (30 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#! /usr/bin/env python3
# display tree of files on Toshiba FlashAir SD card via wi-fi
# see https://www.flashair-developers.com/en/documents/api/
import os
import sys
import argparse
import configparser
import flashair
def tree(dir, pad):
card.dir=dir
card.get_files()
files=card.files
files.sort(key=lambda x: x[0])
ctr=len(files)
for file, size, attrib, date in files:
ctr-=1
if ctr:
print(pad[2:]+'├─', file)
else:
print(pad[2:]+'└─', file)
if attrib & 16:
if dir == '/':
dir=''
if ctr:
tree(dir+'/'+file, pad+'│ ')
else:
tree(dir+'/'+file, pad[:-2]+' ')
card=flashair.card()
card.setup()
tree('/', ' ')