validate:launcher: Give information to users when cloning asset failed

It might not be obvious from the stacktrace so it is better to clearly
explain what the failure was when we know it
This commit is contained in:
Thibault Saunier 2014-07-16 10:35:34 +02:00
parent 6beb346aa3
commit 89aa70545a

View file

@ -24,6 +24,7 @@ import loggable
import argparse
import textwrap
import reporters
import subprocess
from httpserver import HTTPServer
@ -132,6 +133,44 @@ QA_ASSETS = "gst-qa-assets"
MEDIAS_FOLDER = "medias"
DEFAULT_GST_QA_ASSETS_REPO = "git://people.freedesktop.org/~tsaunier/gst-qa-assets/"
def update_assets(options):
try:
launch_command("cd %s && %s" % (options.clone_dir,
options.update_assets_command),
fails=True)
except subprocess.CalledProcessError as e:
if "annex" in options.update_assets_command:
m = "\n\nMAKE SURE YOU HAVE git-annex INSTALLED!"
else:
m = ""
printc("Could not update assets repository\n\nError: %s%s" %(e, m),
Colors.FAIL, True)
return False
return True
def download_assets(options):
try:
launch_command("%s %s %s" % (options.get_assets_command,
options.remote_assets_url,
options.clone_dir),
fails=True)
except subprocess.CalledProcessError as e:
if "git" in options.get_assets_command:
m = "\n\nMAKE SURE YOU HAVE git INSTALLED!"
else:
m = ""
printc("Could not download assets\n\nError: %s%s" %(e, m),
Colors.FAIL, True)
return False
return True
class PrintUsage(argparse.Action):
def __init__(self, option_strings, dest=argparse.SUPPRESS, default=argparse.SUPPRESS, help=None):
super(PrintUsage, self).__init__(option_strings=option_strings, dest=dest,
@ -304,17 +343,14 @@ user argument, you can thus overrides command line options using that.
if options.remote_assets_url and options.sync:
if os.path.exists(options.clone_dir):
launch_command("cd %s && %s" % (options.clone_dir,
options.update_assets_command),
fails=True)
if not update_assets(options):
exit(1)
else:
launch_command("%s %s %s" % (options.get_assets_command,
options.remote_assets_url,
options.clone_dir),
fails=True)
launch_command("cd %s && %s" % (options.clone_dir,
options.update_assets_command),
fails=True)
if not download_assets(options):
exit(1)
if not update_assets(options):
exit(1)
# Ensure that the scenario manager singleton is ready to be used
ScenarioManager().config = options