2
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
4
# Copyright (c) 2004-2012 Canonical
6
# 2005 Martin Willemoes Hansen
7
# 2010 Mohamed Amine IL Idrissi
9
# Author: Michiel Sikkes <michiel@eyesopened.nl>
10
# Michael Vogt <mvo@debian.org>
11
# Martin Willemoes Hansen <mwh@sysrq.dk>
12
# Mohamed Amine IL Idrissi <ilidrissiamine@gmail.com>
13
# Alex Launi <alex.launi@canonical.com>
14
# Michael Terry <michael.terry@canonical.com>
16
# This program is free software; you can redistribute it and/or
17
# modify it under the terms of the GNU General Public License as
18
# published by the Free Software Foundation; either version 2 of the
19
# License, or (at your option) any later version.
21
# This program is distributed in the hope that it will be useful,
22
# but WITHOUT ANY WARRANTY; without even the implied warranty of
23
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
# GNU General Public License for more details.
26
# You should have received a copy of the GNU General Public License
27
# along with this program; if not, write to the Free Software
28
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
31
from __future__ import absolute_import, print_function
34
warnings.filterwarnings("ignore", "Accessed deprecated property",
40
from .backend import get_backend
42
from .Core.utils import inhibit_sleep, allow_sleep
45
class UpdateProgress(object):
47
def __init__(self, app):
48
self.window_main = app
49
self.datadir = app.datadir
50
self.options = app.options
52
# Used for inhibiting power management
53
self.sleep_cookie = None
56
# get the install backend
57
self.install_backend = get_backend(self.datadir, self.window_main)
58
self.install_backend.connect("action-done", self._on_backend_done)
60
def invoke_manager(self):
61
# don't display apt-listchanges
62
os.environ["APT_LISTCHANGES_FRONTEND"] = "none"
64
# Do not suspend during the update process
65
(self.sleep_dev, self.sleep_cookie) = inhibit_sleep()
67
self.install_backend.update()
69
def _on_backend_done(self, backend, action, authorized, success):
70
# Allow suspend after synaptic is finished
72
allow_sleep(self.sleep_dev, self.sleep_cookie)
73
self.sleep_cookie = self.sleep_dev = None
75
# Either launch main dialog and continue or quit altogether
77
self.window_main.start_available()