~mvo/update-manager/release-notes-markup

« back to all changes in this revision

Viewing changes to UpdateManager/UpdateManager.py

  • Committer: Michael Vogt
  • Date: 2008-07-30 09:56:53 UTC
  • Revision ID: michael.vogt@ubuntu.com-20080730095653-ltsxxs251hrijhgo
* do-release-upgrade:
  - unify proxy configuration between gtk and cli UI

Show diffs side-by-side

added added

removed removed

Lines of Context:
411
411
        self.button_help.set_sensitive(False)
412
412
 
413
413
    self.gconfclient = gconf.client_get_default()
414
 
    self.init_proxy()
 
414
    init_proxy(self.gconfclient)
415
415
 
416
416
    # restore state
417
417
    self.restore_state()
418
418
    self.window_main.show()
419
419
 
420
 
  def init_proxy(self):
421
 
      """ init proxy settings
422
 
 
423
 
      * first check for http_proxy environment (always wins),
424
 
      * then check the apt.conf http proxy, 
425
 
      * then look into synaptics conffile
426
 
      * then into gconf 
427
 
      """
428
 
      SYNAPTIC_CONF_FILE = "%s/.synaptic/synaptic.conf" % pwd.getpwuid(0)[5]
429
 
      proxy = None
430
 
      # environment wins
431
 
      if os.getenv("http_proxy"):
432
 
          return
433
 
      # generic apt config wins too
434
 
      if apt_pkg.Config.Find("Acquire::http::Proxy") != '':
435
 
          proxy = apt_pkg.Config.Find("Acquire::http::Proxy")
436
 
      elif os.path.exists(SYNAPTIC_CONF_FILE):
437
 
          cnf = apt_pkg.newConfiguration()
438
 
          apt_pkg.ReadConfigFile(cnf, SYNAPTIC_CONF_FILE)
439
 
          use_proxy = cnf.FindB("Synaptic::useProxy", False)
440
 
          if use_proxy:
441
 
              proxy_host = cnf.Find("Synaptic::httpProxy")
442
 
              proxy_port = str(cnf.FindI("Synaptic::httpProxyPort"))
443
 
              if proxy_host and proxy_port:
444
 
                  # FIXME: set the proxy for libapt here as well (e.g. for the
445
 
                  #        DistUpgradeFetcher
446
 
                  proxy = "http://%s:%s/" % (proxy_host, proxy_port)
447
 
      elif self.gconfclient.get_bool("/system/http_proxy/use_http_proxy"):
448
 
          host = self.gconfclient.get_string("/system/http_proxy/host")
449
 
          port = self.gconfclient.get_int("/system/http_proxy/port")
450
 
          use_auth = self.gconfclient.get_bool("/system/http_proxy/use_authentication")
451
 
          if host and port:
452
 
              if use_auth:
453
 
                  auth_user = self.gconfclient.get_string("/system/http_proxy/authentication_user")
454
 
                  auth_pw = self.gconfclient.get_string("/system/http_proxy/authentication_password")
455
 
                  proxy = "http://%s:%s@%s:%s/" % (auth_user,auth_pw,host, port)
456
 
              else:
457
 
                  proxy = "http://%s:%s/" % (host, port)
458
 
      if proxy:
459
 
          proxy_support = urllib2.ProxyHandler({"http":proxy})
460
 
          opener = urllib2.build_opener(proxy_support)
461
 
          urllib2.install_opener(opener)
462
 
          os.putenv("http_proxy",proxy)
463
 
 
464
420
  def install_column_view_func(self, cell_layout, renderer, model, iter):
465
421
    pkg = model.get_value(iter, LIST_PKG)
466
422
    # hide it if we are only a header line