Merge lp:~robert-ancell/quickly/drop-lpi into lp:quickly

Proposed by Robert Ancell
Status: Merged
Approved by: Didier Roche-Tolomelli
Approved revision: 668
Merged at revision: 684
Proposed branch: lp:~robert-ancell/quickly/drop-lpi
Merge into: lp:quickly
Diff against target: 541 lines (+0/-395)
6 files modified
data/templates/ubuntu-application/internal/apportutils.py (+0/-57)
data/templates/ubuntu-application/project_root/python_lib/Window.py (+0/-11)
data/templates/ubuntu-application/test/apport/TestProjectWindow.py.no_lpi (+0/-102)
data/templates/ubuntu-application/test/apport/apport.sh (+0/-84)
data/templates/ubuntu-application/test/apportutils.py (+0/-140)
data/templates/ubuntu-application/upgrade.py (+0/-1)
To merge this branch: bzr merge lp:~robert-ancell/quickly/drop-lpi
Reviewer Review Type Date Requested Status
Didier Roche-Tolomelli Needs Fixing
Review via email: mp+105735@code.launchpad.net

Description of the change

Remove Launchpad integration. It will be removed in Quantal:
https://blueprints.launchpad.net/ubuntu/+spec/desktop-q-gnome-plans-review

Not sure if this branch does enough, and also the packaging needs to be updated to drop the dependency.

To post a comment you must log in.
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

that looks good. Nice work Robert!

I think you did all what is needed apart from giving an upgrade story.
Can you try to add an upgrade path to data/templates/ubuntu-application/upgrade.py to remove it (if the stenza is found) on project upgrade?
You should "just" need to remove bump the version of the template and remove the lpi lines if you find them anywhere on the project directory.

review: Needs Fixing
Revision history for this message
Michael Terry (mterry) wrote :

Didier, does this need to remove the code on upgrade? It's harmless if the module isn't present (ignores the exception).

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

@Michael: you are right, but that means that we will still install it if the application packaging was generated on a machine that have LPI, it will be pulled on the user's machine for nothing, wdyt?

Revision history for this message
Michael Terry (mterry) wrote :

Fair.

I have a branch I'm about to propose that will help with such upgrade.py issues (the branch will finally actually keep bin/, setup.py, and python_lib/ up to date with the latest versions automatically, so we don't have to keep managing upgrade.py ourselves for the quickly-owned code).

I'll base it off this branch because there is actually some overlapping changes in the apport test. So if the upgrade branch gets approval, this can land too, because it will get upgrade support automatically.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

