Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Script that inform Github users of removal of a Github team. Modify for your organization and copy-paste the generated text into your favourite mail client!
# -*- coding: utf-8 -*-
import requests
import os
import pprint
def request(url):
return requests.get(url, auth=('JensRantil', os.environ['APIKEY']), headers={"Accept": "application/vnd.github.hellcat-preview+json"})
teams = dict([(e['id'], e['name']) for e in request('').json()])
team = raw_input('Which team id to remove? ')
team = int(team)
repos = request('{}/repos'.format(team)).json()
repos = [" * " + repo['full_name'] for repo in repos]
repos = "\n".join(repos)
members = request('{}/members'.format(team)).json()
members = [request(e['url']).json() for e in members]
members = [(e['name'], e['email'], e['login']) for e in members]
def email(e):
if e[1]:
return e[1]
proposal = e[0].lower().replace(' ', '.') + "" if e[0] else e[2]
q = 'What is e-mail for "{}"? [{}] '.format(e[0], proposal)
a = raw_input(q).strip()
a = None
if not a:
return proposal
return a
members = [email(m) for m in members]
print "Recipients:", ", ".join(members)
print "Subject: Changes to tink-ab Github permissions"
print """Hello,
This is an automated e-mail.
I am writing to you to let you know that I might have removed write access to the following repositories:
If you believe you have lost the access, please request the permission from your team lead.
Jens Rantil, Github admin at Tink""".format(repos)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.