We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Can't download and extract Gentry dataset
If trying to download "Gentry Forest Transect Dataset" the retriever seems to download the data, but gets stuck when it comes in extracting AVALANCH.xls
Moreover force quit seems the only way to close the program. 
OS: OS X El Capitan Version 10.11.3 (15D21)
Machine: Macbook Pro Early 2015 13"


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `app/download_manager.py`
Content:
```
1 """This class manages dataset downloads concurrently and processes progress
2 output."""
3 
4 import wx
5 from retriever.lib.download import DownloadThread
6 
7 
8 class DownloadManager:
9     def __init__(self, parent):
10         self.dialog = None
11         self.worker = None
12         self.queue = []
13         self.downloaded = set()
14         self.errors = set()
15         self.warnings = set()
16         self.Parent = parent
17         self.timer = wx.Timer(parent, -1)
18         self.timer.interval = 10
19         parent.Bind(wx.EVT_TIMER, self.update, self.timer)
20 
21     def Download(self, script):
22         if not script in self.queue and not (self.worker and self.worker.script == script):
23             self.queue.append(script)
24             self.downloaded.add(script)
25             if script in self.errors:
26                 self.errors.remove(script)
27                 self.warnings.remove(script)
28             self.Parent.script_list.RefreshMe(None)
29             if not self.timer.IsRunning() and not self.worker and len(self.queue) < 2:
30                 self.timer.Start(self.timer.interval)
31             return True
32         return False
33 
34     def update(self, evt):
35         self.timer.Stop()
36         terminate = False
37         if self.worker:
38             script = self.worker.script
39             if self.worker.finished() and len(self.worker.output) == 0:
40                 if hasattr(script, 'warnings') and script.warnings:
41                     self.warnings.add(script)
42                     self.Parent.SetStatusText('\n'.join(str(w) for w in script.warnings))
43                 else:
44                     self.Parent.SetStatusText("")
45                 self.worker = None
46                 self.Parent.script_list.RefreshMe(None)
47                 self.timer.Start(self.timer.interval)
48             else:
49                 self.worker.output_lock.acquire()
50                 while len(self.worker.output) > 0 and not terminate:
51                     if "Error:" in self.worker.output[0] and script in self.downloaded:
52                         self.downloaded.remove(script)
53                         self.errors.add(script)
54                     if self.write(self.worker) == False:
55                         terminate = True
56                     self.worker.output = self.worker.output[1:]
57                 #self.gauge.SetValue(100 * ((self.worker.scriptnum) /
58                 #                           (self.worker.progress_max + 1.0)))
59                 self.worker.output_lock.release()
60                 if terminate:
61                     self.Parent.Quit(None)
62                 else:
63                     self.timer.Start(self.timer.interval)
64         elif self.queue:
65             script = self.queue[0]
66             self.queue = self.queue[1:]
67             self.worker = DownloadThread(self.Parent.engine, script)
68             self.worker.parent = self
69             self.worker.start()
70             self.timer.Start(10)
71 
72     def flush(self):
73         pass
74 
75     def write(self, worker):
76         s = worker.output[0]
77 
78         if '\b' in s:
79             s = s.replace('\b', '')
80             if not self.dialog:
81                 wx.GetApp().Yield()
82                 self.dialog = wx.ProgressDialog("Download Progress",
83                                                 "Downloading datasets . . .\n"
84                                                 + "  " * len(s),
85                                                 maximum=1000,
86                                                 parent=None,
87                                                 style=wx.PD_SMOOTH
88                                                       | wx.DIALOG_NO_PARENT
89                                                       | wx.PD_CAN_ABORT
90                                                       | wx.PD_AUTO_HIDE
91                                                       | wx.PD_REMAINING_TIME
92                                                 )
93             def progress(s):
94                 if ' / ' in s:
95                     s = s.split(' / ')
96                     total = float(s[1])
97                     current = float(s[0].split(': ')[1])
98                     progress = int((current / total) * 1000)
99                     return (progress if progress > 1 else 1)
100                 else:
101                     return None
102 
103             current_progress = progress(s)
104             if current_progress:
105                 (keepgoing, skip) = self.dialog.Update(current_progress, s)
106             else:
107                 (keepgoing, skip) = self.dialog.Pulse(s)
108 
109             if not keepgoing:
110                 return False
111         else:
112             if self.dialog:
113                 self.dialog.Update(1000, "")
114                 self.dialog.Destroy()
115                 self.dialog = None
116 
117             if '...' in s:
118                 self.Parent.SetStatusText(s)
119             else:
120                 self.Parent.script_list.SetStatus(worker.script.name, s)
121 
122         wx.GetApp().Yield()
123         return True
124
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/app/download_manager.py b/app/download_manager.py
--- a/app/download_manager.py
+++ b/app/download_manager.py
@@ -102,8 +102,9 @@
 
             current_progress = progress(s)
             if current_progress:
-                (keepgoing, skip) = self.dialog.Update(current_progress, s)
-            else:
+            # download progress remaining-time disabled. causes bottle neck on Gentry ref: #396.
+            #     (keepgoing, skip) = self.dialog.Update(current_progress, s)
+            # else:
                 (keepgoing, skip) = self.dialog.Pulse(s)
 
             if not keepgoing:

{"golden_diff": "diff --git a/app/download_manager.py b/app/download_manager.py\n--- a/app/download_manager.py\n+++ b/app/download_manager.py\n@@ -102,8 +102,9 @@\n \n             current_progress = progress(s)\n             if current_progress:\n-                (keepgoing, skip) = self.dialog.Update(current_progress, s)\n-            else:\n+            # download progress remaining-time disabled. causes bottle neck on Gentry ref: #396.\n+            #     (keepgoing, skip) = self.dialog.Update(current_progress, s)\n+            # else:\n                 (keepgoing, skip) = self.dialog.Pulse(s)\n \n             if not keepgoing:\n", "issue": "Can't download and extract Gentry dataset\nIf trying to download \"Gentry Forest Transect Dataset\" the retriever seems to download the data, but gets stuck when it comes in extracting AVALANCH.xls\nMoreover force quit seems the only way to close the program. \nOS: OS X El Capitan Version 10.11.3 (15D21)\nMachine: Macbook Pro Early 2015 13\"\n\n", "before_files": [{"content": "\"\"\"This class manages dataset downloads concurrently and processes progress\noutput.\"\"\"\n\nimport wx\nfrom retriever.lib.download import DownloadThread\n\n\nclass DownloadManager:\n    def __init__(self, parent):\n        self.dialog = None\n        self.worker = None\n        self.queue = []\n        self.downloaded = set()\n        self.errors = set()\n        self.warnings = set()\n        self.Parent = parent\n        self.timer = wx.Timer(parent, -1)\n        self.timer.interval = 10\n        parent.Bind(wx.EVT_TIMER, self.update, self.timer)\n\n    def Download(self, script):\n        if not script in self.queue and not (self.worker and self.worker.script == script):\n            self.queue.append(script)\n            self.downloaded.add(script)\n            if script in self.errors:\n                self.errors.remove(script)\n                self.warnings.remove(script)\n            self.Parent.script_list.RefreshMe(None)\n            if not self.timer.IsRunning() and not self.worker and len(self.queue) < 2:\n                self.timer.Start(self.timer.interval)\n            return True\n        return False\n\n    def update(self, evt):\n        self.timer.Stop()\n        terminate = False\n        if self.worker:\n            script = self.worker.script\n            if self.worker.finished() and len(self.worker.output) == 0:\n                if hasattr(script, 'warnings') and script.warnings:\n                    self.warnings.add(script)\n                    self.Parent.SetStatusText('\\n'.join(str(w) for w in script.warnings))\n                else:\n                    self.Parent.SetStatusText(\"\")\n                self.worker = None\n                self.Parent.script_list.RefreshMe(None)\n                self.timer.Start(self.timer.interval)\n            else:\n                self.worker.output_lock.acquire()\n                while len(self.worker.output) > 0 and not terminate:\n                    if \"Error:\" in self.worker.output[0] and script in self.downloaded:\n                        self.downloaded.remove(script)\n                        self.errors.add(script)\n                    if self.write(self.worker) == False:\n                        terminate = True\n                    self.worker.output = self.worker.output[1:]\n                #self.gauge.SetValue(100 * ((self.worker.scriptnum) /\n                #                           (self.worker.progress_max + 1.0)))\n                self.worker.output_lock.release()\n                if terminate:\n                    self.Parent.Quit(None)\n                else:\n                    self.timer.Start(self.timer.interval)\n        elif self.queue:\n            script = self.queue[0]\n            self.queue = self.queue[1:]\n            self.worker = DownloadThread(self.Parent.engine, script)\n            self.worker.parent = self\n            self.worker.start()\n            self.timer.Start(10)\n\n    def flush(self):\n        pass\n\n    def write(self, worker):\n        s = worker.output[0]\n\n        if '\\b' in s:\n            s = s.replace('\\b', '')\n            if not self.dialog:\n                wx.GetApp().Yield()\n                self.dialog = wx.ProgressDialog(\"Download Progress\",\n                                                \"Downloading datasets . . .\\n\"\n                                                + \"  \" * len(s),\n                                                maximum=1000,\n                                                parent=None,\n                                                style=wx.PD_SMOOTH\n                                                      | wx.DIALOG_NO_PARENT\n                                                      | wx.PD_CAN_ABORT\n                                                      | wx.PD_AUTO_HIDE\n                                                      | wx.PD_REMAINING_TIME\n                                                )\n            def progress(s):\n                if ' / ' in s:\n                    s = s.split(' / ')\n                    total = float(s[1])\n                    current = float(s[0].split(': ')[1])\n                    progress = int((current / total) * 1000)\n                    return (progress if progress > 1 else 1)\n                else:\n                    return None\n\n            current_progress = progress(s)\n            if current_progress:\n                (keepgoing, skip) = self.dialog.Update(current_progress, s)\n            else:\n                (keepgoing, skip) = self.dialog.Pulse(s)\n\n            if not keepgoing:\n                return False\n        else:\n            if self.dialog:\n                self.dialog.Update(1000, \"\")\n                self.dialog.Destroy()\n                self.dialog = None\n\n            if '...' in s:\n                self.Parent.SetStatusText(s)\n            else:\n                self.Parent.script_list.SetStatus(worker.script.name, s)\n\n        wx.GetApp().Yield()\n        return True\n", "path": "app/download_manager.py"}], "after_files": [{"content": "\"\"\"This class manages dataset downloads concurrently and processes progress\noutput.\"\"\"\n\nimport wx\nfrom retriever.lib.download import DownloadThread\n\n\nclass DownloadManager:\n    def __init__(self, parent):\n        self.dialog = None\n        self.worker = None\n        self.queue = []\n        self.downloaded = set()\n        self.errors = set()\n        self.warnings = set()\n        self.Parent = parent\n        self.timer = wx.Timer(parent, -1)\n        self.timer.interval = 10\n        parent.Bind(wx.EVT_TIMER, self.update, self.timer)\n\n    def Download(self, script):\n        if not script in self.queue and not (self.worker and self.worker.script == script):\n            self.queue.append(script)\n            self.downloaded.add(script)\n            if script in self.errors:\n                self.errors.remove(script)\n                self.warnings.remove(script)\n            self.Parent.script_list.RefreshMe(None)\n            if not self.timer.IsRunning() and not self.worker and len(self.queue) < 2:\n                self.timer.Start(self.timer.interval)\n            return True\n        return False\n\n    def update(self, evt):\n        self.timer.Stop()\n        terminate = False\n        if self.worker:\n            script = self.worker.script\n            if self.worker.finished() and len(self.worker.output) == 0:\n                if hasattr(script, 'warnings') and script.warnings:\n                    self.warnings.add(script)\n                    self.Parent.SetStatusText('\\n'.join(str(w) for w in script.warnings))\n                else:\n                    self.Parent.SetStatusText(\"\")\n                self.worker = None\n                self.Parent.script_list.RefreshMe(None)\n                self.timer.Start(self.timer.interval)\n            else:\n                self.worker.output_lock.acquire()\n                while len(self.worker.output) > 0 and not terminate:\n                    if \"Error:\" in self.worker.output[0] and script in self.downloaded:\n                        self.downloaded.remove(script)\n                        self.errors.add(script)\n                    if self.write(self.worker) == False:\n                        terminate = True\n                    self.worker.output = self.worker.output[1:]\n                #self.gauge.SetValue(100 * ((self.worker.scriptnum) /\n                #                           (self.worker.progress_max + 1.0)))\n                self.worker.output_lock.release()\n                if terminate:\n                    self.Parent.Quit(None)\n                else:\n                    self.timer.Start(self.timer.interval)\n        elif self.queue:\n            script = self.queue[0]\n            self.queue = self.queue[1:]\n            self.worker = DownloadThread(self.Parent.engine, script)\n            self.worker.parent = self\n            self.worker.start()\n            self.timer.Start(10)\n\n    def flush(self):\n        pass\n\n    def write(self, worker):\n        s = worker.output[0]\n\n        if '\\b' in s:\n            s = s.replace('\\b', '')\n            if not self.dialog:\n                wx.GetApp().Yield()\n                self.dialog = wx.ProgressDialog(\"Download Progress\",\n                                                \"Downloading datasets . . .\\n\"\n                                                + \"  \" * len(s),\n                                                maximum=1000,\n                                                parent=None,\n                                                style=wx.PD_SMOOTH\n                                                      | wx.DIALOG_NO_PARENT\n                                                      | wx.PD_CAN_ABORT\n                                                      | wx.PD_AUTO_HIDE\n                                                      | wx.PD_REMAINING_TIME\n                                                )\n            def progress(s):\n                if ' / ' in s:\n                    s = s.split(' / ')\n                    total = float(s[1])\n                    current = float(s[0].split(': ')[1])\n                    progress = int((current / total) * 1000)\n                    return (progress if progress > 1 else 1)\n                else:\n                    return None\n\n            current_progress = progress(s)\n            if current_progress:\n            # download progress remaining-time disabled. causes bottle neck on Gentry ref: #396.\n            #     (keepgoing, skip) = self.dialog.Update(current_progress, s)\n            # else:\n                (keepgoing, skip) = self.dialog.Pulse(s)\n\n            if not keepgoing:\n                return False\n        else:\n            if self.dialog:\n                self.dialog.Update(1000, \"\")\n                self.dialog.Destroy()\n                self.dialog = None\n\n            if '...' in s:\n                self.Parent.SetStatusText(s)\n            else:\n                self.Parent.script_list.SetStatus(worker.script.name, s)\n\n        wx.GetApp().Yield()\n        return True\n", "path": "app/download_manager.py"}]}