Debian Codegraph @

bin/lp-project

raw
1 #!/usr/bin/python3
2 #
3 # Author: Robert Collins <[email protected]>
4 #
5 # Copyright 2010 Canonical Ltd.
6 #
7 # This program is free software: you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License version 3, as published
9 # by the Free Software Foundation.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranties of
13 # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14 # PURPOSE. See the GNU General Public License for more details.
15 #
16 # 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/>.
18
19 """lp-project -- An lptools command to work with projects in Launchpad.
20 https://launchpad.net/lptools/
21
22 lp-project help commands -- list commands
23 """
24
25 import os
26
27 # Might want to make errors import lazy.
28 from breezy import controldir
29
30 from lptools.command import *
31
32
33 class cmd_create(LaunchpadCommand):
34 """Create a project.
35
36 This creates two teams - a management/committer team owner by you and
37 a -dev mailing list owned by the mgmt team. It then creates the project,
38 makes it owned by the committer team, creates a new empty bzr branch for
39 trunk and then fires up a web browser pointing at the project for you to
40 fine tune.
41
42 After running this command you need to:
43 - set what LP features you are using
44 (https://bugs.launchpad.net/launchpad/+bug/537269)
45 - describe your project (title, summary, description)
46 - upload your code to lp:PROJECT
47 - turn on the mailing list by hand
48 (https://bugs.launchpad.net/launchpad/+bug/537258)
49
50 lp-project create projectname
51 """
52
53 takes_args = ['project']
54
55 def run(self, project):
56 self.outf.write('creating project %s\n' % project)
57 # load the lp plugin - we needs it, but don't want its commands shown.
58 from breezy.plugins import launchpad
59 project_d = {'project':project}
60 mgmt = self.launchpad.people.newTeam(
61 display_name='%s committers' % project, name=project,
62 subscription_policy='Moderated Team', team_description="This is the"
63 " %(project)s project maintainers and committers team. Membership "
64 "in this team grants commit access to the %(project)s trunk and "
65 "release branches, and owner access to the project. To become a "
66 "member of this team, please contact the project via the "
67 "%(project)s-dev mailing list." % {'project':project})
68 dev = self.launchpad.people.newTeam(
69 display_name='%s mailing list' % project, name='%s-dev' % project,
70 subscription_policy='Open Team', team_description="This is the"
71 " %(project)s (https://launchpad.net/%(project)s) development "
72 "discussion mailing list. To subscribe to the list join this team "
73 "(it does not receive bug mail or other such dross)." % project_d)
74 dev.team_owner = mgmt
75 dev.lp_save()
76 proj = self.launchpad.projects.new_project(
77 display_name=project,
78 name=project,
79 registrant=mgmt,
80 title="Put what you want to show in browser window titles for %s "
81 "here" % project,
82 description="""Put a long description of the %(project)s project here.
83
84 A mailing list for discussion, usage and development is at https://launchpad.net/~%(project)s-dev - all are welcome to join. Some folk hang out on #%(project)s on irc.freenode.net.
85 """ % project_d,
86 home_page_url="https://launchpad.net/%s" % project,
87 summary="Put a pithy summary of %s here." % project,
88 )
89 proj.bug_reporting_guidelines = """Enough data to reproduce the behaviour if possible.
90
91 If that is not possible, just describe as well as you can what is happening and we will talk through the issue with you.
92 """
93 proj.owner = mgmt
94 proj.lp_save()
95 branch_path = '~%(project)s/%(project)s/trunk' % project_d
96 lp_host = os.environ.get('LAUNCHPAD_API', '')
97 if lp_host:
98 lp_host = '//%s/' % lp_host
99 branch = controldir.ControlDir.create_branch_convenience(
100 'lp:%s%s' % (lp_host, branch_path), force_new_tree=False)
101 series = proj.getSeries(name='trunk')
102 series.branch_link = self.launchpad.load(branch_path)
103 series.lp_save()
104 self.outf.write("""
105 Project created at %s (sorry about the url. (https://bugs.launchpad.net/launchpadlib/+bug/316694)).
106 You now need to:
107 - set what LP features you are using
108 (https://bugs.launchpad.net/launchpad/+bug/537269)
109 - describe your project (title, summary, description)
110 - upload your code to lp:PROJECT
111 - turn on the mailing list by hand
112 (https://bugs.launchpad.net/launchpad/+bug/537258)
113 """ % proj.self_link)
114
115
116 if __name__ == "__main__":
117 main()