~jelmer/lp-dev-utils/loc-contributions-author

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/usr/bin/python

from lpscripts import LaunchpadAPIScript


class DisableProject(LaunchpadAPIScript):
    """Disable a project and notify the owner.

    If the project is owned by a team we assume it is advanced enough to stay
    around.
    """

    SUBJECT = "Your project in Launchpad (%(project_name)s)"

    MSG_TEMPLATES = [
        # Standard disable message.
        """\
Hello %(owner_display_name)s,

RE: %(project_url)s

You registered the project '%(project_name)s' in Launchpad.  I cannot figure
out if the project is an active open source project. I've disabled it for now,
but let me know if you think it should be reactivated and I'll reconsider.

If you would like to test Launchpad, please use our test server at:

   https://staging.launchpad.net/

If you would like to translate a specific project into your language,
please request more information at:

   https://answers.launchpad.net/rosetta

If you just want a place to host your code, you can push branches to the
+junk area without needing a project:

    https://help.launchpad.net/NonProjectBranches
    http://doc.bazaar-vcs.org/latest/en/mini-tutorial/index.html

If you are looking to create a team, note that teams are created at:

   https://launchpad.net/people/+newteam

If you are looking for Ubuntu CDs, please request at:

   https://shipit.ubuntu.com/

If you need help with Ubuntu please see the following links:

   https://help.ubuntu.com/
   https://answers.launchpad.net/ubuntu

If you have questions about Launchpad, please see the following links:

   https://launchpad.net/+tour
   https://help.launchpad.net/

Thanks,

%(me)s
Canonical, Ltd.
""",
        # 1: Suspending project due to lack of reply.
        """\
Hello %(owner_display_name)s,

RE: %(project_url)s

Previously you were contacted regarding the project '%(project_name)s' which
is registered in Launchpad and has you listed as the maintainer.  We requested
additional information from you regarding the project but that has not been
forthcoming.  Therefore I am suspending the project.

If you would like to continue using Launchpad for this project, I'll be happy
to reconsider this action if you will contact me directly via email.

Thanks,

%(me)s
Canonical, Ltd.
""",
        # 2: Translation only project.
        """\
Hello %(owner_display_name)s,

RE: %(project_url)s

You registered the project '%(project_name)s' in Launchpad.
This project's sole purpose seems to be to translate a piece of software into
a single specfic language. I am sorry to have to tell you that we do not
accept such projects into Launchpad. Your project has been disabled.

Instead we ask you to contact the software's maintainers to coordinate your
translation effort with theirs. If they do not have a plattform for
translating their software yet you might well suggest that they use
Launchpad for this. Encourage them to set up a project entry in Launchpad
which can then be used to translate that software into any language.

If the project already exists in Launchpad and you are having trouble
participating or contacting the maintainers, then please feel free to
contact us for help to resolve the issue.

Thanks,

%(me)s
Canonical, Ltd.
""",
        # 3: Disabling proprietary project that has not renewed.
        """\
Hello %(owner_display_name)s,

RE: %(project_url)s

You are the owner of the project '%(project_name)s' in Launchpad, which is
proprietary and previously had a commercial-use subscription.  Your
subscription has expired and you have not renewed your subscription.

I am disabling your project.  None of your data will be lost but you'll be
unable to access your project unless you renew your subscription.

Please contact me and I'll be happy to help you get your project re-activated.

Best,

%(me)s
Canonical, Ltd.
""",
]


    WHITEBOARD_MESSAGE = """\
%(today)s %(me)s: Project disabled and %(owner_display_name)s \
(%(owner_name)s) notified."""

    def addParserOptions(self):
        """Add additional parse options."""
        super(DisableProject, self).addParserOptions()

        self.parser.add_option(
            '--force',
            action='store_true', default=False, dest='force',
            help="""\
Force the project to be disabled, even if owned by a team.""")

        self.parser.add_option(
            '--msg-num',
            type="int", default=0, dest='msg_num',
            help="""\
Index of message template to use.  Default is 0.""")

    def process_project(self, proj):
        """Disable the project."""

        print "Disabling", proj.name, "...",

        self.MSG_TEMPLATE = self.MSG_TEMPLATES[self.opts.msg_num]

        if proj.active:
            owner = proj.owner
            if owner.is_team:
                if self.opts.force:
                    owner = owner.team_owner
                else:
                    print ("ah, it is owned by a team, skipping.  Use --force "
                           "to disable anyway.")
                    return
            try:
                self.send_email(proj, owner)
            except:
                pass
            proj.active = False
            proj.project_reviewed = True
            proj.lp_save()
            self.update_whiteboard(proj, owner)
        else:
            print "was already disabled, skipping."

    def __init__(self, name=None, lp=None, args=None, opts=None):
        super(DisableProject, self).__init__(name, lp, args, opts)
        # Awful hack to get default values of options if invoked
        # via import and not run as a program.
        if not hasattr(self.opts, 'msg_num'):
            self.opts.msg_num = 0


if __name__ == "__main__":

    script = DisableProject()
    script.run()