~mvo/update-manager/not-automatic

« back to all changes in this revision

Viewing changes to UpdateManager/Common/utils.py

  • Committer: Michael Vogt
  • Date: 2009-01-26 16:26:13 UTC
  • Revision ID: michael.vogt@ubuntu.com-20090126162613-yvx1zkwdwspbwqow
improve logic that detects what mirror is in use by
sources.list inspection (LP: #107983)

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
    return lang[:2]+"."
48
48
  return ''
49
49
 
 
50
def get_dist():
 
51
  " return the codename of the current runing distro "
 
52
  from subprocess import Popen, PIPE
 
53
  p = Popen(["lsb_release","-c","-s"],stdout=PIPE)
 
54
  res = p.wait()
 
55
  if res != 0:
 
56
    sys.stderr.write("lsb_release returned exitcode: %i\n" % res)
 
57
    return "unknown distribution"
 
58
  dist = p.stdout.readline().strip()
 
59
  return dist
 
60
 
50
61
def url_downloadable(uri, debug_func=None):
51
62
  """
52
63
  helper that checks if the given uri exists and is downloadable
229
240
    else:
230
241
        # TRANSLATORS: download size of updates, e.g. "2.3 MB"
231
242
        return locale.format(_("%.1f MB"), bytes / 1024 / 1024)
 
243
 
 
244
if __name__ == "__main__":
 
245
  print mirror_from_sources_list()