-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplace_fs.py
More file actions
51 lines (40 loc) · 1.85 KB
/
replace_fs.py
File metadata and controls
51 lines (40 loc) · 1.85 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
from pickle import TRUE
import sys
# Check if mklittlefs.exe exists, download if not.
# This can be overriden by setting the bool below to FALSE.
doDownload = True
doesExist = False
if not os.path.exists('./mklittlefs.exe'):
if doDownload:
print("\033[96m[i] mklittlefs.exe not found, downloading from GitHub (v3.0.0)...\033[0m")
if not os.path.exists("./tmp"):
os.mkdir("./tmp")
import urllib.request
if urllib.request.urlretrieve("https://github.com/earlephilhower/mklittlefs/releases/download/3.0.0/i686-w64-mingw32-mklittlefs-295fe9b.zip", "./tmp/tmp.zip"):
print("\033[96m[i] > OK, extracting and moving file ...\033[0m")
import zipfile
with zipfile.ZipFile("./tmp/tmp.zip","r") as zip_ref:
zip_ref.extractall("./tmp/")
import shutil
if shutil.move("./tmp/mklittlefs/mklittlefs.exe", "./mklittlefs.exe"):
doesExist = True
print("\033[96m[i] > OK, cleaning up...\033[0m")
try:
shutil.rmtree("./tmp")
except OSError as e:
print("[X] > Error: %s - %s." % (e.filename, e.strerror))
print("\033[92m[i] > All done!\033[0m")
else:
print("\033[93m[!] mklittlefs.exe will not be downloaded.\033[0m")
print("\033[93m Please manually download it from 'https://github.com/earlephilhower/mklittlefs/releases'.\033[0m")
else:
doesExist = True
if doesExist:
Import("env")
print("\033[96m[i] MKSPIFFSTOOL will be replaced with 'mklittlefs.exe'.\033[0m")
env.Replace (MKSPIFFSTOOL = "mklittlefs.exe")
else:
print("\033[91m[!] mklittlefs.exe is unavailable.\n The filesystem might not build correctly!\033[0m")
# Acquire mklittlefs.exe from here: https://github.com/earlephilhower/mklittlefs/releases
# Place in root of project directory.