Created
April 5, 2018 19:36
-
-
Save hallamoore/71daa58c0e82bc6b1573ea12fd3a587e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from nylas.db.sharded.models.account import Account | |
| from nylas.db.sharded.models.session import session_scope_by_shard_id | |
| from nylas.sync.adaptors.ews import EWSSyncAdaptor | |
| from nylas.sync.types.ews import EWSResponseShape | |
| with session_scope_by_shard_id(0) as db: | |
| acc = db.query(Account).get(4) # exchange account, test@nilas.com | |
| adaptor = EWSSyncAdaptor(acc) | |
| adaptor.authorize_account() | |
| state = None | |
| while True: | |
| print(state) | |
| print('') | |
| item_change_collection_generator = adaptor.sync_folder_items( | |
| adaptor._exlib_account.calendar.folder_id, | |
| EWSResponseShape.AllProperties, | |
| state, | |
| max_changes=1) | |
| has_changes = False | |
| for change in item_change_collection_generator: | |
| if isinstance(change, str): | |
| state = change | |
| break | |
| else: | |
| has_changes = True | |
| if not has_changes: | |
| state = None # start over, re-sync forever |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment