To judge download is successful or not 97/37597/2
authorwutianwei <wutianwei1@huawei.com>
Mon, 17 Jul 2017 03:08:41 +0000 (11:08 +0800)
committerwutianwei <wutianwei1@huawei.com>
Mon, 17 Jul 2017 04:11:58 +0000 (12:11 +0800)
if download fialed then exit

Change-Id: I40d847523ac5448c51d0788f79e4af9737bb5944
Signed-off-by: wutianwei <wutianwei1@huawei.com>
build/parser.py

index 63eb494..b80709c 100644 (file)
@@ -43,7 +43,9 @@ def get_from_cache(cache, package):
     print "downloading remote file to local...."
     cmd = "curl --connect-timeout 10 -o " + localfile + " " + remotefile
     print cmd
-    os.system(cmd)
+    rc = os.system(cmd)
+    if rc != 0:
+        sys.exit(1)
 
 
 def get_from_git(cache, package):
@@ -53,7 +55,9 @@ def get_from_git(cache, package):
     os.system(cmd)
     cmd = "git clone " + package.get("url") + " " + localfile
     print cmd
-    os.system(cmd)
+    rc = os.system(cmd)
+    if rc != 0:
+        sys.exit(1)
 
 
 def get_from_docker(cache, package):
@@ -61,14 +65,18 @@ def get_from_docker(cache, package):
     os.system(cmd)
     cmd = "sudo docker save "+package.get("url")+" -o "+cache+"/"
     cmd += package.get("name")+".tar"
-    os.system(cmd)
+    rc = os.system(cmd)
+    if rc != 0:
+        sys.exit(1)
 
 
 def get_from_curl(cache, package):
     cmd = "curl --connect-timeout 10 -o " + cache + "/"
     cmd += package.get("name") + " " + package.get("url")
     print cmd
-    os.system(cmd)
+    rc = os.system(cmd)
+    if rc != 0:
+        sys.exit(1)
 
 
 def usage():