Merge lp:~ralsina/ubuntuone-control-panel/unique-3-0 into lp:ubuntuone-control-panel/stable-3-0

Proposed by Roberto Alsina on 2012-04-25
Status: Merged
Approved by: dobey on 2012-04-25
Approved revision: 261
Merged at revision: 261
Proposed branch: lp:~ralsina/ubuntuone-control-panel/unique-3-0
Merge into: lp:ubuntuone-control-panel/stable-3-0
Diff against target: 284 lines (+67/-113)
8 files modified
run-tests (+1/-1)
ubuntuone/controlpanel/gui/qt/main/__init__.py (+1/-0)
ubuntuone/controlpanel/gui/qt/main/tests/test_main.py (+13/-0)
ubuntuone/controlpanel/gui/qt/uniqueapp/__init__.py (+28/-8)
ubuntuone/controlpanel/gui/qt/uniqueapp/linux.py (+0/-29)
ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_unique_app.py (+2/-23)
ubuntuone/controlpanel/gui/qt/uniqueapp/windows.py (+0/-52)
ubuntuone/controlpanel/gui/tests/__init__.py (+22/-0)
To merge this branch: bzr merge lp:~ralsina/ubuntuone-control-panel/unique-3-0
Reviewer Review Type Date Requested Status
dobey (community) 2012-04-25 Approve on 2012-04-25
Review via email: mp+103489@code.launchpad.net

Commit Message

 - Implemented UniqueApplication for Linux (Fixes LP:987909).

Description of the Change

 - Implemented UniqueApplication for Linux (Fixes LP:987909).

To post a comment you must log in.
dobey (dobey) :
review: Approve
Ubuntu One Auto Pilot (otto-pilot) wrote :

The attempt to merge lp:~ralsina/ubuntuone-control-panel/unique-3-0 into lp:ubuntuone-control-panel/stable-3-0 failed. Below is the output from the failed tests.

*** Running test suite for ubuntuone/controlpanel ***

Traceback (most recent call last):
  File "/usr/bin/u1trial", line 337, in <module>
    main()
  File "/usr/bin/u1trial", line 317, in main
    suite = trial_runner.get_suite(config)
  File "/usr/bin/u1trial", line 196, in get_suite
    config['ignore-paths']))
  File "/usr/bin/u1trial", line 180, in _collect_tests
    module_suite = self._load_unittest(filepath)
  File "/usr/bin/u1trial", line 120, in _load_unittest
    module = __import__(modpath, None, None, [""])
  File "/mnt/tarmac/cache/ubuntuone-control-panel/stable-3-0/ubuntuone/controlpanel/tests/test_web_client.py", line 24, in <module>
    from ubuntu_sso.utils.webclient.tests import BaseMockWebServer
ImportError: cannot import name BaseMockWebServer

Ubuntu One Auto Pilot (otto-pilot) wrote :

The attempt to merge lp:~ralsina/ubuntuone-control-panel/unique-3-0 into lp:ubuntuone-control-panel/stable-3-0 failed. Below is the output from the failed tests.

*** Running test suite for ubuntuone/controlpanel ***

