fix: Use tarfile lib instead of tar UNIX tool
style: Fix UX to show more outputs
This commit is contained in:
parent
1c3bc937d9
commit
1fa5ca0ef7
2 changed files with 13 additions and 5 deletions
|
|
@ -104,12 +104,13 @@ def handle_verbosity():
|
|||
|
||||
return verbosity
|
||||
|
||||
@handle_verbosity()
|
||||
|
||||
def download_frappe_assets(verbose=True):
|
||||
"""Downloads and sets up Frappe assets if they exist based on the current
|
||||
commit HEAD.
|
||||
Returns True if correctly setup else returns False.
|
||||
"""
|
||||
from simple_chalk import green
|
||||
from subprocess import getoutput
|
||||
from tempfile import mkdtemp
|
||||
|
||||
|
|
@ -122,14 +123,20 @@ def download_frappe_assets(verbose=True):
|
|||
click.secho("Retreiving Assets...", fg="yellow")
|
||||
prefix = mkdtemp(prefix="frappe-assets-", suffix=frappe_head)
|
||||
assets_archive = download_file(url, prefix)
|
||||
print("{0} Downloaded assets archive from {1}".format(green('✔'), url))
|
||||
|
||||
if assets_archive:
|
||||
import subprocess
|
||||
import tarfile
|
||||
|
||||
click.secho("Extracting Assets...", fg="yellow")
|
||||
subprocess.check_output(
|
||||
["tar", "xf", assets_archive, "--strip", "3"], cwd=sites_path
|
||||
)
|
||||
with tarfile.open(assets_archive) as tar:
|
||||
for file in tar:
|
||||
if not file.isdir():
|
||||
dest = "." + file.name.replace("./frappe-bench/sites", "")
|
||||
show = dest.replace("./assets/", "")
|
||||
tar.makefile(file, dest)
|
||||
print("{0} Restored {1}".format(green('✔'), show))
|
||||
|
||||
build_missing_files()
|
||||
return True
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ RestrictedPython==5.0
|
|||
rq>=1.1.0
|
||||
schedule==0.6.0
|
||||
semantic-version==2.8.4
|
||||
simple-chalk==0.1.0
|
||||
six==1.14.0
|
||||
sqlparse==0.2.4
|
||||
stripe==2.40.0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue