# print(title) # print(start, duration) # if attendees: # for attendee in attendees: # print(attendee) # print(e) # print(component) # print(80 * "-") return events if __name__ == "__main__": filename = sys.argv.pop() events = load_events(filename) print(f"Loaded {len(events)} events") aw = ActivityWatchClient(testing=True) bucket_name = 'ical-import' if bucket_name in aw.get_buckets(): aw.delete_bucket(bucket_name) aw.create_bucket(bucket_name, 'calendar') aw.insert_events(bucket_name, events) """ Basic query: events = query_bucket(find_bucket('ical-import')); RETURN = filter_keyvals_regex(events, 'title', '\<\>')); """
duration = end_time - start_time event = Event(timestamp=start_time.isoformat(), duration=duration, data=datastr) events_to_insert.append(event) return events_to_insert if __name__ == "__main__": captured_events = capture_events() events_to_insert = interpret_events(captured_events) if events_to_insert: aw = ActivityWatchClient(testing=True) bucket_name = "aw-calendar-import" try: aw.delete_bucket(bucket_name) except Exception: print("Bucket doesn't exist") try: aw.create_bucket(bucket_name, "calendar") aw.insert_events(bucket_name, events_to_insert) except Exception: print("something went wrong") if os.path.exists("token.txt"): os.remove("token.txt")