Merge lp:~mterry/quickly/small-refactor into lp:quickly

Proposed by Michael Terry
Status: Needs review
Proposed branch: lp:~mterry/quickly/small-refactor
Merge into: lp:quickly
Diff against target: 753 lines (+207/-192)
14 files modified
data/templates/ubuntu-application/configure.py (+12/-15)
data/templates/ubuntu-application/internal/bzrutils.py (+0/-37)
data/templates/ubuntu-application/package.py (+2/-1)
data/templates/ubuntu-application/release.py (+16/-17)
data/templates/ubuntu-application/share.py (+5/-4)
data/templates/ubuntu-application/submitubuntu.py (+16/-17)
data/templates/ubuntu-application/test/apportutils.py (+7/-7)
data/templates/ubuntu-application/upgrade.py (+3/-4)
quickly/lp/__init__.py (+18/-0)
quickly/lp/access.py (+3/-84)
quickly/lp/bzr.py (+20/-1)
quickly/lp/project.py (+82/-0)
quickly/ubuntu/__init__.py (+18/-0)
quickly/ubuntu/packaging.py (+5/-5)
To merge this branch: bzr merge lp:~mterry/quickly/small-refactor
Reviewer Review Type Date Requested Status
Quickly Developers Pending
Review via email: mp+44606@code.launchpad.net

Description of the change

This is a bit of a refactor to pull some code from ubuntu-application's 'internal' module into the 'quickly' module.

This started based on the quickly-talk thread about how best to enable non-ubuntu templates. This doesn't directly aid that goal, as most of the stuff pulled out is for LP or Ubuntu integration. But it is a proof of concept.

After this is discussed/approved, we can perhaps pull out some of the python code to be more generic too.

To post a comment you must log in.

Unmerged revisions

581. By Michael Terry

move packaging and apport modules to a new quickly.ubuntu module

580. By Michael Terry

