~ubuntu-branches/ubuntu/precise/update-notifier/precise

« back to all changes in this revision

Viewing changes to data/package-data-downloader

  • Committer: Package Import Robot
  • Author(s): Steve Langasek
  • Date: 2012-04-13 03:49:10 UTC
  • Revision ID: package-import@ubuntu.com-20120413034910-mcsgimr71vhm20xi
Tags: 0.119ubuntu7
* Use <proto>_proxy environment variables to choose the proxy to use for
  data downloads, not the apt proxy settings, because apt may be
  configured to point at a package-specific proxy.  This makes proxy
  configuration a little less convenient than before for the
  flashplugin-installer package, but it at least it makes it possible to
  have a different proxy setting for packages vs. arbitrary data
  downloads, which otherwise we don't have any way to support.
  LP: #979477.
* Stop processing after a fatal download error, not just a transient one,
  so that we can't be tricked into feeding a partial list of files to a
  handler.  Thanks to Kees Cook for spotting the bug.  LP: #979426.
* Flush stdout before calling subprocess, so that log output makes more
  sense.
* Print a more meaningful status message when downloading, instead of just
  a bare URL.
* Check for existence of /usr/lib/update-notifier/package-data-downloader
  before trying to run it from our cron job, so that the package doesn't
  generate error messages when removed but not purged.
* The action for our notification should call gksu instead of trying to
  run the command directly without root access.  This is imperfect because
  kubuntu won't have gksudo available by default, but it's an improvement
  over failing for everybody.  LP: #976761.

Show diffs side-by-side

added added

removed removed

Lines of Context:
174
174
        Failed downloads are reported to the user via the
175
175
        update-notifier interface."""
176
176
 
177
 
        # Get our proxy settings from apt
 
177
        # Get our proxy settings from the environment
178
178
        proxies = {}
179
179
        try:
180
180
                for proto in ('http','https','ftp'):
181
 
                        proxies[proto] = apt.apt_pkg.config.get("Acquire::"+proto+"::Proxy")
182
 
                        if not proxies[proto]:
183
 
                                proxies.pop(proto)
 
181
                        try:
 
182
                                proxies[proto] = os.environ[proto+"_proxy"]
 
183
                        except KeyError:
 
184
                                pass
184
185
 
185
186
                if proxies:
186
187
                        urllib._urlopener = urllib.FancyURLopener(proxies)
229
230
                                # Download each file and verify the sum
230
231
                                try:
231
232
                                        for i in range(len(files)):
232
 
                                                print files[i]
 
233
                                                print "%s: downloading %s" % (relfile, files[i])
233
234
                                                dest_file = urllib.urlretrieve(files[i])[0]
234
235
                                                output = subprocess.check_output(["sha256sum", dest_file])
235
236
                                                output = output.split(' ')[0]
238
239
                                                else:
239
240
                                                        record_failure(relfile)
240
241
                                                        break
241
 
                                        if relfile in failures:
 
242
                                        if relfile in failures + permanent_failures:
242
243
                                                break
243
244
 
 
245
                                        sys.stdout.flush()
244
246
                                        result = subprocess.call(command)
245
247
                                        if result:
246
248
                                                # There's no sense redownloading if the script fails