def _snarf_dates_from_olprops(self, olpd): d = self._get_olprop(olpd, mt.PR_CREATION_TIME) if d: date = utils.utc_time_to_local_ts(d) self.set_created(iso8601.tostring(date)) d = self._get_olprop(olpd, mt.PR_BIRTHDAY) if d: d = utils.utc_time_to_local_ts(d, ret_dt=True) date = utils.pytime_to_yyyy_mm_dd(d) self.set_birthday(date) a = self._get_olprop(olpd, mt.PR_WEDDING_ANNIVERSARY) if a: a = utils.utc_time_to_local_ts(a, ret_dt=True) date = utils.pytime_to_yyyy_mm_dd(a) self.set_anniv(date)
def _snarf_dates_from_olprops (self, olpd): d = self._get_olprop(olpd, mt.PR_CREATION_TIME) if d: date = utils.utc_time_to_local_ts(d) self.set_created(iso8601.tostring(date)) d = self._get_olprop(olpd, mt.PR_BIRTHDAY) if d: d = utils.utc_time_to_local_ts(d, ret_dt=True) date = utils.pytime_to_yyyy_mm_dd(d) self.set_birthday(date) a = self._get_olprop(olpd, mt.PR_WEDDING_ANNIVERSARY) if a: a = utils.utc_time_to_local_ts(a, ret_dt=True) date = utils.pytime_to_yyyy_mm_dd(a) self.set_anniv(date)
def prep_sync_lists (self, destid, sl, synct_sto=None, cnt=0): """See the documentation in folder.Folder""" pname = sl.get_pname() conf = self.get_config() pdb1id = conf.get_profile_db1(pname) oldi = conf.get_itemids(pname) stag = conf.make_sync_label(pname, destid) logging.info('Querying MAPI for status of Contact Entries') ## Sort the DBIds so dest1 has the 'lower' ID dest1 = self.get_db().get_dbid() if dest1 > destid: dest2 = dest1 dest1 = destid else: dest2 = destid ctable = self.get_contents() stp = self.get_proptags().sync_tags[stag] cols = (mt.PR_ENTRYID, mt.PR_LAST_MODIFICATION_TIME, mt.PR_DISPLAY_NAME, stp) ctable.SetColumns(cols, 0) i = 0 synct_str = self.get_config().get_last_sync_start(pname) if not synct_sto: synct_sto = self.get_config().get_last_sync_stop(pname) synct = iso8601.parse(synct_sto) logging.debug('Last Start iso str : %s', synct_str) logging.debug('Last Stop iso str : %s', synct_sto) logging.debug('Current Time : %s', iso8601.tostring(time.time())) logging.info('Data obtained from MAPI. Processing...') newi = {} while True: rows = ctable.QueryRows(1, 0) #if this is the last row then stop if len(rows) != 1: break ((entryid_tag, entryid), (tt, modt), (name_tag, name), (gid_tag, gid)) = rows[0] b64_entryid = base64.b64encode(entryid) newi.update({b64_entryid : gid}) if mt.PROP_TYPE(gid_tag) == mt.PT_ERROR: # Was not synced for whatever reason. logging.debug('New Outlook Contact: %20s %s', name, b64_entryid) sl.add_new(b64_entryid) else: if mt.PROP_TYPE(tt) == mt.PT_ERROR: logging.debug('Impossible! Entry has no timestamp. i = %d', i) else: if utils.utc_time_to_local_ts(modt) <= synct: sl.add_unmod(b64_entryid) else: logging.debug('Modified Outlook Contact: %20s %s', name, b64_entryid) sl.add_mod(b64_entryid, gid) i += 1 if cnt != 0 and i >= cnt: break ctable.SetColumns(self.get_def_cols(), 0) kss = newi.keys() for x, y in oldi.iteritems(): if not x in kss and not y in kss: logging.debug('Deleted Outlook Contact: %s:%s', x, y) if pdb1id == self.get_dbid(): sl.add_del(x, y) else: sl.add_del(y,x)
def prep_sync_lists(self, destid, sl, synct_sto=None, cnt=0): """See the documentation in folder.Folder""" pname = sl.get_pname() conf = self.get_config() pdb1id = conf.get_profile_db1(pname) oldi = conf.get_itemids(pname) stag = conf.make_sync_label(pname, destid) logging.info('Querying MAPI for status of Contact Entries') ## Sort the DBIds so dest1 has the 'lower' ID dest1 = self.get_db().get_dbid() if dest1 > destid: dest2 = dest1 dest1 = destid else: dest2 = destid ctable = self.get_contents() stp = self.get_proptags().sync_tags[stag] cols = (mt.PR_ENTRYID, mt.PR_LAST_MODIFICATION_TIME, mt.PR_DISPLAY_NAME, stp) ctable.SetColumns(cols, 0) i = 0 synct_str = self.get_config().get_last_sync_start(pname) if not synct_sto: synct_sto = self.get_config().get_last_sync_stop(pname) synct = iso8601.parse(synct_sto) logging.debug('Last Start iso str : %s', synct_str) logging.debug('Last Stop iso str : %s', synct_sto) logging.debug('Current Time : %s', iso8601.tostring(time.time())) logging.info('Data obtained from MAPI. Processing...') newi = {} while True: rows = ctable.QueryRows(1, 0) #if this is the last row then stop if len(rows) != 1: break ((entryid_tag, entryid), (tt, modt), (name_tag, name), (gid_tag, gid)) = rows[0] b64_entryid = base64.b64encode(entryid) newi.update({b64_entryid: gid}) if mt.PROP_TYPE(gid_tag) == mt.PT_ERROR: # Was not synced for whatever reason. logging.debug('New Outlook Contact: %20s %s', name, b64_entryid) sl.add_new(b64_entryid) else: if mt.PROP_TYPE(tt) == mt.PT_ERROR: logging.debug('Impossible! Entry has no timestamp. i = %d', i) else: if utils.utc_time_to_local_ts(modt) <= synct: sl.add_unmod(b64_entryid) else: logging.debug('Modified Outlook Contact: %20s %s', name, b64_entryid) sl.add_mod(b64_entryid, gid) i += 1 if cnt != 0 and i >= cnt: break ctable.SetColumns(self.get_def_cols(), 0) kss = newi.keys() for x, y in oldi.iteritems(): if not x in kss and not y in kss: logging.debug('Deleted Outlook Contact: %s:%s', x, y) if pdb1id == self.get_dbid(): sl.add_del(x, y) else: sl.add_del(y, x)
def prep_sync_lists (self, destid, sl, synct_sto=None, cnt=0): """See the documentation in folder.Folder""" pname = sl.get_pname() stag = self.get_config().make_sync_label(pname, destid) logging.info('Querying MAPI for status of Contact Entries') ## Sort the DBIds so dest1 has the 'lower' ID dest1 = self.get_db().get_dbid() if dest1 > destid: dest2 = dest1 dest1 = destid else: dest2 = destid ctable = self.get_contents() ## FIXME: This needs to be fixed. The ID will be different based on ## the actual remote database, of course. stp = self.get_proptags().sync_tags[stag] cols = (mt.PR_ENTRYID, mt.PR_LAST_MODIFICATION_TIME, mt.PR_DISPLAY_NAME, stp) ctable.SetColumns(cols, 0) i = 0 pname = sl.get_pname() synct_str = self.get_config().get_last_sync_start(pname) if not synct_sto: synct_sto = self.get_config().get_last_sync_stop(pname) synct = iso8601.parse(synct_sto) logging.debug('Last Start iso str : %s', synct_str) logging.debug('Last Stop iso str : %s', synct_sto) logging.debug('Current Time : %s', iso8601.tostring(time.time())) logging.info('Data obtained from MAPI. Processing...') while True: rows = ctable.QueryRows(1, 0) #if this is the last row then stop if len(rows) != 1: break ((entryid_tag, entryid), (tt, modt), (name_tag, name), (gid_tag, gid)) = rows[0] b64_entryid = base64.b64encode(entryid) sl.add_entry(b64_entryid, gid) if mt.PROP_TYPE(gid_tag) == mt.PT_ERROR: # Was not synced for whatever reason. sl.add_new(b64_entryid) else: if mt.PROP_TYPE(tt) == mt.PT_ERROR: logging.debug('Impossible! Entry has no timestamp. i = %d', i) else: if utils.utc_time_to_local_ts(modt) <= synct: sl.add_unmod(b64_entryid) else: sl.add_mod(b64_entryid, gid) i += 1 if cnt != 0 and i >= cnt: break ctable.SetColumns(self.get_def_cols(), 0)