Traceback (most recent call last):
  File "/usr/bin/u1trial", line 337, in <module>
    main()
  File "/usr/bin/u1trial", line 317, in main
    suite = trial_runner.get_suite(config)
  File "/usr/bin/u1trial", line 196, in get_suite
    config['ignore-paths']))
  File "/usr/bin/u1trial", line 180, in _collect_tests
    module_suite = self._load_unittest(filepath)
  File "/usr/bin/u1trial", line 120, in _load_unittest
    module = __import__(modpath, None, None, [""])
  File "/mnt/tarmac/cache/ubuntuone-control-panel/stable-3-0/ubuntuone/controlpanel/tests/__init__.py", line 28, in <module>
    from ubuntuone.controlpanel.backend import (
  File "/mnt/tarmac/cache/ubuntuone-control-panel/stable-3-0/ubuntuone/controlpanel/backend.py", line 26, in <module>
    from ubuntuone.platform.credentials import CredentialsManagementTool
ImportError: No module named platform.credentials

Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (46.1 KiB)

The attempt to merge lp:~ralsina/ubuntuone-control-panel/unique-3-0 into lp:ubuntuone-control-panel/stable-3-0 failed. Below is the output from the failed tests.

*** Running test suite for ubuntuone/controlpanel ***
ubuntuone.controlpanel.tests.test_replication_client
  ReplicationsTestCase
    test_exclude ... [OK]
    test_exclude_name_in_exclusions ... [OK]
    test_exclude_name_not_in_replications ... [OK]
    test_get_exclusions ... [OK]
    test_get_replications ... [OK]
    test_no_pairing_record ... [OK]
    test_replicate ... [OK]
    test_replicate_name_not_in_exclusions ... [OK]
    test_replicate_name_not_in_replications ... [OK]
ubuntuone.controlpanel.tests
  TestCase
    runTest ... [OK]
ubuntuone.controlpanel.tests.test_sd_client
  AutoconnectTestCase
    test_disable ... [OK]
    test_disable_throws_an_error ... [OK]
    test_enable ... [OK]
    test_enable_throws_an_error ... [OK]
    test_get_value ... [OK]
    test_get_value_throws_an_error ... [OK]
  BaseTestCase
    runTest ... [OK]
  BasicTestCase
    test_get_current_status ... [OK]
    test_get_current_status_error ... [OK]
    test_get_root_dir ... [OK]
    test_get_shares_dir ... [OK]
    test_get_shares_dir_link ... [OK]
  FileSyncTestCase
    test_connect_file_sync ... [OK]
    test_disable_file_sync ... [OK]
    test_disconnect_file_sync ... [OK]
    test_enable_file_sync ... [OK]
    test_file_sync_enabled ... [OK]
    test_set_status_changed_handler ... [OK]
    test_start_file_sync ... [OK]
    test_stop_file_sync ... [OK]
  FoldersTestCase
    test_create_folder ... [OK]
    test_create_folder_error ... [OK]
    test_get_folders ... [OK]
    test_get_folders_error ... [OK]
    test_subs...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'run-tests'
--- run-tests 2012-02-29 19:49:44 +0000
+++ run-tests 2012-04-25 14:34:51 +0000
@@ -16,7 +16,7 @@
16# You should have received a copy of the GNU General Public License along16# You should have received a copy of the GNU General Public License along
17# with this program. If not, see <http://www.gnu.org/licenses/>.17# with this program. If not, see <http://www.gnu.org/licenses/>.
1818
19QT_TESTS_PATH="ubuntuone/controlpanel/gui/qt/tests, ubuntuone/controlpanel/gui/qt/main/tests"19QT_TESTS_PATH="ubuntuone/controlpanel/gui/qt/tests, ubuntuone/controlpanel/gui/qt/main/tests, ubuntuone/controlpanel/gui/qt/uniqueapp/tests"
20DBUS_TESTS_PATH=ubuntuone/controlpanel/dbustests20DBUS_TESTS_PATH=ubuntuone/controlpanel/dbustests
21WINDOWS_TESTS=test_windows.py21WINDOWS_TESTS=test_windows.py
2222
2323
=== modified file 'ubuntuone/controlpanel/gui/qt/main/__init__.py'
--- ubuntuone/controlpanel/gui/qt/main/__init__.py 2012-03-29 17:20:14 +0000
+++ ubuntuone/controlpanel/gui/qt/main/__init__.py 2012-04-25 14:34:51 +0000
@@ -100,6 +100,7 @@
100 installer=installer)100 installer=installer)
101 if window:101 if window:
102 window.switch_to(switch_to)102 window.switch_to(switch_to)
103 app.new_instance.connect(window.raise_)
103 # pylint: enable=W0612104 # pylint: enable=W0612
104 if icon:105 if icon:
105 app.new_instance.connect(icon.restore_window)106 app.new_instance.connect(icon.restore_window)
106107
=== modified file 'ubuntuone/controlpanel/gui/qt/main/tests/test_main.py'
--- ubuntuone/controlpanel/gui/qt/main/tests/test_main.py 2012-03-29 17:08:33 +0000
+++ ubuntuone/controlpanel/gui/qt/main/tests/test_main.py 2012-04-25 14:34:51 +0000
@@ -23,6 +23,7 @@
2323
24from ubuntuone.controlpanel.gui.qt import main24from ubuntuone.controlpanel.gui.qt import main
25from ubuntuone.controlpanel.tests import TestCase25from ubuntuone.controlpanel.tests import TestCase
26from ubuntuone.controlpanel.gui.tests import FakeSignal
2627
2728
28class FakeTranslator(object):29class FakeTranslator(object):
@@ -44,6 +45,7 @@
44 self.args = None45 self.args = None
45 self.style = None46 self.style = None
46 self.translator = None47 self.translator = None
48 self.new_instance = FakeSignal()
4749
48 def __call__(self, argv, *args, **kwargs):50 def __call__(self, argv, *args, **kwargs):
49 """Fake arg filtering function."""51 """Fake arg filtering function."""
@@ -77,6 +79,7 @@
7779
78 tabname = None80 tabname = None
79 urgent = None81 urgent = None
82 raised = None
8083
81 def switch_to(self, tabname):84 def switch_to(self, tabname):
82 """Fake switch_to."""85 """Fake switch_to."""
@@ -86,6 +89,10 @@
86 """Fake set_urgent."""89 """Fake set_urgent."""
87 self.urgent = value90 self.urgent = value
8891
92 def raise_(self):
93 """Fake raise."""
94 self.raised = True
95
8996
90class FakeStart(object):97class FakeStart(object):
9198
@@ -183,3 +190,9 @@
183 self.assertEqual(self.translator.args, (("qt_" + locale,190 self.assertEqual(self.translator.args, (("qt_" + locale,
184 QtCore.QLibraryInfo.location(191 QtCore.QLibraryInfo.location(
185 QtCore.QLibraryInfo.TranslationsPath)), {}))192 QtCore.QLibraryInfo.TranslationsPath)), {}))
193
194 def test_new_instance(self):
195 """Ensure the new_instance signal is connected."""
196 main.main([sys.argv[0]])
197 self.assertEqual(self.app.new_instance.target,
198 self.start.window.raise_)
186199
=== modified file 'ubuntuone/controlpanel/gui/qt/uniqueapp/__init__.py'
--- ubuntuone/controlpanel/gui/qt/uniqueapp/__init__.py 2012-01-23 20:15:09 +0000
+++ ubuntuone/controlpanel/gui/qt/uniqueapp/__init__.py 2012-04-25 14:34:51 +0000
@@ -16,13 +16,33 @@
1616
17"""A QApplication that starts a single instance."""17"""A QApplication that starts a single instance."""
1818
19#pylint: disable=W0404
20import sys19import sys
2120
22if sys.platform == "win32":21from PyQt4 import QtNetwork, QtGui, QtCore
23 from ubuntuone.controlpanel.gui.qt.uniqueapp import windows as platform22
24else:23
25 from ubuntuone.controlpanel.gui.qt.uniqueapp import linux as platform24class UniqueApplication(QtGui.QApplication):
2625
27#pylint: disable=C010326 """A dummy UniqueApplication class."""
28UniqueApplication = platform.UniqueApplication27
28 new_instance = QtCore.pyqtSignal()
29
30 def __init__(self, argv, key):
31 super(UniqueApplication, self).__init__(argv)
32 self.key = key
33 self.server = QtNetwork.QLocalServer(self)
34 self.server.newConnection.connect(self.new_instance.emit)
35 self.aboutToQuit.connect(self.cleanup)
36 # Try to connect to existing app
37 socket = QtNetwork.QLocalSocket()
38 socket.connectToServer(key, QtCore.QIODevice.WriteOnly)
39 if socket.waitForConnected(500):
40 # Connected, exit
41 sys.exit()
42
43 # Not connected, start server
44 self.ready = self.server.listen(key)
45
46 def cleanup(self):
47 """Remove the socket when we die."""
48 self.server.removeServer(self.key)
2949
=== removed file 'ubuntuone/controlpanel/gui/qt/uniqueapp/linux.py'
--- ubuntuone/controlpanel/gui/qt/uniqueapp/linux.py 2012-02-24 02:49:47 +0000
+++ ubuntuone/controlpanel/gui/qt/uniqueapp/linux.py 1970-01-01 00:00:00 +0000
@@ -1,29 +0,0 @@
1# -*- coding: utf-8 -*-
2#
3# Copyright 2011 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.
16
17"""A QApplication that starts a single instance."""
18
19from PyQt4 import QtGui, QtCore
20
21
22class UniqueApplication(QtGui.QApplication):
23
24 """A dummy UniqueApplication class."""
25
26 new_instance = QtCore.pyqtSignal()
27
28 def __init__(self, argv, key):
29 super(UniqueApplication, self).__init__(argv)
300
=== renamed file 'ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_windows.py' => 'ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_unique_app.py'
--- ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_windows.py 2012-01-02 14:29:16 +0000
+++ ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_unique_app.py 2012-04-25 14:34:51 +0000
@@ -19,8 +19,9 @@
19from PyQt4 import QtCore19from PyQt4 import QtCore
20from twisted.internet.defer import inlineCallbacks20from twisted.internet.defer import inlineCallbacks
2121
22from ubuntuone.controlpanel.gui.qt.uniqueapp import windows as uniqueapp22from ubuntuone.controlpanel.gui.qt import uniqueapp
23from ubuntuone.controlpanel.tests import TestCase23from ubuntuone.controlpanel.tests import TestCase
24from ubuntuone.controlpanel.gui.tests import FakeSignal
2425
2526
26#pylint: disable=C010327#pylint: disable=C0103
@@ -42,28 +43,6 @@
42 return self.connect_succeeds43 return self.connect_succeeds
4344
4445
45class FakeSignal(object):
46
47 """A fake PyQt signal."""
48
49 def __init__(self, *args, **kwargs):
50 """Initialize."""
51 self.target = None
52
53 def connect(self, target):
54 """Fake connect."""
55 self.target = target
56
57 def disconnect(self, *args):
58 """Fake disconnect."""
59 self.target = None
60
61 def emit(self, *args):
62 """Fake emit."""
63 if self.target:
64 self.target(*args)
65
66
67class FakeLocalServer(object):46class FakeLocalServer(object):
6847
69 """A fake QLocalServer."""48 """A fake QLocalServer."""
7049
=== removed file 'ubuntuone/controlpanel/gui/qt/uniqueapp/windows.py'
--- ubuntuone/controlpanel/gui/qt/uniqueapp/windows.py 2012-01-04 11:09:35 +0000
+++ ubuntuone/controlpanel/gui/qt/uniqueapp/windows.py 1970-01-01 00:00:00 +0000
@@ -1,52 +0,0 @@
1# -*- coding: utf-8 -*-
2#
3# Copyright 2011 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.
16
17"""A QApplication that starts a single instance."""
18
19import sys
20
21from PyQt4 import QtNetwork, QtGui, QtCore
22
23
24class UniqueApplication(QtGui.QApplication):
25
26 """A QApplication that can only be started once.
27
28 Also, the new instance notifies the old one to show
29 its window.
30 """
31
32 new_instance = QtCore.pyqtSignal()
33
34 def __init__(self, argv, key):
35 super(UniqueApplication, self).__init__(argv)
36 self.key = key
37 self.server = QtNetwork.QLocalServer(self)
38 self.server.newConnection.connect(self.new_instance.emit)
39 self.aboutToQuit.connect(self.cleanup)
40 # Try to connect to existing app
41 socket = QtNetwork.QLocalSocket()
42 socket.connectToServer(key, QtCore.QIODevice.WriteOnly)
43 if socket.waitForConnected(500):
44 # Connected, exit
45 sys.exit()
46
47 # Not connected, start server
48 self.ready = self.server.listen(key)
49
50 def cleanup(self):
51 """Remove the socket when we die."""
52 self.server.removeServer(self.key)
530
=== modified file 'ubuntuone/controlpanel/gui/tests/__init__.py'
--- ubuntuone/controlpanel/gui/tests/__init__.py 2012-03-08 20:46:13 +0000
+++ ubuntuone/controlpanel/gui/tests/__init__.py 2012-04-25 14:34:51 +0000
@@ -175,3 +175,25 @@
175 return result175 return result
176176
177 return faked_call_in_faked_object177 return faked_call_in_faked_object
178
179
180class FakeSignal(object):
181
182 """A fake PyQt signal."""
183
184 def __init__(self, *args, **kwargs):
185 """Initialize."""
186 self.target = None
187
188 def connect(self, target):
189 """Fake connect."""
190 self.target = target
191
192 def disconnect(self, *args):
193 """Fake disconnect."""
194 self.target = None
195
196 def emit(self, *args):
197 """Fake emit."""
198 if self.target:
199 self.target(*args)

Subscribers

People subscribed via source and target branches