mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
[enh] Get completely rid of os.system calls in _fetch_app_from_git
This commit is contained in:
parent
ca9abffbe8
commit
db7fb0c3f9
1 changed files with 19 additions and 12 deletions
|
@ -1151,8 +1151,11 @@ def _fetch_app_from_git(app):
|
||||||
Dict manifest
|
Dict manifest
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
app_tmp_archive = '{0}.zip'.format(app_tmp_folder)
|
||||||
if os.path.exists(app_tmp_folder):
|
if os.path.exists(app_tmp_folder):
|
||||||
shutil.rmtree(app_tmp_folder)
|
shutil.rmtree(app_tmp_folder)
|
||||||
|
if os.path.exists(app_tmp_archive):
|
||||||
|
os.remove(app_tmp_archive)
|
||||||
|
|
||||||
msignals.display(m18n.n('downloading'))
|
msignals.display(m18n.n('downloading'))
|
||||||
|
|
||||||
|
@ -1170,15 +1173,16 @@ def _fetch_app_from_git(app):
|
||||||
tarball_url = "{url}/archive/{tree}.zip".format(
|
tarball_url = "{url}/archive/{tree}.zip".format(
|
||||||
url=url, tree=branch
|
url=url, tree=branch
|
||||||
)
|
)
|
||||||
if os.system('wget "%s" -O "%s.zip" > /dev/null 2>&1' % (
|
try:
|
||||||
tarball_url, app_tmp_folder)) == 0:
|
subprocess.check_call([
|
||||||
manifest = _extract_app_from_file(
|
'wget', '-qO', app_tmp_archive, tarball_url])
|
||||||
app_tmp_folder +'.zip', remove=True)
|
except subprocess.CalledProcessError:
|
||||||
del manifest['remote']
|
logger.exception('unable to download %s', tarball_url)
|
||||||
else:
|
|
||||||
logger.debug('unable to download %s', tarball_url)
|
|
||||||
raise MoulinetteError(errno.EIO,
|
raise MoulinetteError(errno.EIO,
|
||||||
m18n.n('app_sources_fetch_failed'))
|
m18n.n('app_sources_fetch_failed'))
|
||||||
|
else:
|
||||||
|
manifest = _extract_app_from_file(
|
||||||
|
app_tmp_archive, remove=True)
|
||||||
else:
|
else:
|
||||||
tree_index = url.rfind('/tree/')
|
tree_index = url.rfind('/tree/')
|
||||||
if tree_index > 0:
|
if tree_index > 0:
|
||||||
|
@ -1227,13 +1231,16 @@ def _fetch_app_from_git(app):
|
||||||
tarball_url = "{url}/archive/{tree}.zip".format(
|
tarball_url = "{url}/archive/{tree}.zip".format(
|
||||||
url=url, tree=app_info['git']['revision']
|
url=url, tree=app_info['git']['revision']
|
||||||
)
|
)
|
||||||
if os.system('wget "%s" -O "%s.zip" > /dev/null 2>&1' % (
|
try:
|
||||||
tarball_url, app_tmp_folder)) == 0:
|
subprocess.check_call([
|
||||||
manifest = _extract_app_from_file(
|
'wget', '-qO', app_tmp_archive, tarball_url])
|
||||||
app_tmp_folder +'.zip', remove=True)
|
except subprocess.CalledProcessError:
|
||||||
else:
|
logger.exception('unable to download %s', tarball_url)
|
||||||
raise MoulinetteError(errno.EIO,
|
raise MoulinetteError(errno.EIO,
|
||||||
m18n.n('app_sources_fetch_failed'))
|
m18n.n('app_sources_fetch_failed'))
|
||||||
|
else:
|
||||||
|
manifest = _extract_app_from_file(
|
||||||
|
app_tmp_archive, remove=True)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
|
|
Loading…
Add table
Reference in a new issue