File: display-error-string-when-download-failed.patch

package info (click to toggle)
nautilus-dropbox 2019.02.14-1
  • links: PTS, VCS
  • area: non-free
  • in suites: bullseye
  • size: 2,472 kB
  • sloc: sh: 4,181; python: 2,016; ansic: 2,012; makefile: 120
file content (87 lines) | stat: -rw-r--r-- 3,405 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Description: Give more info about download failures
 When you have to diagnose download failures, you need some basic
 information about the user's configuration. Print those
 information in the error message.
Author: Raphaƫl Hertzog <hertzog@debian.org>
Origin: vendor
Forwarded: no
Last-Update: 2012-08-08

--- a/dropbox.in
+++ b/dropbox.in
@@ -236,17 +236,27 @@
                 else:
                     raise
 
+def get_download_debug_info(url, e):
+    msg = "\nURL that failed to download: %s\nError: %s\n" % (url, e.strerror)
+    if "http_proxy" in os.environ:
+        msg += "http_proxy = %s" % os.environ["http_proxy"]
+    if "https_proxy" in os.environ:
+        msg += "https_proxy = %s" % os.environ["https_proxy"]
+    return msg
+
 class DownloadState(object):
     def __init__(self):
         self.local_file = StringIO.StringIO()
 
     def copy_data(self):
-        return download_file_chunk(DOWNLOAD_LOCATION_FMT % plat(), self.local_file)
+        self.url = DOWNLOAD_LOCATION_FMT % plat()
+        return download_file_chunk(self.url , self.local_file)
 
     def unpack(self):
         # download signature
         signature = StringIO.StringIO()
-        for _ in download_file_chunk(SIGNATURE_LOCATION_FMT % plat(), signature):
+        self.url = SIGNATURE_LOCATION_FMT % plat()
+        for _ in download_file_chunk(self.url, signature):
             pass
         signature.seek(0)
         self.local_file.seek(0)
@@ -373,7 +383,9 @@
                     self.unpack_dropbox()
 
                 def error(ex):
-                    FatalVisibleError(ERROR_CONNECTING)
+                    FatalVisibleError(ERROR_CONNECTING + "\n" +
+                                      get_download_debug_info(
+                                          self.download.url, ex))
 
                 self.update_progress(DOWNLOADING, 0)
                 self.task = GeneratorTask(self.download.copy_data,
@@ -396,7 +408,9 @@
                     if isinstance(ex, SignatureVerifyError):
                         FatalVisibleError(ERROR_SIGNATURE)
                     else:
-                        FatalVisibleError(ERROR_CONNECTING)
+                        FatalVisibleError(ERROR_CONNECTING + "\n" +
+                                          get_download_debug_info(
+                                              self.download.url,ex))
 
                 self.task = GeneratorTask(self.download.unpack,
                                           unpack_progress,
@@ -557,8 +571,9 @@
                 if not status:
                     break
                 setprogress(DOWNLOADING, progress)
-        except Exception:
-            FatalVisibleError(ERROR_CONNECTING)
+        except Exception as ex:
+            FatalVisibleError(ERROR_CONNECTING + "\n" +
+                              get_download_debug_info(download.url, ex))
         else:
             setprogress(DOWNLOADING, 1.0)
             console_print()
@@ -569,8 +584,9 @@
                 setprogress(UNPACKING, float(i)/total)
         except SignatureVerifyError:
             FatalVisibleError(ERROR_SIGNATURE)
-        except Exception:
-            FatalVisibleError(ERROR_CONNECTING)
+        except Exception as e:
+            FatalVisibleError(ERROR_CONNECTING + "\n" +
+                              get_download_debug_info(download.url, ex))
         else:
             setprogress(UNPACKING, 1.0)