Skip to content

Instantly share code, notes, and snippets.

@hallamoore
Created April 5, 2018 19:36
Show Gist options
  • Select an option

  • Save hallamoore/71daa58c0e82bc6b1573ea12fd3a587e to your computer and use it in GitHub Desktop.

Select an option

Save hallamoore/71daa58c0e82bc6b1573ea12fd3a587e to your computer and use it in GitHub Desktop.
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