~mvo/ubuntu-sso-client/strawman-lp711413

« back to all changes in this revision

Viewing changes to ubuntu_sso/qt/proxy_dialog.py

  • Committer: Tarmac
  • Author(s): Diego Sarmentero, Roberto Alsina, Natalia B. Bidart, manuel.delapena at canonical, Manuel de la Pena
  • Date: 2012-03-27 19:33:27 UTC
  • mfrom: (831.1.2 stable-3-0-update-2.99.91.1)
  • Revision ID: tarmac-20120327193327-rgwi1z1cbfxxrx9d
Tags: release-2_99_91_1
[ Diego Sarmentero <diego.sarmentero@canonical.com> ]
  - Converting to unicode some data returned by webclient in
    QByteArray format (LP: #961315).
  - Adding ubuntu_sso.qt.main module to the setup script (LP: #965377).
  - Fixed the backend getting stuck installing the qtreactor before
    the qt process is executed and running the application in the
    twisted process (This fix affects only Windows OS) (LP: #961511).

[ Roberto Alsina <roberto.alsina@canonical.com> ]
   - Forced white background (LP: #961346).

[ Manuel de la Pena <manuel.delapena@canonical.com> ]
  - Fixed dialog on window by using show so that the QEventLoop does
    not block the execution of the main loop of the reactor which did
    not allow the deferreds to be fired (LP: #960481).

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
        except Exception, e:
107
107
            logger.exception('Could not set credentials:')
108
108
            self.done(EXCEPTION_RAISED)
 
109
        logger.debug('Stored creds')
109
110
        # pylint: disable=W0703, W0612
110
111
        self.done(USER_SUCCESS)
111
112
 
140
141
    return parser.parse_args()
141
142
 
142
143
 
 
144
def exit_code(return_code):
 
145
    """Use the window result code and the sys.exit."""
 
146
    logger.debug('exit %s', return_code)
 
147
    QApplication.instance().exit(return_code)
 
148
    if sys.platform == 'win32':
 
149
        logger.debug('Stop qt reactor')
 
150
        from twisted.internet import reactor
 
151
        reactor.stop()
 
152
 
 
153
 
143
154
def main():
144
155
    """Main method used to show the creds dialog."""
145
156
    # Keep ref to avoid core dump, pylint: disable=W0612
 
157
 
 
158
    if sys.platform == 'win32':
 
159
        import qt4reactor
 
160
        qt4reactor.install()
 
161
        logger.debug('Qt reactor installed.')
 
162
 
146
163
    app = QApplication(sys.argv)
147
164
    # pylint: enable=W0612
148
165
    args = parse_args()
149
166
    win = ProxyCredsDialog(domain=args.domain,
150
167
                           retry=args.retry)
151
 
    return_code = win.exec_()
152
 
    sys.exit(return_code)
 
168
 
 
169
    if sys.platform == 'win32':
 
170
        win.show()
 
171
        win.finished.connect(exit_code)
 
172
 
 
173
        logger.debug('Starting reactor')
 
174
        # pylint: disable=E1101
 
175
        from twisted.internet import reactor
 
176
        logger.debug('QApp is %s', reactor.qApp)
 
177
        reactor.run()
 
178
        # pylint: enable=E1101
 
179
    else:
 
180
        return_code = win.exec_()
 
181
        sys.exit(return_code)