[Pkg-privacy-commits] [tails-installer] 05/08: Better error handling in the grabber

Intrigeri intrigeri at moszumanska.debian.org
Wed May 24 15:27:36 UTC 2017


This is an automated email from the git hooks/post-receive script.

intrigeri pushed a commit to tag 3.93.1
in repository tails-installer.

commit 4257a5e5f55600525f6831810fe13c2f3c22e79a
Author: Martin Briza <mbriza at redhat.com>
Date:   Thu Apr 21 16:53:45 2016 +0200

    Better error handling in the grabber
---
 liveusb/grabber.py | 22 +++++++++++++---------
 liveusb/gui.py     |  2 +-
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/liveusb/grabber.py b/liveusb/grabber.py
index 469c251..4bd52b3 100644
--- a/liveusb/grabber.py
+++ b/liveusb/grabber.py
@@ -11,6 +11,7 @@ from PyQt5.QtCore import QStandardPaths
 
 def find_downloads():
     # todo look into SUDO_UID and PKEXEC_UID for the original user
+    path = None
     if sys.platform.startswith("linux"):
         import pwd
         uid = 0
@@ -19,10 +20,17 @@ def find_downloads():
         elif 'PKEXEC_UID' in os.environ:
             uid = int(os.environ['PKEXEC_UID'])
 
-        pw = pwd.getpwuid(uid)
-        p = subprocess.Popen(['sudo', '-u', pw[0], 'xdg-user-dir', 'DOWNLOAD'], stdout=subprocess.PIPE)
-        p.wait()
-        path = p.stdout.readline().strip()
+        try:
+            pw = pwd.getpwuid(uid)
+            p = subprocess.Popen(['sudo', '-u', pw[0], 'xdg-user-dir', 'DOWNLOAD'], stdout=subprocess.PIPE)
+            p.wait()
+            if (p.returncode == 0):
+                path = p.stdout.readline().strip()
+            if not path:
+                path = pw[5]
+        except KeyError:
+            path = tempfile.mkdtemp("liveusb-creator")
+
     else:
         path = QStandardPaths.writableLocation(QStandardPaths.DownloadLocation)
 
@@ -99,12 +107,8 @@ def download(url, target_folder=find_downloads(), update_maximum = None, update_
 
         os.rename(partial_path, full_path)
 
-    except requests.exceptions.ReadTimeout as e:
-        raise LiveUSBError("Your internet connection seems to be broken")
-    except requests.exceptions.ConnectTimeout as e:
+    except requests.exceptions.RequestException as e:
         raise LiveUSBError("Your internet connection seems to be broken")
-    except Exception as e:
-        raise LiveUSBError("Couldn't download the file: %s (%d): %s" % (r.reason, r.status_code, e.message))
 
     return full_path
 
diff --git a/liveusb/gui.py b/liveusb/gui.py
index 2796bdd..91b2a95 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -81,7 +81,7 @@ class ReleaseDownloadThread(QThread):
             self.progress.end()
             self.downloadFinished.emit(filename)
         except LiveUSBError as e:
-            self.downloadError.emit(e.args[0])
+            self.progress.release.addError(e.args[0])
 
     def terminate(self):
         QThread.terminate(self)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/tails-installer.git



More information about the Pkg-privacy-commits mailing list