Beispiel #1
0
def main():
    try:
        #parse the commandline
        myoptions = Cli(MyOptions).parseArguments()
    except CliHelpError as helpError:
        print helpError
        return 0

    #weather functions
    get_weather(myoptions.getweather_location(), myoptions.getmetric_unit())

    #create flags for Google Services
    flags = Flags.Flags(myoptions.getauth_host_name(),
                        myoptions.getauth_host_port(),
                        myoptions.isnoauth_local_webserver(),
                        myoptions.getlogging_level())

    #Create google services object. This get carried around for google api functions.
    google_services = GoogleServices.GoogleServices(myoptions.getclient_secret(), flags)

    try:
        #connect, auth and return a connected service object
        google_services = google_services.startgoogleservices()
    except AccessTokenRefreshError:
        print("The credentials have been revoked or expired, please re-run the application to re-authorize")
        return 0

    #returns a selected calendar - either from one stored in user file or return an option
    select_calendar = CalendarSelection.calendarlisting(google_services)
    calendarid = select_calendar.return_calendar_id()


    EventListing.event_listing(google_services, calendarid)

    #start twisted event loop for fetching weather data.
    reactor.run()