~diegosarmentero/ubuntuone-windows-installer/not-validated-account

« back to all changes in this revision

Viewing changes to ubuntuone_installer/gui/qt/main/__init__.py

  • Committer: Tarmac
  • Author(s): Natalia B. Bidart
  • Date: 2011-11-12 02:00:31 UTC
  • mfrom: (85.1.5 import-qt4reactor)
  • Revision ID: tarmac-20111112020031-gvj3ise8dpm2xs7g
- Import qt4reactor properly (LP: #888722).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- coding: utf-8 -*-
2
 
 
3
 
# Authors: Manuel de la Pena <manuel@canonical.com>
4
2
#
5
3
# Copyright 2011 Canonical Ltd.
6
4
#
15
13
#
16
14
# You should have received a copy of the GNU General Public License along
17
15
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 
18
17
"""Provide the correct reactor and ui integration."""
19
18
 
20
19
import sys
21
20
 
22
 
# pylint: disable=C0103
23
 
main = None
24
 
 
 
21
from PyQt4 import QtGui
 
22
 
 
23
# Module used to include the resources into this file
 
24
# Unused import images_rc, pylint: disable=W0611
 
25
from ubuntuone_installer.gui.qt.ui import images_rc
 
26
# pylint: enable=W0611
 
27
 
 
28
 
 
29
# Invalid name "source", pylint: disable=C0103
25
30
if sys.platform == 'win32':
26
31
    from ubuntuone_installer.gui.qt.main import windows
27
 
    main = windows.main
 
32
    source = windows
28
33
else:
29
34
    from ubuntuone_installer.gui.qt.main import linux
30
 
    main = linux.main
 
35
    source = linux
 
36
# pylint: enable=C0103
 
37
 
 
38
 
 
39
def main(installing=False):
 
40
    """Start the Qt reactor and open the main window."""
 
41
    # The following cannot be imported outside this function
 
42
    # because u1trial already provides a reactor.
 
43
 
 
44
    # The main loop MUST be initialized before importing the reactor
 
45
    app = QtGui.QApplication(sys.argv)
 
46
    source.main(app)
 
47
 
 
48
    # Reimport 'qt4reactor', 'reactor', pylint: disable=W0404
 
49
    import qt4reactor
 
50
    qt4reactor.install()
 
51
 
 
52
    from twisted.internet import reactor
 
53
    from ubuntuone_installer.gui.qt.utils import check_credentials
 
54
    # pylint: enable=W0404
 
55
 
 
56
    # Module 'reactor' has no 'run'/'stop' member, pylint: disable=E1101
 
57
    reactor.callWhenRunning(check_credentials,
 
58
                            installing=installing, stop_cb=reactor.stop)
 
59
    reactor.run()
 
60
    # pylint: enable=E1101