~ubuntu-core-dev/ubuntu/xenial/ubuntu-release-upgrader/xenial

« back to all changes in this revision

Viewing changes to update-manager

  • Committer: Michael Terry
  • Date: 2012-06-06 21:23:35 UTC
  • mto: This revision was merged to the branch mainline in revision 2509.
  • Revision ID: michael.terry@canonical.com-20120606212335-dt5xyu2v3ct5hcey
first pass at converting update-manager source into ubuntu-release-upgrader

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
# update-manager.in - easy updating application
3
 
#  
4
 
#  Copyright (c) 2004-2008 Canonical
5
 
#                2004-2008 Michael Vogt
6
 
#                2004 Michiel Sikkes
7
 
#  
8
 
#  Author: Michiel Sikkes <michiel@eyesopened.nl>
9
 
#          Michael Vogt <mvo@debian.org>
10
 
11
 
#  This program is free software; you can redistribute it and/or 
12
 
#  modify it under the terms of the GNU General Public License as 
13
 
#  published by the Free Software Foundation; either version 2 of the
14
 
#  License, or (at your option) any later version.
15
 
16
 
#  This program is distributed in the hope that it will be useful,
17
 
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 
#  GNU General Public License for more details.
20
 
21
 
#  You should have received a copy of the GNU General Public License
22
 
#  along with this program; if not, write to the Free Software
23
 
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24
 
#  USA
25
 
 
26
 
from __future__ import print_function
27
 
 
28
 
from gi.repository import Gtk
29
 
import gi
30
 
gi.require_version("Gtk", "3.0")
31
 
 
32
 
import os
33
 
import sys
34
 
 
35
 
from UpdateManager.UpdateManager import UpdateManager
36
 
from DistUpgrade.DistUpgradeVersion import VERSION
37
 
import locale
38
 
import gettext
39
 
from gettext import gettext as _
40
 
 
41
 
from optparse import OptionParser
42
 
 
43
 
if __name__ == "__main__":
44
 
 
45
 
  Gtk.init_check(sys.argv)
46
 
  
47
 
  gettext.bindtextdomain("update-manager", "/usr/share/locale")
48
 
  gettext.textdomain("update-manager")
49
 
 
50
 
  try:
51
 
    locale.setlocale(locale.LC_ALL, "")
52
 
  except:
53
 
    pass
54
 
 
55
 
  # Begin parsing of options
56
 
  parser = OptionParser()
57
 
  #FIXME: Workaround a bug in optparser which doesn't handle unicode/str
58
 
  #       correctly, see http://bugs.python.org/issue4391
59
 
  #       Should be resolved by Python3
60
 
  enc = locale.getpreferredencoding()
61
 
  parser.add_option ("-V", "--version", action="store_true",
62
 
                     dest="show_version", default=False,
63
 
                     help=_("Show version and exit").decode(enc))
64
 
  parser.add_option ("--data-dir", "", 
65
 
                     default="/usr/share/update-manager/",
66
 
                     help=_("Directory that contains the data files").decode(enc))
67
 
  parser.add_option ("-c", "--check-dist-upgrades", action="store_true",
68
 
                     dest="check_dist_upgrades", default=False,
69
 
                     help=_("Check if a new Ubuntu release is available").decode(enc))
70
 
  parser.add_option ("-d", "--devel-release", action="store_true",
71
 
                     dest="devel_release", default=False,
72
 
                     help=_("Check if upgrading to the latest devel release "
73
 
                          "is possible").decode(enc))
74
 
  parser.add_option ("-p","--proposed", action="store_true",
75
 
                     dest="use_proposed", default=False,
76
 
                     help=_("Upgrade using the latest proposed version of the release upgrader").decode(enc))
77
 
  parser.add_option ("--no-focus-on-map", action="store_true",
78
 
                     dest="no_focus_on_map", default=False,
79
 
                     # TRANSLATORS: this describes the "focus-on-map" gtk
80
 
                     # property that controls if a new window takes the
81
 
                     # input focus control when it is displayed for the
82
 
                     # first time (see also the gtk devhelp page)
83
 
                     help=_("Do not focus on map when starting").decode(enc))
84
 
  parser.add_option ("--dist-upgrade", action="store_true",
85
 
                     dest="dist_upgrade", default=False,
86
 
                     help=_("Try to run a dist-upgrade").decode(enc))
87
 
  parser.add_option ("--no-update", action="store_true",
88
 
                     dest="no_update", default=False,
89
 
                     help=_("Do not check for updates when starting").decode(enc))
90
 
  parser.add_option ("-s","--sandbox", action="store_true", default=False,
91
 
                     # TRANSLATORS: aufs is the name of the filesystem
92
 
                     # that is used to create the overlay
93
 
                     help=_("Test upgrade with a sandbox aufs overlay").decode(enc))
94
 
 
95
 
  (options, args) = parser.parse_args()
96
 
 
97
 
  #data_dir="/usr/share/update-manager/"
98
 
  #data_dir="/tmp/xxx/share/update-manager/"
99
 
  data_dir = os.path.normpath(options.data_dir)+"/"
100
 
 
101
 
  if options.show_version:
102
 
    print("%s: version %s" % (os.path.basename(sys.argv[0]), VERSION))
103
 
    sys.exit(0)
104
 
 
105
 
  if options.dist_upgrade == True:
106
 
    #import logging
107
 
    #logging.basicConfig(level=logging.DEBUG)
108
 
    from DistUpgrade.DistUpgradeViewGtk3 import DistUpgradeViewGtk3
109
 
    from DistUpgrade.DistUpgradeController import DistUpgradeController
110
 
    # FIXME: Having a "partial upgrade" view here would make it possible
111
 
    #        to get rid of the ugly hideStep() stuff
112
 
    view = DistUpgradeViewGtk3(data_dir)
113
 
    view.label_title.set_markup("<b><big>%s</big></b>" % _("Running partial upgrade"))
114
 
    controller = DistUpgradeController(view, datadir=data_dir)
115
 
    controller.doPartialUpgrade()
116
 
  else:
117
 
    app = UpdateManager(data_dir, options)
118
 
    app.main(options)