| 1 |
#!/usr/bin/python3 |
| 2 |
# |
| 3 |
# Copyright (c) 2005-2009 Canonical Ltd |
| 4 |
# |
| 5 |
# AUTHOR: |
| 6 |
# Michael Vogt <[email protected]> |
| 7 |
# |
| 8 |
# This file is part of GDebi |
| 9 |
# |
| 10 |
# GDebi is free software; you can redistribute it and/or |
| 11 |
# modify it under the terms of the GNU General Public License as published |
| 12 |
# by the Free Software Foundation; either version 2 of the License, or (at |
| 13 |
# your option) any later version. |
| 14 |
# |
| 15 |
# GDebi is distributed in the hope that it will be useful, |
| 16 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 |
# General Public License for more details. |
| 19 |
# |
| 20 |
# You should have received a copy of the GNU General Public License |
| 21 |
# along with GDebi; if not, write to the Free Software |
| 22 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 |
# |
| 24 |
|
| 25 |
import sys |
| 26 |
|
| 27 |
from optparse import OptionParser |
| 28 |
from GDebi.GDebiGtk import GDebiGtk |
| 29 |
|
| 30 |
from gettext import gettext as _ |
| 31 |
import gettext |
| 32 |
|
| 33 |
from gi.repository import Gtk |
| 34 |
|
| 35 |
|
| 36 |
if __name__ == "__main__": |
| 37 |
data="/usr/share/gdebi" |
| 38 |
|
| 39 |
localesApp="gdebi" |
| 40 |
localesDir="/usr/share/locale" |
| 41 |
gettext.bindtextdomain(localesApp, localesDir) |
| 42 |
gettext.textdomain(localesApp) |
| 43 |
|
| 44 |
parser = OptionParser() |
| 45 |
parser.add_option("-n", "--non-interactive", |
| 46 |
action="store_true", dest="non_interactive", |
| 47 |
default=False, |
| 48 |
help=_("Run non-interactive (dangerous!)")) |
| 49 |
parser.add_option("--auto-close", "", |
| 50 |
action="store_true", default=False, |
| 51 |
help=_("Auto close when the install is finished")) |
| 52 |
parser.add_option("--datadir", "", default="", |
| 53 |
help=_("Use alternative datadir")) |
| 54 |
parser.add_option("-r", "--remove", default="False", |
| 55 |
action="store_true", dest="remove", |
| 56 |
help=_("Remove package")) |
| 57 |
(options, args) = parser.parse_args() |
| 58 |
|
| 59 |
if options.datadir: |
| 60 |
data = options.datadir |
| 61 |
|
| 62 |
try: |
| 63 |
Gtk.init_check(sys.argv) |
| 64 |
except RuntimeError as e: |
| 65 |
sys.stderr.write("Can not start %s: %s. Exiting\n" % (sys.argv[0], e)) |
| 66 |
sys.exit(1) |
| 67 |
|
| 68 |
afile = "" |
| 69 |
if len(args) >= 1: |
| 70 |
afile = args[0] |
| 71 |
|
| 72 |
try: |
| 73 |
app = GDebiGtk(datadir=data,options=options,file=afile) |
| 74 |
except SystemError: |
| 75 |
err_header = _("Software index is broken") |
| 76 |
err_body = _("This is a major failure of your software " |
| 77 |
"management system. Please check for broken packages " |
| 78 |
"with synaptic, check the file permissions and " |
| 79 |
"correctness of the file '/etc/apt/sources.list' and " |
| 80 |
"reload the software information with: " |
| 81 |
"'sudo apt-get update' and 'sudo apt-get install -f'." |
| 82 |
) |
| 83 |
dia = Gtk.MessageDialog(None, 0, Gtk.MessageType.ERROR, |
| 84 |
Gtk.ButtonsType.OK, "") |
| 85 |
dia.set_markup("<b><big>%s</big></b>" % err_header) |
| 86 |
dia.format_secondary_text(err_body) |
| 87 |
dia.run() |
| 88 |
sys.exit(1) |
| 89 |
|
| 90 |
if options.non_interactive == True: |
| 91 |
if options.remove == True: |
| 92 |
app.on_button_remove_clicked(None) |
| 93 |
else: |
| 94 |
app.on_button_install_clicked(None) |
| 95 |
if options.auto_close == True: |
| 96 |
sys.exit() |
| 97 |
app.run() |