Skip to content

Commit

Permalink
Add the sheriff rooster and its dependencies
Browse files Browse the repository at this point in the history
For the moment it can only fetch the list of users and the number of days they have been the sheriff
  • Loading branch information
paraita committed Jan 5, 2017
1 parent 221e5e9 commit 7e2cbfd
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
34 changes: 34 additions & 0 deletions billybob/sheriff_rooster.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import gspread
import os
from oauth2client.service_account import ServiceAccountCredentials


class SheriffRooster:

def __init__(self, keyfile=None, **kargs):
if keyfile is None:
self.keyfile = os.environ['GOOGLE_KEYFILE']
else:
self.keyfile = keyfile
self.worksheet_name = 'ActiveEon Sheriff Roster'
self.spreadsheet_name = 'Sheet1'
if 'WORKSHEET_NAME' in kargs:
self.worksheet_name = kargs['WORKSHEET_NAME']
if 'SPREADSHEET_NAME' in kargs:
self.spreadsheet_name = kargs['SPREADSHEET_NAME']
scope = ['https://spreadsheets.google.com/feeds']
self.credentials = ServiceAccountCredentials.from_json_keyfile_name(self.keyfile,
scope)
gc = gspread.authorize(self.credentials)
self.sheet = gc.open(self.worksheet_name).worksheet(self.spreadsheet_name)

def get_users(self):
users = []
users_name = [n for n in self.sheet.col_values('2') if n != '']
for name in users_name:
cell_name = self.sheet.find(name)
cell_days = self.sheet.cell(cell_name.row, cell_name.col+1)
users.append({'name': cell_name.value, 'days': int(cell_days.value)})
return users
13 changes: 13 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
backports.ssl-match-hostname==3.5.0.1
beautifulsoup4==4.5.1
cffi==1.9.1
coverage==4.2
coveralls==1.1
cryptography==1.7.1
docopt==0.6.2
enum34==1.1.6
funcsigs==1.0.2
gspread==0.6.2
httplib2==0.9.2
idna==2.2
ipaddress==1.0.17
mock==2.0.0
nose==1.3.7
oauth2client==4.0.0
pbr==1.10.0
pyasn1==0.1.9
pyasn1-modules==0.0.8
pycparser==2.17
pyOpenSSL==16.2.0
python-dateutil==2.6.0
requests==2.12.4
rsa==3.4.2
simplejson==3.10.0
six==1.10.0
slackclient==1.0.4
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
'slackclient',
'wit',
'python-dateutil',
'sophiabus230'
'sophiabus230',
'oauth2client',
'gspread',
'PyOpenSSL'
],
test_suite='nose.collector',
tests_require=[
Expand Down

0 comments on commit 7e2cbfd

Please sign in to comment.