chiark / gitweb /
throw proper error when download of apks fail
authorMichael Pöhn <michael.poehn@fsfe.org>
Thu, 20 Apr 2017 15:48:38 +0000 (17:48 +0200)
committerMichael Pöhn <michael.poehn@fsfe.org>
Thu, 20 Apr 2017 15:48:38 +0000 (17:48 +0200)
fdroidserver/build.py
fdroidserver/net.py
fdroidserver/verify.py

index 4029b08ff56a835a73d8b933830d5cba5fd5cc28..c63df9d14a07711dcd23be46109fde1d85dfa9ca 100644 (file)
@@ -27,6 +27,7 @@ import tarfile
 import traceback
 import time
 import json
+import requests
 from configparser import ConfigParser
 from argparse import ArgumentParser
 import logging
@@ -1212,7 +1213,10 @@ def main():
                         logging.info("...retrieving " + url)
                         of = "{0}_{1}.apk.binary".format(app.id, build.versionCode)
                         of = os.path.join(output_dir, of)
-                        net.download_file(url, local_filename=of)
+                        try:
+                            net.download_file(url, local_filename=of)
+                        except requests.exceptions.HTTPError as e:
+                            raise FDroidException('downloading Binaries from %s failed' % url) from e
 
                     build_succeeded.append(app)
                     wikilog = "Build succeeded"
index c5bf283c9f89ebedafe50bd8dbbd7a4cd9678b05..f7932440302ab5d64eb34f07374614c8ae32ec85 100644 (file)
@@ -26,7 +26,8 @@ def download_file(url, local_filename=None, dldir='tmp'):
     if local_filename is None:
         local_filename = os.path.join(dldir, filename)
     # the stream=True parameter keeps memory usage low
-    r = requests.get(url, stream=True)
+    r = requests.get(url, stream=True, allow_redirects=True)
+    r.raise_for_status()
     with open(local_filename, 'wb') as f:
         for chunk in r.iter_content(chunk_size=1024):
             if chunk:  # filter out keep-alive new chunks
index cac31a9c832f76d344b05bd18b20b6408e30ca2c..8539775f3954dd06f2029cb78f6a6ed92b2f3a47 100644 (file)
@@ -19,6 +19,7 @@
 import sys
 import os
 import glob
+import requests
 from argparse import ArgumentParser
 import logging
 
@@ -76,7 +77,10 @@ def main():
                 os.remove(remoteapk)
             url = 'https://f-droid.org/repo/' + apkfilename
             logging.info("...retrieving " + url)
-            net.download_file(url, dldir=tmp_dir)
+            try:
+                net.download_file(url, dldir=tmp_dir)
+            except requests.exceptions.HTTPError as e:
+                raise FDroidException('downloading %s failed', url) from e
 
             compare_result = common.verify_apks(
                 remoteapk,