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

Proposed by Roberto Alsina
Status: Merged
Approved by: dobey
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) Approve
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.
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
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

Revision history for this message
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

Revision history for this message
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
1=== modified file 'run-tests'
2--- run-tests 2012-02-29 19:49:44 +0000
3+++ run-tests 2012-04-25 14:34:51 +0000
4@@ -16,7 +16,7 @@
5 # You should have received a copy of the GNU General Public License along
6 # with this program. If not, see <http://www.gnu.org/licenses/>.
7
8-QT_TESTS_PATH="ubuntuone/controlpanel/gui/qt/tests, ubuntuone/controlpanel/gui/qt/main/tests"
9+QT_TESTS_PATH="ubuntuone/controlpanel/gui/qt/tests, ubuntuone/controlpanel/gui/qt/main/tests, ubuntuone/controlpanel/gui/qt/uniqueapp/tests"
10 DBUS_TESTS_PATH=ubuntuone/controlpanel/dbustests
11 WINDOWS_TESTS=test_windows.py
12
13
14=== modified file 'ubuntuone/controlpanel/gui/qt/main/__init__.py'
15--- ubuntuone/controlpanel/gui/qt/main/__init__.py 2012-03-29 17:20:14 +0000
16+++ ubuntuone/controlpanel/gui/qt/main/__init__.py 2012-04-25 14:34:51 +0000
17@@ -100,6 +100,7 @@
18 installer=installer)
19 if window:
20 window.switch_to(switch_to)
21+ app.new_instance.connect(window.raise_)
22 # pylint: enable=W0612
23 if icon:
24 app.new_instance.connect(icon.restore_window)
25
26=== modified file 'ubuntuone/controlpanel/gui/qt/main/tests/test_main.py'
27--- ubuntuone/controlpanel/gui/qt/main/tests/test_main.py 2012-03-29 17:08:33 +0000
28+++ ubuntuone/controlpanel/gui/qt/main/tests/test_main.py 2012-04-25 14:34:51 +0000
29@@ -23,6 +23,7 @@
30
31 from ubuntuone.controlpanel.gui.qt import main
32 from ubuntuone.controlpanel.tests import TestCase
33+from ubuntuone.controlpanel.gui.tests import FakeSignal
34
35
36 class FakeTranslator(object):
37@@ -44,6 +45,7 @@
38 self.args = None
39 self.style = None
40 self.translator = None
41+ self.new_instance = FakeSignal()
42
43 def __call__(self, argv, *args, **kwargs):
44 """Fake arg filtering function."""
45@@ -77,6 +79,7 @@
46
47 tabname = None
48 urgent = None
49+ raised = None
50
51 def switch_to(self, tabname):
52 """Fake switch_to."""
53@@ -86,6 +89,10 @@
54 """Fake set_urgent."""
55 self.urgent = value
56
57+ def raise_(self):
58+ """Fake raise."""
59+ self.raised = True
60+
61
62 class FakeStart(object):
63
64@@ -183,3 +190,9 @@
65 self.assertEqual(self.translator.args, (("qt_" + locale,
66 QtCore.QLibraryInfo.location(
67 QtCore.QLibraryInfo.TranslationsPath)), {}))
68+
69+ def test_new_instance(self):
70+ """Ensure the new_instance signal is connected."""
71+ main.main([sys.argv[0]])
72+ self.assertEqual(self.app.new_instance.target,
73+ self.start.window.raise_)
74
75=== modified file 'ubuntuone/controlpanel/gui/qt/uniqueapp/__init__.py'
76--- ubuntuone/controlpanel/gui/qt/uniqueapp/__init__.py 2012-01-23 20:15:09 +0000
77+++ ubuntuone/controlpanel/gui/qt/uniqueapp/__init__.py 2012-04-25 14:34:51 +0000
78@@ -16,13 +16,33 @@
79
80 """A QApplication that starts a single instance."""
81
82-#pylint: disable=W0404
83 import sys
84
85-if sys.platform == "win32":
86- from ubuntuone.controlpanel.gui.qt.uniqueapp import windows as platform
87-else:
88- from ubuntuone.controlpanel.gui.qt.uniqueapp import linux as platform
89-
90-#pylint: disable=C0103
91-UniqueApplication = platform.UniqueApplication
92+from PyQt4 import QtNetwork, QtGui, QtCore
93+
94+
95+class UniqueApplication(QtGui.QApplication):
96+
97+ """A dummy UniqueApplication class."""
98+
99+ new_instance = QtCore.pyqtSignal()
100+
101+ def __init__(self, argv, key):
102+ super(UniqueApplication, self).__init__(argv)
103+ self.key = key
104+ self.server = QtNetwork.QLocalServer(self)
105+ self.server.newConnection.connect(self.new_instance.emit)
106+ self.aboutToQuit.connect(self.cleanup)
107+ # Try to connect to existing app
108+ socket = QtNetwork.QLocalSocket()
109+ socket.connectToServer(key, QtCore.QIODevice.WriteOnly)
110+ if socket.waitForConnected(500):
111+ # Connected, exit
112+ sys.exit()
113+
114+ # Not connected, start server
115+ self.ready = self.server.listen(key)
116+
117+ def cleanup(self):
118+ """Remove the socket when we die."""
119+ self.server.removeServer(self.key)
120
121=== removed file 'ubuntuone/controlpanel/gui/qt/uniqueapp/linux.py'
122--- ubuntuone/controlpanel/gui/qt/uniqueapp/linux.py 2012-02-24 02:49:47 +0000
123+++ ubuntuone/controlpanel/gui/qt/uniqueapp/linux.py 1970-01-01 00:00:00 +0000
124@@ -1,29 +0,0 @@
125-# -*- coding: utf-8 -*-
126-#
127-# Copyright 2011 Canonical Ltd.
128-#
129-# This program is free software: you can redistribute it and/or modify it
130-# under the terms of the GNU General Public License version 3, as published
131-# by the Free Software Foundation.
132-#
133-# This program is distributed in the hope that it will be useful, but
134-# WITHOUT ANY WARRANTY; without even the implied warranties of
135-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
136-# PURPOSE. See the GNU General Public License for more details.
137-#
138-# You should have received a copy of the GNU General Public License along
139-# with this program. If not, see <http://www.gnu.org/licenses/>.
140-
141-"""A QApplication that starts a single instance."""
142-
143-from PyQt4 import QtGui, QtCore
144-
145-
146-class UniqueApplication(QtGui.QApplication):
147-
148- """A dummy UniqueApplication class."""
149-
150- new_instance = QtCore.pyqtSignal()
151-
152- def __init__(self, argv, key):
153- super(UniqueApplication, self).__init__(argv)
154
155=== renamed file 'ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_windows.py' => 'ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_unique_app.py'
156--- ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_windows.py 2012-01-02 14:29:16 +0000
157+++ ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_unique_app.py 2012-04-25 14:34:51 +0000
158@@ -19,8 +19,9 @@
159 from PyQt4 import QtCore
160 from twisted.internet.defer import inlineCallbacks
161
162-from ubuntuone.controlpanel.gui.qt.uniqueapp import windows as uniqueapp
163+from ubuntuone.controlpanel.gui.qt import uniqueapp
164 from ubuntuone.controlpanel.tests import TestCase
165+from ubuntuone.controlpanel.gui.tests import FakeSignal
166
167
168 #pylint: disable=C0103
169@@ -42,28 +43,6 @@
170 return self.connect_succeeds
171
172
173-class FakeSignal(object):
174-
175- """A fake PyQt signal."""
176-
177- def __init__(self, *args, **kwargs):
178- """Initialize."""
179- self.target = None
180-
181- def connect(self, target):
182- """Fake connect."""
183- self.target = target
184-
185- def disconnect(self, *args):
186- """Fake disconnect."""
187- self.target = None
188-
189- def emit(self, *args):
190- """Fake emit."""
191- if self.target:
192- self.target(*args)
193-
194-
195 class FakeLocalServer(object):
196
197 """A fake QLocalServer."""
198
199=== removed file 'ubuntuone/controlpanel/gui/qt/uniqueapp/windows.py'
200--- ubuntuone/controlpanel/gui/qt/uniqueapp/windows.py 2012-01-04 11:09:35 +0000
201+++ ubuntuone/controlpanel/gui/qt/uniqueapp/windows.py 1970-01-01 00:00:00 +0000
202@@ -1,52 +0,0 @@
203-# -*- coding: utf-8 -*-
204-#
205-# Copyright 2011 Canonical Ltd.
206-#
207-# This program is free software: you can redistribute it and/or modify it
208-# under the terms of the GNU General Public License version 3, as published
209-# by the Free Software Foundation.
210-#
211-# This program is distributed in the hope that it will be useful, but
212-# WITHOUT ANY WARRANTY; without even the implied warranties of
213-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
214-# PURPOSE. See the GNU General Public License for more details.
215-#
216-# You should have received a copy of the GNU General Public License along
217-# with this program. If not, see <http://www.gnu.org/licenses/>.
218-
219-"""A QApplication that starts a single instance."""
220-
221-import sys
222-
223-from PyQt4 import QtNetwork, QtGui, QtCore
224-
225-
226-class UniqueApplication(QtGui.QApplication):
227-
228- """A QApplication that can only be started once.
229-
230- Also, the new instance notifies the old one to show
231- its window.
232- """
233-
234- new_instance = QtCore.pyqtSignal()
235-
236- def __init__(self, argv, key):
237- super(UniqueApplication, self).__init__(argv)
238- self.key = key
239- self.server = QtNetwork.QLocalServer(self)
240- self.server.newConnection.connect(self.new_instance.emit)
241- self.aboutToQuit.connect(self.cleanup)
242- # Try to connect to existing app
243- socket = QtNetwork.QLocalSocket()
244- socket.connectToServer(key, QtCore.QIODevice.WriteOnly)
245- if socket.waitForConnected(500):
246- # Connected, exit
247- sys.exit()
248-
249- # Not connected, start server
250- self.ready = self.server.listen(key)
251-
252- def cleanup(self):
253- """Remove the socket when we die."""
254- self.server.removeServer(self.key)
255
256=== modified file 'ubuntuone/controlpanel/gui/tests/__init__.py'
257--- ubuntuone/controlpanel/gui/tests/__init__.py 2012-03-08 20:46:13 +0000
258+++ ubuntuone/controlpanel/gui/tests/__init__.py 2012-04-25 14:34:51 +0000
259@@ -175,3 +175,25 @@
260 return result
261
262 return faked_call_in_faked_object
263+
264+
265+class FakeSignal(object):
266+
267+ """A fake PyQt signal."""
268+
269+ def __init__(self, *args, **kwargs):
270+ """Initialize."""
271+ self.target = None
272+
273+ def connect(self, target):
274+ """Fake connect."""
275+ self.target = target
276+
277+ def disconnect(self, *args):
278+ """Fake disconnect."""
279+ self.target = None
280+
281+ def emit(self, *args):
282+ """Fake emit."""
283+ if self.target:
284+ self.target(*args)

Subscribers

People subscribed via source and target branches