def process_python_students(): errors = [] api = SpreadsheetAPI(env('GOOGLE_APPS_USERNAME'), env('GOOGLE_APPS_PASSWORD'), 'thinkful.com') sheet = api.get_worksheet(PYTHON_SPREADSHEET_KEY, 'od6') emails = map(lambda row: row['email'], sheet.get_rows()) with crm_connection() as crm: for email in emails: with collect_error(errors): contact = match_email_to_contact(row['email'], crm) add_python_potential_to_contact(contact, email) print '<%s>' % '<\n>'.join(errors)
def enroll(): ag = request.args USERNAME = '******' PASSWORD = '******' SOURCE = 'thinkful.com' api = SpreadsheetAPI(env(GOOGLE_USERNAME), env(GOOGLE_PASSWORD), env(GOOGLE_SOURCE)) spreadsheets = api.list_spreadsheets() sheet = api.get_worksheet(spreadsheets[0][1], 'od6') rows = sheet.get_rows() row = dict(zip(map(lambda x: ag[x][0], ag), ag)) sheet.insert_row(row) cio = get_cio()
def main(): gc = SimpleGCal(env('GOOGLE_SCHEDULE_CALL_USERNAME'), env('GOOGLE_SCHEDULE_CALL_PASSWORD')) def demo_get_all_cals(): name, cals = gc.get_all_calendars() print "Calendars in account '%s'" % name for cal in cals: print "\t", cal.title.text def demo_get_events(): start_date = datetime(2013,9,23,9) end_date = datetime(2013,9,24) events = gc.get_events(start_date, end_date) print "Events from %s - %s" % (start_date, end_date) for i, an_event in zip(xrange(len(events)), events): print '\t%s. %s' % (i+1, an_event.title.text,) for a_when in an_event.when: print '\t\tStart time: %s' % (a_when.start,) print '\t\tEnd time: %s' % (a_when.end,) demo_get_all_cals() print "" demo_get_events()
def check_auth(username, password): """This function is called to check if a username / password combination is valid. """ return username == env('ADMIN_AUTH_USERNAME') and password == env('ADMIN_AUTH_PASSWORD')
def dump_fixtures_redis_get(prefix): for key in conn.keys(): if key.startswith(prefix): fn = join(env('FIXTURE_ROOT'), 'redis', key) with open(fn, 'w') as fh: fh.write(conn.get(key))
def decorated(*args, **kwargs): if env('HOSTNAME') == 'localhost:5000': fn = join(env('FIXTURE_ROOT'), db, args[0]) with open(fn, 'r') as fh: return fh.read() return f(*args, **kwargs)