I'm approving this one then, please feel free to merge it altogether with your test branch

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/templates/ubuntu-application/internal/apportutils.py'
2--- data/templates/ubuntu-application/internal/apportutils.py 2011-06-06 10:14:40 +0000
3+++ data/templates/ubuntu-application/internal/apportutils.py 2012-05-14 22:57:18 +0000
4@@ -28,19 +28,6 @@
5
6 from lxml import etree
7
8-LPI_init_menu_block = """
9- # Optional Launchpad integration
10- # This shouldn't crash if not found as it is simply used for bug reporting.
11- # See https://wiki.ubuntu.com/UbuntuDevelopment/Internationalisation/Coding
12- # for more information about Launchpad integration.
13- try:
14- import LaunchpadIntegration
15- LaunchpadIntegration.add_items(self.ui.%(help_menu)s, 1, True, True)
16- LaunchpadIntegration.set_sourcepackagename('%(project_name)s')
17- except:
18- pass
19-"""
20-
21 def update_apport(project_name, old_lp_project, new_lp_project):
22 if not new_lp_project:
23 return
24@@ -88,50 +75,6 @@
25 os.makedirs(relative_apport_dir)
26 templatetools.file_from_template(template_hook_dir, "source_project_name.py", relative_apport_dir, subst_new)
27
28-def insert_lpi_if_required(project_name):
29- camel_case_project_name = quickly.templatetools.get_camel_case_name(project_name)
30- existing_base_filename = os.path.join(quickly.templatetools.python_name(project_name) + '_lib',
31- "Window.py")
32- existing_ui_filename = os.path.join("data", "ui", "%sWindow.ui"%camel_case_project_name)
33-
34- if os.path.isfile(existing_base_filename) and os.path.isfile(existing_ui_filename):
35- tree = etree.parse(existing_ui_filename)
36- help_menu = find_about_menu(tree)
37-
38- if help_menu:
39- existing_base_file = file(existing_base_filename, "r")
40- existing_lines = existing_base_file.readlines()
41- existing_base_file.close()
42- new_lines = detect_or_insert_lpi(existing_lines, project_name, help_menu)
43- if new_lines:
44- print _("Adding launchpad integration to existing application")
45- new_content = ''.join(new_lines)
46- templatetools.set_file_contents(existing_base_filename, new_content)
47- return True
48- return False
49-
50-def detect_or_insert_lpi(existing_lines, project_name, help_menu):
51- integration_present = False
52- init_insert_line = None
53- current_line = 0
54- for line in existing_lines:
55- if "import LaunchpadIntegration" in line:
56- integration_present = True
57- break
58- if not init_insert_line and "self.builder.connect_signals(self)" in line:
59- init_insert_line = current_line
60- current_line += 1
61-
62- if not integration_present and init_insert_line:
63- init_menu_block = LPI_init_menu_block%{"project_name":project_name, "help_menu":help_menu}
64- existing_lines = existing_lines[:init_insert_line+1] + \
65- ["%s\n"%l for l in init_menu_block.splitlines()] + \
66- existing_lines[init_insert_line+1:]
67- return existing_lines
68- else:
69- return None
70-
71-
72 def find_about_menu(tree):
73 """Finds the current help menu in the passed xml document by looking for the gtk-about element"""
74 help_item = tree.xpath('//property[@name="label" and .="gtk-about"]/../../../@id')
75
76=== modified file 'data/templates/ubuntu-application/project_root/python_lib/Window.py'
77--- data/templates/ubuntu-application/project_root/python_lib/Window.py 2011-11-07 21:55:54 +0000
78+++ data/templates/ubuntu-application/project_root/python_lib/Window.py 2012-05-14 22:57:18 +0000
79@@ -52,17 +52,6 @@
80 self.settings = Gio.Settings("net.launchpad.project_name")
81 self.settings.connect('changed', self.on_preferences_changed)
82
83- # Optional Launchpad integration
84- # This shouldn't crash if not found as it is simply used for bug reporting.
85- # See https://wiki.ubuntu.com/UbuntuDevelopment/Internationalisation/Coding
86- # for more information about Launchpad integration.
87- try:
88- from gi.repository import LaunchpadIntegration # pylint: disable=E0611
89- LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
90- LaunchpadIntegration.set_sourcepackagename('project_name')
91- except ImportError:
92- pass
93-
94 # Optional application indicator support
95 # Run 'quickly add indicator' to get started.
96 # More information:
97
98=== removed file 'data/templates/ubuntu-application/test/apport/TestProjectWindow.py.no_lpi'
99--- data/templates/ubuntu-application/test/apport/TestProjectWindow.py.no_lpi 2011-03-01 20:12:22 +0000
100+++ data/templates/ubuntu-application/test/apport/TestProjectWindow.py.no_lpi 1970-01-01 00:00:00 +0000
101@@ -1,102 +0,0 @@
102-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
103-### BEGIN LICENSE
104-# This file is in the public domain
105-### END LICENSE
106-
107-import gtk
108-
109-import test.helpers as helpers
110-
111-import gettext
112-from gettext import gettext as _
113-gettext.textdomain('test')
114-
115-
116-# This class is meant to be subclassed by TestWindow. It provides
117-# common functions and some boilerplate.
118-class BaseTestWindow(gtk.Window):
119- __gtype_name__ = "BaseTestWindow"
120-
121- # To construct a new instance of this method, the following notable
122- # methods are called in this order:
123- # __new__(cls)
124- # __init__(self)
125- # finish_initializing(self, builder)
126- # __init__(self)
127- #
128- # For this reason, it's recommended you leave __init__ empty and put
129- # your initialization code in finish_initializing
130-
131- def __new__(cls):
132- """Special static method that's automatically called by Python when
133- constructing a new instance of this class.
134-
135- Returns a fully instantiated BaseTestWindow object.
136- """
137- builder = helpers.get_builder('TestWindow')
138- new_object = builder.get_object("test_window")
139- new_object.finish_initializing(builder)
140- return new_object
141-
142- def finish_initializing(self, builder):
143- """Called while initializing this instance in __new__
144-
145- finish_initializing should be called after parsing the UI definition
146- and creating a TestWindow object with it in order to finish
147- initializing the start of the new TestWindow instance.
148-
149- Put your initilization code in here and leave __init__ undefined.
150- """
151- # Get a reference to the builder and set up the signals.
152- self.builder = builder
153- self.builder.connect_signals(self)
154-
155- # Optional application indicator support
156- # Run 'quickly add indicator' to get started.
157- # More information:
158- # http://owaislone.org/quickly-add-indicator/
159- # https://wiki.ubuntu.com/DesktopExperienceTeam/ApplicationIndicators
160- try:
161- from test import indicator
162- # self is passed so methods of this class can be called from indicator.py
163- # Comment this next line out to disable appindicator
164- self.indicator = indicator.new_application_indicator(self)
165- except:
166- pass
167-
168- def load_preferences(self):
169- """Loads preferences into self.preferences"""
170- prefs = PreferencesTestDialog.PreferencesTestDialog()
171- self.preferences = prefs.get_preferences()
172-
173- def about(self, widget, data=None):
174- """Display the about box for test."""
175- about = AboutTestDialog.AboutTestDialog()
176- response = about.run()
177- about.destroy()
178-
179- def preferences(self, widget, data=None):
180- """Display the preferences window for test."""
181- prefs = PreferencesTestDialog.PreferencesTestDialog()
182- response = prefs.run()
183- if response == gtk.RESPONSE_OK and hasattr(self, 'preferences_updated'):
184- # Add a preferences_updated function to subclasses to react to
185- # changes that a user makes. You'll find such changes in self.preferences
186- self.preferences = prefs.get_preferences() # in case load_preferences was never called
187- self.preferences_updated()
188- prefs.destroy()
189-
190- def quit(self, widget, data=None):
191- """Signal handler for closing the TestWindow."""
192- self.destroy()
193-
194- def on_destroy(self, widget, data=None):
195- """Called when the TestWindow is closed."""
196- # Clean up code for saving application state should be added here.
197- gtk.main_quit()
198-
199-
200-if __name__ == "__main__":
201- window = BaseTestWindow()
202- window.show()
203- gtk.main()
204
205=== modified file 'data/templates/ubuntu-application/test/apport/apport.sh'
206--- data/templates/ubuntu-application/test/apport/apport.sh 2011-11-08 02:27:24 +0000
207+++ data/templates/ubuntu-application/test/apport/apport.sh 2012-05-14 22:57:18 +0000
208@@ -11,28 +11,12 @@
209
210 cd test-project
211
212-grep LaunchpadIntegration. test_project_lib/Window.py
213-# from gi.repository import LaunchpadIntegration # pylint: disable=E0611
214-# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
215-# LaunchpadIntegration.set_sourcepackagename('test-project')
216-
217-grep helpMenu test_project_lib/Window.py
218-# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
219-
220 quickly configure lp-project gpoweroff
221 # Get Launchpad Settings
222 # Launchpad connection is ok
223 # Creating new apport crashdb configuration
224 # Creating new apport hooks
225
226-grep LaunchpadIntegration. test_project_lib/Window.py
227-# from gi.repository import LaunchpadIntegration # pylint: disable=E0611
228-# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
229-# LaunchpadIntegration.set_sourcepackagename('test-project')
230-
231-grep helpMenu test_project_lib/Window.py
232-# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
233-
234 bzr status
235 # modified:
236 # .quickly
237@@ -55,14 +39,6 @@
238 # Launchpad connection is ok
239 # Updating project name references in existing apport crashdb configuration
240
241-grep LaunchpadIntegration. test_project_lib/Window.py
242-# from gi.repository import LaunchpadIntegration # pylint: disable=E0611
243-# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
244-# LaunchpadIntegration.set_sourcepackagename('test-project')
245-
246-grep helpMenu test_project_lib/Window.py
247-# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
248-
249 bzr status
250 # added:
251 # apport/
252@@ -121,14 +97,6 @@
253 # Launchpad connection is ok
254 # Updating project name references in existing apport crashdb configuration
255
256-grep LaunchpadIntegration. test_project_lib/Window.py
257-# from gi.repository import LaunchpadIntegration # pylint: disable=E0611
258-# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
259-# LaunchpadIntegration.set_sourcepackagename('test-project')
260-
261-grep helpMenu test_project_lib/Window.py
262-# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
263-
264 bzr status
265 # modified:
266 # .quickly
267@@ -152,14 +120,6 @@
268 # Updating project name references in existing apport crashdb configuration
269 # Creating new apport hooks
270
271-grep LaunchpadIntegration. test_project_lib/Window.py
272-# from gi.repository import LaunchpadIntegration # pylint: disable=E0611
273-# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
274-# LaunchpadIntegration.set_sourcepackagename('test-project')
275-
276-grep helpMenu test_project_lib/Window.py
277-# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
278-
279 cat etc/apport/crashdb.conf.d/test-project-crashdb.conf
280 # ### BEGIN LICENSE
281 # # This file is in the public domain
282@@ -192,14 +152,6 @@
283 # Launchpad connection is ok
284 # Updating project name references in existing apport crashdb configuration
285
286-grep LaunchpadIntegration. test_project_lib/Window.py
287-# from gi.repository import LaunchpadIntegration # pylint: disable=E0611
288-# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
289-# LaunchpadIntegration.set_sourcepackagename('test-project')
290-
291-grep helpMenu test_project_lib/Window.py
292-# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
293-
294 cat etc/apport/crashdb.conf.d/test-project-crashdb.conf
295 # ### BEGIN LICENSE
296 # # This file is in the public domain
297@@ -319,14 +271,6 @@
298 # Creating new apport crashdb configuration
299 # Creating new apport hooks
300
301-grep LaunchpadIntegration. test_project_lib/Window.py
302-# from gi.repository import LaunchpadIntegration # pylint: disable=E0611
303-# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
304-# LaunchpadIntegration.set_sourcepackagename('test-project')
305-
306-grep helpMenu test_project_lib/Window.py
307-# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
308-
309 cat etc/apport/crashdb.conf.d/test-project-crashdb.conf
310 # ### BEGIN LICENSE
311 # # This file is in the public domain
312@@ -354,66 +298,38 @@
313 # report['ThirdParty'] = 'True'
314 # report['CrashDB'] = 'test_project'
315
316-cp "$TEST_SCRIPT_DIR/TestProjectWindow.py.no_lpi" ./test_project_lib/Window.py
317-
318 cp "$TEST_SCRIPT_DIR/TestProjectWindow.ui.renamed_help_menu" ./data/ui/TestProjectWindow.ui
319
320 rm -rf apport
321
322 rm -rf etc
323
324-grep LaunchpadIntegration. test_project_lib/Window.py
325-
326-grep helpMenu test_project_lib/Window.py
327-
328 quickly upgrade 0.3
329-# Adding launchpad integration to existing application
330 # Creating new apport crashdb configuration
331 # Creating new apport hooks
332
333-grep LaunchpadIntegration. test_project_lib/Window.py
334-# LaunchpadIntegration.add_items(self.ui.differentHelpMenu, 1, True, True)
335-# LaunchpadIntegration.set_sourcepackagename('test-project')
336-
337-cp "$TEST_SCRIPT_DIR/TestProjectWindow.py.no_lpi" ./test_project_lib/Window.py
338-
339 cp "$TEST_SCRIPT_DIR/TestProjectWindow.ui.no_gtk-about" ./data/ui/TestProjectWindow.ui
340
341 rm -rf apport
342
343 rm -rf etc
344
345-grep LaunchpadIntegration. test_project_lib/Window.py
346-
347-grep helpMenu test_project_lib/Window.py
348-
349 grep gtk-about data/ui/TestProjectWindow.ui
350
351 bzr commit -m "Committing after removing all lpi integration"
352 # Committing to: /tmp/test-project/
353 # modified data/ui/TestProjectWindow.ui
354-# modified test_project_lib/Window.py
355 # Committed revision 6.
356
357 quickly upgrade 0.3
358 # Creating new apport crashdb configuration
359 # Creating new apport hooks
360
361-grep LaunchpadIntegration. test_project_lib/Window.py
362-
363-grep helpMenu test_project_lib/Window.py
364-
365 bzr status
366 # unknown:
367 # apport/
368 # etc/
369
370-cp "$TEST_SCRIPT_DIR/TestProjectWindow.py.no_lpi" ./test_project_lib/Window.py
371-
372 rm ./data/ui/TestProjectWindow.ui
373
374-grep LaunchpadIntegration. test_project_lib/Window.py
375-
376-grep helpMenu test_project_lib/Window.py
377-
378 quickly upgrade 0.3
379
380=== modified file 'data/templates/ubuntu-application/test/apportutils.py'
381--- data/templates/ubuntu-application/test/apportutils.py 2011-04-04 13:22:11 +0000
382+++ data/templates/ubuntu-application/test/apportutils.py 2012-05-14 22:57:18 +0000
383@@ -17,146 +17,6 @@
384 from internal import apportutils
385
386 class TestApportUtils(unittest.TestCase):
387- def test_lpi_existing(self):
388- lines = """#!/usr/bin/python
389-import sys
390-import os
391-import gtk
392-import gettext
393-from gettext import gettext as _
394-gettext.textdomain('project_name')
395-
396-# optional Launchpad integration
397-# this shouldn't crash if not found as it is simply used for bug reporting
398-try:
399- import LaunchpadIntegration
400- launchpad_available = True
401-except:
402- launchpad_available = False
403-
404-class camel_case_nameWindow(gtk.Window):
405- __gtype_name__ = "camel_case_nameWindow"
406-
407- def __init__(self):
408- pass
409-
410- def finish_initializing(self, builder):
411- # Get a reference to the builder and set up the signals.
412- self.builder = builder
413- self.builder.connect_signals(self)
414-
415- if launchpad_available:
416- # see https://wiki.ubuntu.com/UbuntuDevelopment/Internationalisation/Coding for more information
417- # about LaunchpadIntegration
418- LaunchpadIntegration.set_sourcepackagename('project_name')
419- LaunchpadIntegration.add_items(self.builder.get_object('helpMenu'), 1, True, True)
420-
421- def about(self, widget, data=None):
422- about = Aboutcamel_case_nameDialog.NewAboutcamel_case_nameDialog()
423- response = about.run()
424- about.destroy()
425-""".splitlines()
426- self.failIf(apportutils.detect_or_insert_lpi(lines, "project_name1", "helpMenu1"))
427-
428- def test_partial_lpi_import_only(self):
429- lines = """#!/usr/bin/python
430-import sys
431-import os
432-import gtk
433-import gettext
434-from gettext import gettext as _
435-gettext.textdomain('project_name')
436-
437-# optional Launchpad integration
438-# this shouldn't crash if not found as it is simply used for bug reporting
439-try:
440- import LaunchpadIntegration
441- launchpad_available = True
442-except:
443- launchpad_available = False
444-
445-class camel_case_nameWindow(gtk.Window):
446- __gtype_name__ = "camel_case_nameWindow"
447-
448- def __init__(self):
449- pass
450-
451- def finish_initializing(self, builder):
452- # Get a reference to the builder and set up the signals.
453- self.builder = builder
454- self.builder.connect_signals(self)
455-
456- def about(self, widget, data=None):
457- about = Aboutcamel_case_nameDialog.NewAboutcamel_case_nameDialog()
458- response = about.run()
459- about.destroy()
460-""".splitlines()
461- self.failIf(apportutils.detect_or_insert_lpi(lines, "project_name1", "helpMenu1"))
462-
463- def test_no_lpi(self):
464- lines = """#!/usr/bin/python
465-import sys
466-import os
467-import gtk
468-import gettext
469-from gettext import gettext as _
470-gettext.textdomain('project_name')
471-
472-class camel_case_nameWindow(gtk.Window):
473- __gtype_name__ = "camel_case_nameWindow"
474-
475- def __init__(self):
476- pass
477-
478- def finish_initializing(self, builder):
479- # Get a reference to the builder and set up the signals.
480- self.builder = builder
481- self.builder.connect_signals(self)
482-
483- def about(self, widget, data=None):
484- about = Aboutcamel_case_nameDialog.NewAboutcamel_case_nameDialog()
485- response = about.run()
486- about.destroy()
487-""".splitlines(True)
488- expected = """#!/usr/bin/python
489-import sys
490-import os
491-import gtk
492-import gettext
493-from gettext import gettext as _
494-gettext.textdomain('project_name')
495-
496-class camel_case_nameWindow(gtk.Window):
497- __gtype_name__ = "camel_case_nameWindow"
498-
499- def __init__(self):
500- pass
501-
502- def finish_initializing(self, builder):
503- # Get a reference to the builder and set up the signals.
504- self.builder = builder
505- self.builder.connect_signals(self)
506-
507- # Optional Launchpad integration
508- # This shouldn't crash if not found as it is simply used for bug reporting.
509- # See https://wiki.ubuntu.com/UbuntuDevelopment/Internationalisation/Coding
510- # for more information about Launchpad integration.
511- try:
512- import LaunchpadIntegration
513- LaunchpadIntegration.add_items(self.ui.helpMenu1, 1, True, True)
514- LaunchpadIntegration.set_sourcepackagename('project_name1')
515- except:
516- pass
517-
518- def about(self, widget, data=None):
519- about = Aboutcamel_case_nameDialog.NewAboutcamel_case_nameDialog()
520- response = about.run()
521- about.destroy()
522-"""
523- # print "".join(apportutils.detect_or_insert_lpi(lines, "project_name1", "helpMenu1"))
524- # print "".join(expected.splitlines(True))
525- self.assertEqual("".join(expected.splitlines(True)).strip(), "".join(apportutils.detect_or_insert_lpi(lines, "project_name1", "helpMenu1")).strip())
526-
527 def test_find_about_menu(self):
528 xml_tree = etree.parse(StringIO.StringIO("""<?xml version="1.0"?>
529 <interface>
530
531=== modified file 'data/templates/ubuntu-application/upgrade.py'
532--- data/templates/ubuntu-application/upgrade.py 2011-12-22 16:42:11 +0000
533+++ data/templates/ubuntu-application/upgrade.py 2012-05-14 22:57:18 +0000
534@@ -169,7 +169,6 @@
535 pass
536
537 # add apport hooks if launchpad application is configured
538- internal.apportutils.insert_lpi_if_required(project_name)
539 lp_project_name = configurationhandler.project_config.get('lp_id', None)
540 if lp_project_name is not None:
541 internal.apportutils.update_apport(project_name, lp_project_name, lp_project_name)

Subscribers

People subscribed via source and target branches