Skip to content

Instantly share code, notes, and snippets.

@uggedal
Created March 5, 2019 12:22
Show Gist options
  • Save uggedal/0d7944af0960ccd74bae82a57f8f17d6 to your computer and use it in GitHub Desktop.
Save uggedal/0d7944af0960ccd74bae82a57f8f17d6 to your computer and use it in GitHub Desktop.
Find inactive atlassian cloud users
#!/usr/bin/env python
import re
import sys
import csv
import datetime
now = datetime.datetime.now()
def dt(s):
if s == 'Never logged in':
return datetime.datetime.utcfromtimestamp(0)
if s == 'Not active in the last 180 days':
return now - datetime.timedelta(days=180)
return datetime.datetime.strptime(s, '%d %b %Y')
users = []
with open('export-users.csv') as f:
cr = csv.reader(f)
next(cr, None) # skip header
for r in cr:
users.append(dict(
email=r[2],
conf=dt(r[5]),
jira=dt(r[7]),
))
period = datetime.timedelta(days=int(sys.argv[1]))
for u in users:
cdelta = now - u['conf']
jdelta = now - u['jira']
if cdelta > period and jdelta > period:
print u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment