示例#1
0
    def test_fields_in_props (self, itemid):
        """Check if the the properties returned by a default search
        include all the fields that the user has requested for through
        the fields.json file. This is intended to be used for
        development and debugging purposes."""

        if not itemid:
            itemid = self.get_itemid()

        con = OLContact(self.deff, eid=base64.b64decode(itemid))

        print 'Con: \n', con

        props  = dict(con.get_olprops_from_mapi()) # later to try get_olprops_from_mapi
        fields = con.get_sync_fields()
        pt     = self.deff.get_proptags()

        logging.debug('Type of props        : %s', type(props))
        logging.debug('Num props in props   : %d', len(props))
        logging.debug('Num fields in fields : %d', len(fields))

        for tag in props:
            props[tag]= True

        for field in fields:
            if not field in props.keys():
                logging.debug('Property %35s (0x%x) not in Props.',
                             pt.name(field), field)
            else:
                logging.debug('Property %35s (0x%x)     in Props.',
                              pt.name(field), field)
示例#2
0
    def test_fields_in_props(self, itemid):
        """Check if the the properties returned by a default search
        include all the fields that the user has requested for through
        the fields.json file. This is intended to be used for
        development and debugging purposes."""

        if not itemid:
            itemid = self.get_itemid()

        con = OLContact(self.deff, eid=base64.b64decode(itemid))

        print 'Con: \n', con

        props = dict(
            con.get_olprops_from_mapi())  # later to try get_olprops_from_mapi
        fields = con.get_sync_fields()
        pt = self.deff.get_proptags()

        logging.debug('Type of props        : %s', type(props))
        logging.debug('Num props in props   : %d', len(props))
        logging.debug('Num fields in fields : %d', len(fields))

        for tag in props:
            props[tag] = True

        for field in fields:
            if not field in props.keys():
                logging.debug('Property %35s (0x%x) not in Props.',
                              pt.name(field), field)
            else:
                logging.debug('Property %35s (0x%x)     in Props.',
                              pt.name(field), field)
示例#3
0
    def batch_create(self, sync_list, src_dbid, items):
        """See the documentation in folder.Folder"""

        my_dbid = self.get_dbid()
        c = self.get_config()
        pname = sync_list.get_pname()

        src_sync_tag = c.make_sync_label(pname, src_dbid)
        dst_sync_tag = c.make_sync_label(pname, my_dbid)

        success = True
        for item in items:
            olc = OLContact(self, con=item)
            rid = item.get_itemid()
            olc.update_sync_tags(src_sync_tag, rid)

            ## FIXME: I strongly suspect this is not the most efficient way to
            ## do this. We should test by importing items in bulk into
            ## Outlook and measure performance, and fix this if needed.

            try:
                eid = olc.save()
                logging.info(
                    'Successfully created outlook entry for %30s (%s)',
                    olc.get_disp_name(), olc.get_itemid())
            except Exception, e:
                logging.error('Could not save contact (%s) due to: %s',
                              olc.get_disp_name(), str(e))
                logging.debug('Contact Entry: %s', olc)
                logging.debug(traceback.format_exc())
                success = False
                continue

            iid = olc.get_itemid()
            item.update_sync_tags(dst_sync_tag, iid)
示例#4
0
    def batch_create (self, sync_list, src_dbid, items):
        """See the documentation in folder.Folder"""

        my_dbid = self.get_dbid()
        c       = self.get_config()
        pname   = sync_list.get_pname()

        src_sync_tag = c.make_sync_label(pname, src_dbid)
        dst_sync_tag = c.make_sync_label(pname, my_dbid)

        success = True
        for item in items:
            olc = OLContact(self, con=item)
            rid = item.get_itemid()
            olc.update_sync_tags(src_sync_tag, rid)

            ## FIXME: I strongly suspect this is not the most efficient way to
            ## do this. We should test by importing items in bulk into
            ## Outlook and measure performance, and fix this if needed.

            try:
                eid = olc.save()
                logging.info('Successfully created outlook entry for %30s (%s)',
                             olc.get_disp_name(), olc.get_itemid())
            except Exception, e:
                logging.error('Could not save contact (%s) due to: %s',
                              olc.get_disp_name(), str(e))
                logging.debug('Contact Entry: %s', olc)
                logging.debug(traceback.format_exc())
                success = False
                continue

            iid = olc.get_itemid()
            item.update_sync_tags(dst_sync_tag, iid)
