Created
December 19, 2013 01:32
-
-
Save lost-theory/8032849 to your computer and use it in GitHub Desktop.
how to show the name of the person on-call right now for a pagerduty schedule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygerduty | |
from datetime import datetime as dt, timedelta as d | |
p = pygerduty.PagerDuty("user-goes-here", "api-key-goes-here") | |
sched = p.schedules.show('SCHEDULEID') | |
t0 = dt.now() | |
t1 = t0 + d(minutes=1) | |
result = sched.entries.list(since=t0.strftime("%F %T"), until=t1.strftime("%F %T")) | |
print result[0].user.name if result else "nobody?" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment