~alecu/ubuntuone-client/fix-broken-tunnel

« back to all changes in this revision

Viewing changes to ubuntuone/proxy/tunnel_server.py

  • Committer: Alejandro J. Cura
  • Date: 2012-03-30 04:49:21 UTC
  • Revision ID: alecu@canonical.com-20120330044921-lpw7qoeg5m4y461k
Use system configuration on windows; also don't install the qt+dbus integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
353
353
            logger.info("Proxy is disabled.")
354
354
        return enabled
355
355
    else:
 
356
        QNetworkProxyFactory.setUseSystemConfiguration(True)
356
357
        query = QNetworkProxyQuery(host, port)
357
358
        proxies = QNetworkProxyFactory.systemProxyForQuery(query)
358
359
        return len(proxies) and proxies[0].type() != QNetworkProxy.DefaultProxy
359
360
 
360
361
 
 
362
def install_qt_dbus():
 
363
    """Import and install the qt+dbus integration."""
 
364
    from dbus.mainloop.qt import DBusQtMainLoop
 
365
    DBusQtMainLoop(set_as_default=True)
 
366
 
 
367
 
361
368
def main(argv):
362
369
    """The main function for the tunnel server."""
363
370
    if not check_proxy_enabled(*argv[1:]):
364
371
        sys.stdout.write("Proxy not enabled.")
365
372
        sys.stdout.flush()
366
373
    else:
367
 
        from dbus.mainloop.qt import DBusQtMainLoop
368
 
        DBusQtMainLoop(set_as_default=True)
 
374
        if sys.platform.startswith("linux"):
 
375
            install_qt_dbus()
 
376
 
369
377
        app = QCoreApplication(argv)
370
378
        cookie = str(uuid.uuid4())
371
379
        tunnel_server = TunnelServer(cookie)