Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ideascube
ARCHIVED Kiwix Hotspot
Commits
931160cb
Commit
931160cb
authored
Nov 29, 2018
by
rgaudin
Browse files
Added `wipe --sdcard /dev/xxx` CLI command
parent
42aa5239
Changes
8
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
931160cb
2.0.2
* Better etcher-cli calling and on-error logging on macOS via GUI
* Added `wipe --sdcard /dev/xxx` CLI command
2.0.1
* Changed cache directory name from `cache` to `kiwix-hotspot.cache`
...
...
kiwix-hotspot-linux.spec
View file @
931160cb
...
...
@@ -14,7 +14,7 @@ a = Analysis(['kiwix-hotspot/__main__.py'],
(
'etcher-cli'
,
'etcher-cli'
),
(
'mbr.img'
,
'.'
),
(
'vexpress-boot'
,
'vexpress-boot'
)],
hiddenimports
=
[
'gui'
,
'cli'
,
'image'
,
'cache'
],
hiddenimports
=
[
'gui'
,
'cli'
,
'image'
,
'cache'
,
'wipe'
],
hookspath
=
[
'additional-hooks'
],
runtime_hooks
=
[],
excludes
=
[],
...
...
kiwix-hotspot-macos.spec
View file @
931160cb
...
...
@@ -21,7 +21,7 @@ a = Analysis(['kiwix-hotspot/__main__.py'],
(
'etcher-cli'
,
'etcher-cli'
),
(
'mbr.img'
,
'.'
),
(
'vexpress-boot'
,
'vexpress-boot'
)],
hiddenimports
=
[
'gui'
,
'cli'
,
'image'
,
'cache'
],
hiddenimports
=
[
'gui'
,
'cli'
,
'image'
,
'cache'
,
'wipe'
],
hookspath
=
[
'additional-hooks'
],
runtime_hooks
=
[],
excludes
=
[],
...
...
kiwix-hotspot-win32.spec
View file @
931160cb
...
...
@@ -34,7 +34,7 @@ a = Analysis(['kiwix-hotspot/__main__.py'],
(
'C:\Program Files
\\
7zextra
\\
7za.dll'
,
'.'
),
(
'C:\Program Files
\\
7zextra
\\
7za.exe'
,
'.'
),
(
'C:\Program Files
\\
7zextra
\\
7zxa.dll'
,
'.'
)],
hiddenimports
=
[
'gui'
,
'cli'
,
'image'
,
'cache'
],
hiddenimports
=
[
'gui'
,
'cli'
,
'image'
,
'cache'
,
'wipe'
],
hookspath
=
[
'additional-hooks'
],
runtime_hooks
=
[],
excludes
=
[],
...
...
kiwix-hotspot-win64.spec
View file @
931160cb
...
...
@@ -34,7 +34,7 @@ a = Analysis(['kiwix-hotspot/__main__.py'],
(
'C:\Program Files
\\
7zextra
\\
x64
\\
7za.dll'
,
'.'
),
(
'C:\Program Files
\\
7zextra
\\
x64
\\
7za.exe'
,
'.'
),
(
'C:\Program Files
\\
7zextra
\\
x64
\\
7zxa.dll'
,
'.'
)],
hiddenimports
=
[
'gui'
,
'cli'
,
'image'
,
'cache'
],
hiddenimports
=
[
'gui'
,
'cli'
,
'image'
,
'cache'
,
'wipe'
],
hookspath
=
[
'additional-hooks'
],
runtime_hooks
=
[],
excludes
=
[],
...
...
kiwix-hotspot/__main__.py
View file @
931160cb
...
...
@@ -19,6 +19,11 @@ elif sys.argv[1] == "cli":
elif
sys
.
argv
[
1
]
==
"image"
:
sys
.
argv
.
pop
(
1
)
runpy
.
run_module
(
"image"
)
elif
sys
.
argv
[
1
]
==
"wipe"
:
sys
.
argv
.
pop
(
1
)
from
wipe
import
main
main
()
elif
sys
.
argv
[
1
]
==
"cache"
:
sys
.
argv
.
pop
(
1
)
from
cache
import
main
...
...
@@ -33,6 +38,7 @@ else:
sub_parser
.
add_parser
(
"cli"
,
help
=
"run it on the console"
)
sub_parser
.
add_parser
(
"image"
,
help
=
"prepare a master image"
)
sub_parser
.
add_parser
(
"cache"
,
help
=
"manage cache folder to reclaim disk space"
)
sub_parser
.
add_parser
(
"wipe"
,
help
=
"wipe an SD-card clean"
)
args
=
parser
.
parse_args
()
if
args
.
version
:
...
...
kiwix-hotspot/backend/util.py
View file @
931160cb
...
...
@@ -384,7 +384,7 @@ def get_etcher_command(image_fpath, device_fpath, logger, from_cli):
return
cmd
,
log_to_file
,
log_file
def
flash_image_with_etcher
(
image_fpath
,
device_fpath
,
retcode
):
def
flash_image_with_etcher
(
image_fpath
,
device_fpath
,
retcode
,
from_cli
=
False
):
""" flash an image onto SD-card
use only with small image as there is no output capture on OSX
...
...
@@ -392,7 +392,7 @@ def flash_image_with_etcher(image_fpath, device_fpath, retcode):
retcode is a multiprocessing.Value """
logger
=
CLILogger
()
cmd
,
log_to_file
,
log_file
=
get_etcher_command
(
image_fpath
,
device_fpath
,
logger
,
False
image_fpath
,
device_fpath
,
logger
,
from_cli
)
returncode
,
_
=
subprocess_pretty_call
(
cmd
,
check
=
False
,
logger
=
logger
)
retcode
.
value
=
returncode
...
...
kiwix-hotspot/wipe.py
0 → 100644
View file @
931160cb
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: ai ts=4 sts=4 et sw=4 nu
""" Flash a clean, single FAT partition MBR onto the specifief SD-card """
import
os
import
sys
import
argparse
import
multiprocessing
import
data
from
backend.util
import
flash_image_with_etcher
from
util
import
CLILogger
def
wipe_card
(
logger
,
sd_card
):
logger
.
step
(
"Wiping `{}` SD-card by flashing empty/clean MBR"
.
format
(
sd_card
))
retcode
=
multiprocessing
.
Value
(
"i"
,
-
1
)
flash_image_with_etcher
(
os
.
path
.
join
(
data
.
data_dir
,
"mbr.img"
),
sd_card
,
retcode
,
True
)
if
retcode
.
value
==
0
:
logger
.
succ
(
"SD-card `{}` wiped successfuly"
.
format
(
sd_card
))
else
:
logger
.
err
(
"Unable to wipe SD-card at `{}`"
.
format
(
sd_card
))
return
retcode
.
value
def
main
():
logger
=
CLILogger
()
parser
=
argparse
.
ArgumentParser
(
description
=
"SD-card Wiping Tool"
)
parser
.
add_argument
(
"--sdcard"
,
help
=
"Device path for the SD-card"
,
required
=
True
)
# defaults to help
args
=
parser
.
parse_args
([
"--help"
]
if
len
(
sys
.
argv
)
<
2
else
None
)
sys
.
exit
(
wipe_card
(
logger
,
sd_card
=
args
.
sdcard
))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment