def __init__(self, calendar_timezone, calendar_location):
        gmail_account = get_account_info(configs[CONFIG_KEY_GMAIL_ACCOUNT],
                                         GMAIL_PROMPT)
        gmail_pwd = get_account_info(configs[CONFIG_KEY_GMAIL_PWD],
                                     PASSWORD_PROMPT,
                                     True)

        self.client = gdata.calendar.client.CalendarClient(
            source=GoogleCalendarProxy.app_source
        )

        try:
            info('logging in as %s' % gmail_account)
            self.client.ClientLogin(gmail_account, gmail_pwd,
                                    self.client.source)

            for calendar in self.client.GetOwnCalendarsFeed().entry:
                if calendar.summary and\
                   calendar.summary.text == configs[CONFIG_KEY_THIS_CALENDAR_SUMMARY]:
                    if configs[CONFIG_KEY_IF_THIS_CALENDAR_FOUND_THEN_PERFORM_DELETE]:
                        info('previously created calendar %s found,'
                             'deleting' % calendar.title.text)
                        self.client.Delete(calendar.GetEditLink().href)
                        self.current_calendar = self.client.InsertCalendar(
                            new_calendar=self.gen_calender(
                                configs[CONFIG_KEY_THIS_CALENDAR_TITLE],
                                configs[CONFIG_KEY_THIS_CALENDAR_SUMMARY],
                                configs[CONFIG_KEY_THIS_CALENDAR_COLOR],
                                calendar_timezone,
                                calendar_location
                            )
                        )
                    else:
                        self.current_calendar = calendar
                    break
            else:
                self.current_calendar = self.client.InsertCalendar(
                    new_calendar=self.gen_calender(
                        configs[CONFIG_KEY_THIS_CALENDAR_TITLE],
                        configs[CONFIG_KEY_THIS_CALENDAR_SUMMARY],
                        configs[CONFIG_KEY_THIS_CALENDAR_COLOR],
                        calendar_timezone,
                        calendar_location
                    )
                )
            dbg('calendar id = %s' % self.current_calendar.content.src)

        except gdata.client.RequestError as e:
            err(e)
            return
# encoding: utf-8
from mod.config import configs, CONFIG_KEY_STUDENT_ID, CONFIG_KEY_STUDENT_PWD, read_configs
from const.constants import ID_PROMPT, PASSWORD_PROMPT
from mod.fuf import get_account_info
from schools.whu import whu
from schools.whu.calender_adapter import WhuGoogleCalendarAdapter

if __name__ == '__main__':
    read_configs()
    _, courses = whu.read_courses(get_account_info(configs[CONFIG_KEY_STUDENT_ID],
                                                   ID_PROMPT),
                                  get_account_info(configs[CONFIG_KEY_STUDENT_PWD],
                                                   PASSWORD_PROMPT,
                                                   True))
    WhuGoogleCalendarAdapter(courses).do_insertion()


        for week in range(1, 21):
            schedule = {'title': u'第' + num[week] + u'周',
                        'start_date': (start_term + seven_days * (week - 1)).strftime('%Y-%m-%d'),
                        'end_date': (start_term + seven_days * week).strftime('%Y-%m-%d')}

            schedules.append(schedule)

        return schedules


    def do_insertion(self):
        for item in self.courses:
            self.proxy.insert(
                item[SCHEDULE],
                item[COURSE_NAME],
                item[TEACHER_NAME]
            )
        self.proxy.insert_day(self.week_num())


if __name__ == '__main__':
    _, courses = whu.read_courses(
        get_account_info(configs[CONFIG_KEY_STUDENT_ID],
                         ID_PROMPT),
        get_account_info(configs[CONFIG_KEY_STUDENT_PWD],
                         PASSWORD_PROMPT,
                         True)
    )
    WhuGoogleCalendarAdapter(courses).do_insertion()