unpickle = True

gdm_querent = gdm.querent.Querent(
    api_key=settings.GOOGLE_DISTANCE_MATRIX_API_KEY)
gdm_querent.set_travel_mode(querent.TravelMode.TRANSIT)

if not unpickle:
    # create new planner object and pickle it
    p = Planner()

    p.set_home("Str d Pariser Kommune 30")
    p.set_planning_times(globals.to_minutes(8, 0), globals.to_minutes(20, 0))
    p.set_max_events(8)

    p.import_ics("marc_uni.ics")

    pickle.dump(p,
                open("planner_pickle.pkl", "wb"),
                protocol=pickle.HIGHEST_PROTOCOL)
else:
    # try to load an existing pickled planner object
    try:
        p = pickle.load(open("planner_pickle.pkl", "rb"))
    except FileNotFoundError:
        logging.error("Test Planner Pickle: Restore File or Folder not found.")
        exit()

print(p)

print("Used GDM-API - Calls: " + str(gdm_querent.get_api_count()))
Beispiel #2
0
from planner.plannertoimage import PlannerToImage
from planner.planner import Planner

import globals

from datetime import datetime as dt

if __name__ == "__main__":
    planner = Planner()

    planner.set_home("Str d Pariser Kommune 30")
    planner.set_planning_times(
        globals.to_minutes(8, 0),
        globals.to_minutes(20, 0)
    )
    planner.set_max_events(8)

    planner.import_ics('import_planner_draw.ics')
    #planner.import_ics('exported_calendar.ics')
    print(planner)

    PlannerToImage(planner, dt.today()).draw_image('test_image.png')
    #PlannerToImage(planner, dt(2019,4,11)).draw_image('test_image.png')