示例#5
0
文件: folder_ol.py 项目: brehm/ASynK
    def batch_update (self, sync_list, src_dbid, items):
        """See the documentation in folder.Folder"""

        pname   = sync_list.get_pname()
        src_tag = self.get_config().make_sync_label(pname, src_dbid)

        store = self.get_msgstore().get_obj()
        success = True
        for item in items:
            olc = OLContact(self, con=item)

            ## We lose the sync tag as well when we blow everything. To ensure
            ## this gets recreated, put it back in.

            olc.update_sync_tags(src_tag, item.get_itemid())
            olprops = olc.get_olprops()
            oli     = olc.get_olitem()

            ## Wipe out the sucker
            try:
                def_cols = oli.GetPropList(mapi.MAPI_UNICODE)
                print def_cols
                hr, ps = oli.DeleteProps(def_cols)
            except Exception, e:
                logging.error('%s: Could not clear our MAPI props for: %s (%s)',
                              'gc:batch_update()', item.get_name(), e)
                logging.debug(traceback.format_exc())
                success = False
                continue

            ## Now shove the new property set in
            try:
                hr, ps = oli.SetProps(olprops)
                oli.SaveChanges(mapi.KEEP_OPEN_READWRITE)
                logging.info('Successfully updated changes to Outlook for %s',
                             item.get_name())
            except Exception, e:
                logging.error('%s: Could not set new props set for: %s (%s)',
                              'gc:batch_update()', item.get_name(), e)
                success = False
                continue
示例#6
0
    def batch_update(self, sync_list, src_dbid, items):
        """See the documentation in folder.Folder"""

        pname = sync_list.get_pname()
        src_tag = self.get_config().make_sync_label(pname, src_dbid)

        store = self.get_msgstore().get_obj()
        success = True
        for item in items:
            con_itemid = item.get_itemid_from_synctags(pname, 'ol')
            olc = OLContact(self, con=item, con_itemid=con_itemid)

            ## We lose the sync tag as well when we blow everything. To ensure
            ## this gets recreated, put it back in.

            olc.update_sync_tags(src_tag, item.get_itemid())
            olprops = olc.get_olprops()
            oli = olc.get_olitem()

            ## Wipe out the sucker
            try:
                def_cols = oli.GetPropList(mapi.MAPI_UNICODE)
                hr, ps = oli.DeleteProps(def_cols)
            except Exception, e:
                logging.error(
                    '%s: Could not clear our MAPI props for: %s (%s)',
                    'ol:batch_update()', item.get_name(), e)
                logging.debug(traceback.format_exc())
                success = False
                continue

            ## Now shove the new property set in
            try:
                hr, ps = oli.SetProps(olprops)
                oli.SaveChanges(mapi.KEEP_OPEN_READWRITE)
                logging.info('Successfully updated changes to Outlook for %s',
                             item.get_disp_name())
            except Exception, e:
                logging.error('%s: Could not set new props set for: %s (%s)',
                              'ol:batch_update()', item.get_disp_name(), e)
                success = False
                continue
示例#7
0
 def test_new_contact(self):
     c = OLContact(self.deff)
     c.set_name('Supeman')
     c.set_gender('Male')
     c.set_notes('This is a second test contact')
     c.save()
示例#8
0
 def print_contact(self, itemid):
     eid = base64.b64decode(itemid)
     c = OLContact(self.deff, eid=eid)
     logging.debug('Contact: \n%s', str(c))
示例#9
0
 def find_items(self, iids):
     return [OLContact(self, eid=base64.b64decode(iid)) for iid in iids]
示例#10
0
 def find_item(self, itemid):
     eid = base64.b64decode(itemid)
     olc = OLContact(self, eid=eid)
     return olc
示例#11
0
 def test_new_contact (self):
     c = OLContact(self.deff)
     c.set_name('Supeman')
     c.set_gender('Male')
     c.set_notes('This is a second test contact')
     c.save()
 def test_new_contact(self):
     c = OLContact(self.deff)
     c.set_name("Supeman")
     c.set_gender("Male")
     c.set_notes("This is a second test contact")
     c.save()