-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloaks-add.py
More file actions
executable file
·48 lines (36 loc) · 1.46 KB
/
cloaks-add.py
File metadata and controls
executable file
·48 lines (36 loc) · 1.46 KB
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
from optparse import OptionParser
team = "ubuntu-irc-cloaks" # default team
comment = "IRC cloak set" # default comment
usage = 'Usage: %prog [options] [user] ...'
description = 'Add members to a team.'
parser = OptionParser(usage=usage, description=description, add_help_option=False)
parser.add_option('-t', '--team', default=team, help='Specify team.')
parser.add_option('-f', '--file', help='Specify file.')
parser.add_option('-c', '--comment', default=comment, help='Specify comment.')
parser.add_option('-h', '--help', action='help', help='Print this help text.')
opts, args = parser.parse_args()
cachedir = "~/.cache/launchpadlib"
from launchpadlib.launchpad import Launchpad
from launchpadlib.errors import HTTPError
launchpad = Launchpad.login_with('Ubuntu IRC Cloaks Script', 'production',
cachedir, version='devel')
lp_root_uri = str(launchpad._root_uri)
if args:
users = set(args)
elif opts.file:
with open(opts.file) as file:
users = set(file.read().split())
else:
users = set(sys.stdin.read().split())
if not users:
sys.exit()
team = launchpad.people[opts.team]
print("=== {} ===".format(opts.team))
for user in users:
if user != 'ubuntu-irc-council':
status = team.addMember(person='%s~%s' % (lp_root_uri, user),
status='Approved', comment=opts.comment or None)[1]
print(" * %s: %s (%s)" % (status, user, opts.comment))