create and use quickly.lp

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/templates/ubuntu-application/configure.py'
--- data/templates/ubuntu-application/configure.py 2010-10-18 18:39:04 +0000
+++ data/templates/ubuntu-application/configure.py 2010-12-23 18:15:10 +0000
@@ -20,13 +20,10 @@
20import sys20import sys
21import subprocess21import subprocess
2222
23import internal.apportutils23from internal import quicklyutils
24
25from internal import quicklyutils, packaging
26from internal import bzrutils
27from quickly import configurationhandler, templatetools24from quickly import configurationhandler, templatetools
28from quickly import launchpadaccess25from quickly.ubuntu import apport, packaging
2926import quickly.lp as lp
3027
31import gettext28import gettext
32from gettext import gettext as _29from gettext import gettext as _
@@ -73,8 +70,8 @@
73if argv[1] == "lp-project":70if argv[1] == "lp-project":
74 # connect to LP71 # connect to LP
75 try:72 try:
76 launchpad = launchpadaccess.initialize_lpi()73 launchpad = lp.access.initialize_lpi()
77 except launchpadaccess.launchpad_connection_error, e:74 except lp.access.launchpad_connection_error, e:
78 print(e)75 print(e)
79 sys.exit(1)76 sys.exit(1)
8077
@@ -90,13 +87,13 @@
90 previous_lp_project_name = configurationhandler.project_config.get('lp_id', None)87 previous_lp_project_name = configurationhandler.project_config.get('lp_id', None)
91 quickly_project_name = configurationhandler.project_config.get('project', None)88 quickly_project_name = configurationhandler.project_config.get('project', None)
92 try:89 try:
93 project = launchpadaccess.link_project(launchpad, "Change your launchpad project:", project_name)90 project = lp.project.link_project(launchpad, "Change your launchpad project:", project_name)
94 internal.apportutils.update_apport(quickly_project_name, previous_lp_project_name, project.name)91 apport.update_apport(quickly_project_name, previous_lp_project_name, project.name)
95 except launchpadaccess.launchpad_project_error, e:92 except lp.access.launchpad_project_error, e:
96 print(e)93 print(e)
97 sys.exit(1)94 sys.exit(1)
98 # get the project now and save the url into setup.py95 # get the project now and save the url into setup.py
99 project_url = launchpadaccess.launchpad_url + '/' + project.name96 project_url = lp.access.launchpad_url + '/' + project.name
100 quicklyutils.set_setup_value('url', project_url)97 quicklyutils.set_setup_value('url', project_url)
101 about_dialog_file_name = quicklyutils.get_about_file_name()98 about_dialog_file_name = quicklyutils.get_about_file_name()
102 if about_dialog_file_name:99 if about_dialog_file_name:
@@ -112,8 +109,8 @@
112109
113 # connect to LP110 # connect to LP
114 try:111 try:
115 launchpad = launchpadaccess.initialize_lpi()112 launchpad = lp.access.initialize_lpi()
116 except launchpadaccess.launchpad_connection_error, e:113 except lp.access.launchpad_connection_error, e:
117 print(e)114 print(e)
118 sys.exit(1)115 sys.exit(1)
119116
@@ -147,7 +144,7 @@
147 if len(argv) != 3:144 if len(argv) != 3:
148 templatetools.print_usage(options['bzr'])145 templatetools.print_usage(options['bzr'])
149 sys.exit(4)146 sys.exit(4)
150 bzrutils.set_bzrbranch(argv[2])147 lp.bzr.set_bzrbranch(argv[2])
151 configurationhandler.saveConfig() 148 configurationhandler.saveConfig()
152149
153# add additional dependencies150# add additional dependencies
154151
=== removed file 'data/templates/ubuntu-application/internal/bzrutils.py'
--- data/templates/ubuntu-application/internal/bzrutils.py 2010-08-13 15:04:05 +0000
+++ data/templates/ubuntu-application/internal/bzrutils.py 1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2010 Didier Roche
3#
4# This file is part of Quickly ubuntu-application template
5#
6#This program is free software: you can redistribute it and/or modify it
7#under the terms of the GNU General Public License version 3, as published
8#by the Free Software Foundation.
9
10#This program is distributed in the hope that it will be useful, but
11#WITHOUT ANY WARRANTY; without even the implied warranties of
12#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13#PURPOSE. See the GNU General Public License for more details.
14
15#You should have received a copy of the GNU General Public License along
16#with this program. If not, see <http://www.gnu.org/licenses/>.
17
18from quickly import configurationhandler
19
20def set_bzrbranch(bzr_branch):
21 '''set default bzr branch from where to pull and push'''
22
23 if not configurationhandler.project_config:
24 configurationhandler.loadConfig()
25 configurationhandler.project_config['bzrbranch'] = bzr_branch
26
27def get_bzrbranch():
28 '''get default bzr branch from where to pull and push'''
29
30 if not configurationhandler.project_config:
31 configurationhandler.loadConfig()
32
33 try:
34 bzr_branch = configurationhandler.project_config['bzrbranch']
35 except KeyError:
36 bzr_branch = None
37 return bzr_branch
380
=== modified file 'data/templates/ubuntu-application/package.py'
--- data/templates/ubuntu-application/package.py 2010-10-15 20:26:19 +0000
+++ data/templates/ubuntu-application/package.py 2010-12-23 18:15:10 +0000
@@ -23,8 +23,9 @@
23from gettext import gettext as _23from gettext import gettext as _
24gettext.textdomain('quickly')24gettext.textdomain('quickly')
2525
26from internal import quicklyutils, packaging26from internal import quicklyutils
27from quickly import templatetools, configurationhandler27from quickly import templatetools, configurationhandler
28from quickly.ubuntu import packaging
2829
2930
30def usage():31def usage():
3132
=== modified file 'data/templates/ubuntu-application/release.py'
--- data/templates/ubuntu-application/release.py 2010-10-18 18:39:04 +0000
+++ data/templates/ubuntu-application/release.py 2010-12-23 18:15:10 +0000
@@ -21,15 +21,14 @@
21import subprocess21import subprocess
22import webbrowser22import webbrowser
2323
24from internal import quicklyutils, packaging, launchpad_helper24from internal import quicklyutils
25from internal import bzrutils
26from quickly import templatetools, configurationhandler, commands25from quickly import templatetools, configurationhandler, commands
26from quickly.ubuntu import packaging
27import quickly.lp as lp
27import license28import license
2829
29import logging30import logging
3031
31from quickly import launchpadaccess
32
33import gettext32import gettext
34from gettext import gettext as _33from gettext import gettext as _
35gettext.textdomain('quickly')34gettext.textdomain('quickly')
@@ -113,8 +112,8 @@
113112
114# connect to LP113# connect to LP
115try:114try:
116 launchpad = launchpadaccess.initialize_lpi()115 launchpad = lp.access.initialize_lpi()
117except launchpadaccess.launchpad_connection_error, e:116except lp.access.launchpad_connection_error, e:
118 print(e)117 print(e)
119 sys.exit(1)118 sys.exit(1)
120119
@@ -127,11 +126,11 @@
127126
128# get the project now and save the url into setup.py127# get the project now and save the url into setup.py
129try:128try:
130 project = launchpadaccess.get_project(launchpad)129 project = lp.project.get_project(launchpad)
131except launchpadaccess.launchpad_project_error, e:130except lp.access.launchpad_project_error, e:
132 print(e)131 print(e)
133 sys.exit(1)132 sys.exit(1)
134project_url = launchpadaccess.launchpad_url + '/' + project.name133project_url = lp.access.launchpad_url + '/' + project.name
135quicklyutils.set_setup_value('url', project_url)134quicklyutils.set_setup_value('url', project_url)
136about_dialog_file_name = quicklyutils.get_about_file_name()135about_dialog_file_name = quicklyutils.get_about_file_name()
137if about_dialog_file_name:136if about_dialog_file_name:
@@ -234,14 +233,14 @@
234 sys.exit(1)233 sys.exit(1)
235234
236235
237if (launchpadaccess.lp_server == "staging"):236if (lp.access.lp_server == "staging"):
238 bzr_staging = "//staging/"237 bzr_staging = "//staging/"
239else:238else:
240 bzr_staging = ""239 bzr_staging = ""
241240
242custom_location_in_info = None241custom_location_in_info = None
243branch_location = []242branch_location = []
244custom_location = bzrutils.get_bzrbranch()243custom_location = lp.bzr.get_bzrbranch()
245if custom_location:244if custom_location:
246 branch_location = [custom_location]245 branch_location = [custom_location]
247 custom_location_in_info = custom_location.replace('lp:', '')246 custom_location_in_info = custom_location.replace('lp:', '')
@@ -282,14 +281,14 @@
282 sys.exit(return_code)281 sys.exit(return_code)
283282
284#create new release_date283#create new release_date
285launchpad_helper.push_tarball_to_launchpad(project, release_version,284lp.project.push_tarball_to_launchpad(project, release_version,
286 "../%s_%s.tar.gz" % (project_name,285 "../%s_%s.tar.gz" % (project_name,
287 release_version), changelog)286 release_version), changelog)
288287
289print _("%s %s released and building on Launchpad. Wait for half an hour and have look at %s.") % (project_name, release_version, ppa_url)288print _("%s %s released and building on Launchpad. Wait for half an hour and have look at %s.") % (project_name, release_version, ppa_url)
290289
291# as launchpad-open doesn't support staging server, put an url290# as launchpad-open doesn't support staging server, put an url
292if launchpadaccess.lp_server == "staging":291if lp.access.lp_server == "staging":
293 webbrowser.open(launchpadaccess.LAUNCHPAD_CODE_STAGING_URL + '/' + project.name)292 webbrowser.open(lp.access.LAUNCHPAD_CODE_STAGING_URL + '/' + project.name)
294else:293else:
295 webbrowser.open(launchpadaccess.LAUNCHPAD_URL + '/' + project.name)294 webbrowser.open(lp.access.LAUNCHPAD_URL + '/' + project.name)
296295
=== modified file 'data/templates/ubuntu-application/share.py'
--- data/templates/ubuntu-application/share.py 2010-10-18 18:39:04 +0000
+++ data/templates/ubuntu-application/share.py 2010-12-23 18:15:10 +0000
@@ -28,8 +28,9 @@
28gettext.textdomain('quickly')28gettext.textdomain('quickly')
2929
30from quickly import configurationhandler30from quickly import configurationhandler
31from internal import quicklyutils, packaging31from internal import quicklyutils
32from quickly import launchpadaccess32from quickly.ubuntu import packaging
33import quickly.lp as lp
3334
34launchpad = None35launchpad = None
35ppa_name = None36ppa_name = None
@@ -98,8 +99,8 @@
9899
99# connect to LP100# connect to LP
100try:101try:
101 launchpad = launchpadaccess.initialize_lpi()102 launchpad = lp.access.initialize_lpi()
102except launchpadaccess.launchpad_connection_error, e:103except lp.access.launchpad_connection_error, e:
103 print(e)104 print(e)
104 sys.exit(1)105 sys.exit(1)
105106
106107
=== modified file 'data/templates/ubuntu-application/submitubuntu.py'
--- data/templates/ubuntu-application/submitubuntu.py 2010-11-11 14:19:38 +0000
+++ data/templates/ubuntu-application/submitubuntu.py 2010-12-23 18:15:10 +0000
@@ -21,15 +21,14 @@
21import subprocess21import subprocess
22import webbrowser22import webbrowser
2323
24from internal import quicklyutils, packaging, launchpad_helper24from internal import quicklyutils
25from internal import bzrutils
26from quickly import templatetools, configurationhandler, commands25from quickly import templatetools, configurationhandler, commands
26from quickly.ubuntu import packaging
27import quickly.lp as lp
27import license28import license
2829
29import logging30import logging
3031
31from quickly import launchpadaccess
32
33import gettext32import gettext
34from gettext import gettext as _33from gettext import gettext as _
35gettext.textdomain('quickly')34gettext.textdomain('quickly')
@@ -114,8 +113,8 @@
114113
115# connect to LP114# connect to LP
116try:115try:
117 launchpad = launchpadaccess.initialize_lpi()116 launchpad = lp.access.initialize_lpi()
118except launchpadaccess.launchpad_connection_error, e:117except lp.access.launchpad_connection_error, e:
119 print(e)118 print(e)
120 sys.exit(1)119 sys.exit(1)
121120
@@ -128,11 +127,11 @@
128127
129# get the project now and save the url into setup.py128# get the project now and save the url into setup.py
130try:129try:
131 project = launchpadaccess.get_project(launchpad)130 project = lp.project.get_project(launchpad)
132except launchpadaccess.launchpad_project_error, e:131except lp.access.launchpad_project_error, e:
133 print(e)132 print(e)
134 sys.exit(1)133 sys.exit(1)
135project_url = launchpadaccess.launchpad_url + '/' + project.name134project_url = lp.access.launchpad_url + '/' + project.name
136quicklyutils.set_setup_value('url', project_url)135quicklyutils.set_setup_value('url', project_url)
137about_dialog_file_name = quicklyutils.get_about_file_name()136about_dialog_file_name = quicklyutils.get_about_file_name()
138if about_dialog_file_name:137if about_dialog_file_name:
@@ -235,14 +234,14 @@
235 sys.exit(1)234 sys.exit(1)
236235
237236
238if (launchpadaccess.lp_server == "staging"):237if (lp.access.lp_server == "staging"):
239 bzr_staging = "//staging/"238 bzr_staging = "//staging/"
240else:239else:
241 bzr_staging = ""240 bzr_staging = ""
242241
243custom_location_in_info = None242custom_location_in_info = None
244branch_location = []243branch_location = []
245custom_location = bzrutils.get_bzrbranch()244custom_location = lp.bzr.get_bzrbranch()
246if custom_location:245if custom_location:
247 branch_location = [custom_location]246 branch_location = [custom_location]
248 custom_location_in_info = custom_location.replace('lp:', '')247 custom_location_in_info = custom_location.replace('lp:', '')
@@ -283,15 +282,15 @@
283 sys.exit(return_code)282 sys.exit(return_code)
284283
285#create new release_date284#create new release_date
286launchpad_helper.push_tarball_to_launchpad(project, release_version,285lp.project.push_tarball_to_launchpad(project, release_version,
287 "../%s_%s.tar.gz" % (project_name,286 "../%s_%s.tar.gz" % (project_name,
288 release_version), changelog)287 release_version), changelog)
289288
290print _("%s %s released and submitted to ubuntu. Wait for half an hour and have look at %s.") % (project_name, release_version, ppa_url)289print _("%s %s released and submitted to ubuntu. Wait for half an hour and have look at %s.") % (project_name, release_version, ppa_url)
291print _("Then your application will be reviewed by the application review board.")290print _("Then your application will be reviewed by the application review board.")
292291
293# as launchpad-open doesn't support staging server, put an url292# as launchpad-open doesn't support staging server, put an url
294if launchpadaccess.lp_server == "staging":293if lp.access.lp_server == "staging":
295 webbrowser.open(launchpadaccess.LAUNCHPAD_CODE_STAGING_URL + '/' + project.name)294 webbrowser.open(lp.access.LAUNCHPAD_CODE_STAGING_URL + '/' + project.name)
296else:295else:
297 webbrowser.open(launchpadaccess.LAUNCHPAD_URL + '/' + project.name)296 webbrowser.open(lp.access.LAUNCHPAD_URL + '/' + project.name)
298297
=== modified file 'data/templates/ubuntu-application/test/apportutils.py'
--- data/templates/ubuntu-application/test/apportutils.py 2010-12-20 15:44:44 +0000
+++ data/templates/ubuntu-application/test/apportutils.py 2010-12-23 18:15:10 +0000
@@ -14,9 +14,9 @@
14sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__),"..")))14sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__),"..")))
15sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__),"..","..","..","..")))15sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__),"..","..","..","..")))
1616
17from internal import apportutils17from quickly.ubuntu import apport
1818
19class TestApportUtils(unittest.TestCase):19class TestApport(unittest.TestCase):
20 def test_lpi_existing(self):20 def test_lpi_existing(self):
21 lines = """#!/usr/bin/python21 lines = """#!/usr/bin/python
22import sys22import sys
@@ -56,7 +56,7 @@
56 response = about.run()56 response = about.run()
57 about.destroy()57 about.destroy()
58""".splitlines()58""".splitlines()
59 self.failIf(apportutils.detect_or_insert_lpi(lines, "project_name1", "helpMenu1"))59 self.failIf(apport.detect_or_insert_lpi(lines, "project_name1", "helpMenu1"))
6060
61 def test_partial_lpi_import_only(self):61 def test_partial_lpi_import_only(self):
62 lines = """#!/usr/bin/python62 lines = """#!/usr/bin/python
@@ -91,7 +91,7 @@
91 response = about.run()91 response = about.run()
92 about.destroy()92 about.destroy()
93""".splitlines()93""".splitlines()
94 self.failIf(apportutils.detect_or_insert_lpi(lines, "project_name1", "helpMenu1"))94 self.failIf(apport.detect_or_insert_lpi(lines, "project_name1", "helpMenu1"))
9595
96 def test_no_lpi(self):96 def test_no_lpi(self):
97 lines = """#!/usr/bin/python97 lines = """#!/usr/bin/python
@@ -153,9 +153,9 @@
153 response = about.run()153 response = about.run()
154 about.destroy()154 about.destroy()
155"""155"""
156 # print "".join(apportutils.detect_or_insert_lpi(lines, "project_name1", "helpMenu1"))156 # print "".join(apport.detect_or_insert_lpi(lines, "project_name1", "helpMenu1"))
157 # print "".join(expected.splitlines(True))157 # print "".join(expected.splitlines(True))
158 self.assertEqual("".join(expected.splitlines(True)).strip(), "".join(apportutils.detect_or_insert_lpi(lines, "project_name1", "helpMenu1")).strip())158 self.assertEqual("".join(expected.splitlines(True)).strip(), "".join(apport.detect_or_insert_lpi(lines, "project_name1", "helpMenu1")).strip())
159159
160 def test_find_about_menu(self):160 def test_find_about_menu(self):
161 xml_tree = etree.parse(StringIO.StringIO("""<?xml version="1.0"?>161 xml_tree = etree.parse(StringIO.StringIO("""<?xml version="1.0"?>
@@ -207,6 +207,6 @@
207 </child>207 </child>
208 </object>208 </object>
209</interface>"""))209</interface>"""))
210 self.assertEqual("testHelpMenu", apportutils.find_about_menu(xml_tree))210 self.assertEqual("testHelpMenu", apport.find_about_menu(xml_tree))
211211
212unittest.main()212unittest.main()
213213
=== modified file 'data/templates/ubuntu-application/upgrade.py'
--- data/templates/ubuntu-application/upgrade.py 2010-12-07 14:14:08 +0000
+++ data/templates/ubuntu-application/upgrade.py 2010-12-23 18:15:10 +0000
@@ -21,10 +21,9 @@
21import subprocess21import subprocess
22import sys22import sys
2323
24import internal.apportutils
25
26from internal import quicklyutils24from internal import quicklyutils
27from quickly import configurationhandler, templatetools25from quickly import configurationhandler, templatetools
26from quickly.ubuntu import apport
2827
29import gettext28import gettext
30from gettext import gettext as _29from gettext import gettext as _
@@ -141,10 +140,10 @@
141 pass140 pass
142141
143 # add apport hooks if launchpad application is configured142 # add apport hooks if launchpad application is configured
144 internal.apportutils.insert_lpi_if_required(project_name)143 apport.insert_lpi_if_required(project_name)
145 lp_project_name = configurationhandler.project_config.get('lp_id', None)144 lp_project_name = configurationhandler.project_config.get('lp_id', None)
146 if lp_project_name is not None:145 if lp_project_name is not None:
147 internal.apportutils.update_apport(project_name, lp_project_name, lp_project_name)146 apport.update_apport(project_name, lp_project_name, lp_project_name)
148147
149 # new dialog file needs helpers.py148 # new dialog file needs helpers.py
150 if not os.path.isfile('%s/helpers.py' % python_name):149 if not os.path.isfile('%s/helpers.py' % python_name):
151150
=== added directory 'quickly/lp'
=== added file 'quickly/lp/__init__.py'
--- quickly/lp/__init__.py 1970-01-01 00:00:00 +0000
+++ quickly/lp/__init__.py 2010-12-23 18:15:10 +0000
@@ -0,0 +1,18 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2010 Canonical Ltd
3#
4# This file is part of Quickly
5#
6#This program is free software: you can redistribute it and/or modify it
7#under the terms of the GNU General Public License version 3, as published
8#by the Free Software Foundation.
9#
10#This program is distributed in the hope that it will be useful, but
11#WITHOUT ANY WARRANTY; without even the implied warranties of
12#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13#PURPOSE. See the GNU General Public License for more details.
14#
15#You should have received a copy of the GNU General Public License along
16#with this program. If not, see <http://www.gnu.org/licenses/>.
17
18import access, bzr, project
019
=== renamed file 'quickly/launchpadaccess.py' => 'quickly/lp/access.py'
--- quickly/launchpadaccess.py 2010-10-13 19:07:55 +0000
+++ quickly/lp/access.py 2010-12-23 18:15:10 +0000
@@ -24,7 +24,7 @@
24LAUNCHPAD_STAGING_URL = "https://staging.launchpad.net"24LAUNCHPAD_STAGING_URL = "https://staging.launchpad.net"
25LAUNCHPAD_CODE_STAGING_URL = "https://code.staging.launchpad.net"25LAUNCHPAD_CODE_STAGING_URL = "https://code.staging.launchpad.net"
2626
27# TODO: see how to export this error on import launchpadaccess (in init.py ?)27# TODO: see how to export this error on import quickly.lp.access (in init.py ?)
28class launchpad_connection_error(Exception):28class launchpad_connection_error(Exception):
29 pass29 pass
30class launchpad_project_error(Exception):30class launchpad_project_error(Exception):
@@ -40,7 +40,7 @@
40 sys.exit(1)40 sys.exit(1)
4141
4242
43from quickly import bzrbinding43from quickly.lp import bzr
44from quickly import configurationhandler44from quickly import configurationhandler
4545
46import gettext46import gettext
@@ -118,7 +118,7 @@
118118
119 # try to setup bzr119 # try to setup bzr
120 me = launchpad.me120 me = launchpad.me
121 (return_code, suggestion) = bzrbinding.bzr_set_login(me.display_name, me.preferred_email_address.email, me.name)121 (return_code, suggestion) = bzr.bzr_set_login(me.display_name, me.preferred_email_address.email, me.name)
122122
123 if interactive:123 if interactive:
124 if launchpad is None or return_code != 0:124 if launchpad is None or return_code != 0:
@@ -130,84 +130,3 @@
130130
131 return launchpad131 return launchpad
132132
133
134def link_project(launchpad, question, lp_project_name=None):
135 ''' Link to launchpad project, erasing previous one if already set
136
137
138 :return project object'''
139
140 # if config not already loaded
141 if not configurationhandler.project_config:
142 configurationhandler.loadConfig()
143
144 if not lp_project_name:
145 choice = "0"
146 while choice == "0":
147
148 lp_id = raw_input("%s, leave blank to abort.\nLaunchpad project name: " % question)
149 if lp_id == "":
150 raise launchpad_project_error(_("No launchpad project given, aborting."))
151
152 prospective_projects = launchpad.projects.search(text=lp_id)
153 project_number = 1
154 project_names = []
155 for project in prospective_projects:
156 print (_('''---------------- [%s] ----------------
157 %s
158--------------------------------------
159Project name: %s
160Launchpad url: %s/%s
161%s
162''') % (project_number, project.title, project.display_name, launchpad_url, project.name, project.summary))
163 project_names.append(project.name)
164 project_number += 1
165
166 if not list(prospective_projects):
167 message = _("No project found")
168 else:
169 message = _("Choose your project number")
170 choice = raw_input("%s, leave blank to abort, 0 for another search.\nYour choice: " % message)
171
172 try:
173 choice = int(choice)
174 if choice in range(1, project_number):
175 project = launchpad.projects[project_names[choice - 1]]
176 else:
177 raise ValueError
178 except ValueError:
179 raise launchpad_project_error(_("No right number given, aborting."))
180
181 # we got a project name, check that it exists
182 else:
183 try:
184 project = launchpad.projects[lp_project_name]
185 except KeyError:
186 raise launchpad_project_error(_("Can't find %s project on Launchpad. You can try to find it interactively without providing a project name.") % lp_project_name)
187
188 configurationhandler.project_config['lp_id'] = project.name
189 configurationhandler.saveConfig()
190
191 return project
192
193def get_project(launchpad):
194 ''' Get quickly project through launchpad.
195
196 :return project object
197 '''
198
199 # if config not already loaded
200 if not configurationhandler.project_config:
201 configurationhandler.loadConfig()
202
203 # try to get project
204 try:
205 lp_id = configurationhandler.project_config['lp_id']
206 project = launchpad.projects[lp_id]
207
208 # else, bind the project to LP
209 except KeyError:
210 project = link_project(launchpad, "No Launchpad project set")
211
212 return project
213
214133
=== renamed file 'quickly/bzrbinding.py' => 'quickly/lp/bzr.py'
--- quickly/bzrbinding.py 2010-09-28 12:53:04 +0000
+++ quickly/lp/bzr.py 2010-12-23 18:15:10 +0000
@@ -1,5 +1,5 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2009 Didier Roche2# Copyright 2009,2010 Didier Roche
3#3#
4# This file is part of Quickly4# This file is part of Quickly
5#5#
@@ -17,6 +17,7 @@
1717
18import socket18import socket
19import subprocess19import subprocess
20from quickly import configurationhandler
2021
21def bzr_set_login(display_name, preferred_email_adress, launchpad_name=None):22def bzr_set_login(display_name, preferred_email_adress, launchpad_name=None):
22 ''' try to setup bzr whoami for commit and sshing and bzr launchpad_login if provided23 ''' try to setup bzr whoami for commit and sshing and bzr launchpad_login if provided
@@ -52,3 +53,21 @@
52 53
53 return (0, "")54 return (0, "")
5455
56def set_bzrbranch(bzr_branch):
57 '''set default bzr branch from where to pull and push'''
58
59 if not configurationhandler.project_config:
60 configurationhandler.loadConfig()
61 configurationhandler.project_config['bzrbranch'] = bzr_branch
62
63def get_bzrbranch():
64 '''get default bzr branch from where to pull and push'''
65
66 if not configurationhandler.project_config:
67 configurationhandler.loadConfig()
68
69 try:
70 bzr_branch = configurationhandler.project_config['bzrbranch']
71 except KeyError:
72 bzr_branch = None
73 return bzr_branch
5574
=== renamed file 'data/templates/ubuntu-application/internal/launchpad_helper.py' => 'quickly/lp/project.py'
--- data/templates/ubuntu-application/internal/launchpad_helper.py 2010-08-13 15:04:05 +0000
+++ quickly/lp/project.py 2010-12-23 18:15:10 +0000
@@ -22,10 +22,92 @@
22import sys22import sys
23import subprocess23import subprocess
2424
25from quickly import configurationhandler
26
25import gettext27import gettext
26from gettext import gettext as _28from gettext import gettext as _
27gettext.textdomain('quickly')29gettext.textdomain('quickly')
2830
31def link_project(launchpad, question, lp_project_name=None):
32 ''' Link to launchpad project, erasing previous one if already set
33
34
35 :return project object'''
36
37 # if config not already loaded
38 if not configurationhandler.project_config:
39 configurationhandler.loadConfig()
40
41 if not lp_project_name:
42 choice = "0"
43 while choice == "0":
44
45 lp_id = raw_input("%s, leave blank to abort.\nLaunchpad project name: " % question)
46 if lp_id == "":
47 raise launchpad_project_error(_("No launchpad project given, aborting."))
48
49 prospective_projects = launchpad.projects.search(text=lp_id)
50 project_number = 1
51 project_names = []
52 for project in prospective_projects:
53 print (_('''---------------- [%s] ----------------
54 %s
55--------------------------------------
56Project name: %s
57Launchpad url: %s/%s
58%s
59''') % (project_number, project.title, project.display_name, launchpad_url, project.name, project.summary))
60 project_names.append(project.name)
61 project_number += 1
62
63 if not list(prospective_projects):
64 message = _("No project found")
65 else:
66 message = _("Choose your project number")
67 choice = raw_input("%s, leave blank to abort, 0 for another search.\nYour choice: " % message)
68
69 try:
70 choice = int(choice)
71 if choice in range(1, project_number):
72 project = launchpad.projects[project_names[choice - 1]]
73 else:
74 raise ValueError
75 except ValueError:
76 raise launchpad_project_error(_("No right number given, aborting."))
77
78 # we got a project name, check that it exists
79 else:
80 try:
81 project = launchpad.projects[lp_project_name]
82 except KeyError:
83 raise launchpad_project_error(_("Can't find %s project on Launchpad. You can try to find it interactively without providing a project name.") % lp_project_name)
84
85 configurationhandler.project_config['lp_id'] = project.name
86 configurationhandler.saveConfig()
87
88 return project
89
90def get_project(launchpad):
91 ''' Get quickly project through launchpad.
92
93 :return project object
94 '''
95
96 # if config not already loaded
97 if not configurationhandler.project_config:
98 configurationhandler.loadConfig()
99
100 # try to get project
101 try:
102 lp_id = configurationhandler.project_config['lp_id']
103 project = launchpad.projects[lp_id]
104
105 # else, bind the project to LP
106 except KeyError:
107 project = link_project(launchpad, "No Launchpad project set")
108
109 return project
110
29#TODO: see if 0 release in the project111#TODO: see if 0 release in the project
30112
31def create_release(project, version):113def create_release(project, version):
32114
=== added directory 'quickly/ubuntu'
=== added file 'quickly/ubuntu/__init__.py'
--- quickly/ubuntu/__init__.py 1970-01-01 00:00:00 +0000
+++ quickly/ubuntu/__init__.py 2010-12-23 18:15:10 +0000
@@ -0,0 +1,18 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2010 Canonical Ltd
3#
4# This file is part of Quickly
5#
6#This program is free software: you can redistribute it and/or modify it
7#under the terms of the GNU General Public License version 3, as published
8#by the Free Software Foundation.
9#
10#This program is distributed in the hope that it will be useful, but
11#WITHOUT ANY WARRANTY; without even the implied warranties of
12#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13#PURPOSE. See the GNU General Public License for more details.
14#
15#You should have received a copy of the GNU General Public License along
16#with this program. If not, see <http://www.gnu.org/licenses/>.
17
18import apport, packaging
019
=== renamed file 'data/templates/ubuntu-application/internal/apportutils.py' => 'quickly/ubuntu/apport.py'
=== renamed file 'data/templates/ubuntu-application/internal/packaging.py' => 'quickly/ubuntu/packaging.py'
--- data/templates/ubuntu-application/internal/packaging.py 2010-11-23 14:26:08 +0000
+++ quickly/ubuntu/packaging.py 2010-12-23 18:15:10 +0000
@@ -24,7 +24,7 @@
2424
2525
26from quickly import configurationhandler26from quickly import configurationhandler
27from quickly import launchpadaccess27import quickly.lp as lp
28from internal import quicklyutils28from internal import quicklyutils
29from quickly import templatetools29from quickly import templatetools
3030
@@ -229,8 +229,8 @@
229229
230 # connect to LP and get ppa to complete230 # connect to LP and get ppa to complete
231 try:231 try:
232 launchpad = launchpadaccess.initialize_lpi(False)232 launchpad = lp.access.initialize_lpi(False)
233 except launchpadaccess.launchpad_connection_error:233 except lp.access.launchpad_connection_error:
234 sys.exit(0)234 sys.exit(0)
235 available_ppas = []235 available_ppas = []
236 if launchpad:236 if launchpad:
@@ -287,13 +287,13 @@
287 (ppa_user, ppa_name) = get_ppa_parameters(launchpad, configurationhandler.project_config['ppa'])287 (ppa_user, ppa_name) = get_ppa_parameters(launchpad, configurationhandler.project_config['ppa'])
288 except KeyError:288 except KeyError:
289 ppa_user = launchpad.me289 ppa_user = launchpad.me
290 if (launchpadaccess.lp_server == "staging"):290 if (lp.access.lp_server == "staging"):
291 ppa_name = 'staging'291 ppa_name = 'staging'
292 else: # default ppa292 else: # default ppa
293 ppa_name = 'ppa'293 ppa_name = 'ppa'
294 else:294 else:
295 (ppa_user, ppa_name) = get_ppa_parameters(launchpad, ppa_name)295 (ppa_user, ppa_name) = get_ppa_parameters(launchpad, ppa_name)
296 ppa_url = '%s/~%s/+archive/%s' % (launchpadaccess.LAUNCHPAD_URL, ppa_user.name, ppa_name)296 ppa_url = '%s/~%s/+archive/%s' % (lp.access.LAUNCHPAD_URL, ppa_user.name, ppa_name)
297 dput_ppa_name = 'ppa:%s/%s' % (ppa_user.name, ppa_name)297 dput_ppa_name = 'ppa:%s/%s' % (ppa_user.name, ppa_name)
298 return (ppa_user, ppa_name, dput_ppa_name, ppa_url.encode('UTF-8'))298 return (ppa_user, ppa_name, dput_ppa_name, ppa_url.encode('UTF-8'))
299299

Subscribers

People subscribed via source and target branches