示例#1
0
    def __init__(self):
        logging.debug('Getting started... Reading Config File...')

        self.config = Config('../config.json', '../state.json')
        self.ol = OLPIMDB(self.config)
        self.deff = self.ol.get_def_folder()

        print "\nHurrah: Name is: ", self.deff.get_name()
示例#2
0
    def __init__ (self):
        logging.debug('Getting started... Reading Config File...')

        self.config = Config('../config.json', '../state.json')
        self.ol     = OLPIMDB(self.config)
        self.deff   = self.ol.get_def_folder()

        print "\nHurrah: Name is: ", self.deff.get_name()
示例#3
0
 def login_ol(self):
     return OLPIMDB(self.get_config())
示例#4
0
class TestOLContact:
    def __init__(self):
        logging.debug('Getting started... Reading Config File...')

        self.config = Config('../config.json', '../state.json')
        self.ol = OLPIMDB(self.config)
        self.deff = self.ol.get_def_folder()

        print "\nHurrah: Name is: ", self.deff.get_name()

    def print_contact(self, itemid):
        eid = base64.b64decode(itemid)
        c = OLContact(self.deff, eid=eid)
        logging.debug('Contact: \n%s', str(c))

    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_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)

    def test_read_custom_props(self, itemid):
        eid = base64.b64decode(itemid)
        olcf = self.deff

        prop_tag = olcf.get_proptags().get_custom_prop_tag()
        store = olcf.get_msgstore()
        item = store.get_obj().OpenEntry(eid, None, mapi.MAPI_BEST_ACCESS)

        hr, props = item.GetProps([prop_tag], mapi.MAPI_UNICODE)
        (tag, val) = props[0]
        if mt.PROP_TYPE(tag) == mt.PT_ERROR:
            print 'Prop_Tag (0x%16x) not found. Tag: 0x%16x' % (prop_tag,
                                                                (tag %
                                                                 (2**64)))
        else:
            print 'Hurrah! Custom found: ', val

    def test_read_emails(self, itemid):
        eid = base64.b64decode(itemid)
        olcf = self.deff

        prop_tag = olcf.get_proptags().valu('ASYNK_PR_EMAIL_1')
        store = olcf.get_msgstore()
        item = store.get_obj().OpenEntry(eid, None, mapi.MAPI_BEST_ACCESS)

        hr, props = item.GetProps([prop_tag], mapi.MAPI_UNICODE)
        (tag, val) = props[0]
        if mt.PROP_TYPE(tag) == mt.PT_ERROR:
            print 'Prop_Tag (0x%16x) not found. Tag: 0x%16x' % (prop_tag,
                                                                (tag %
                                                                 (2**64)))
        else:
            print 'Email address found: ', val

    def test_sync_status(self):
        sl = SyncLists(self.deff, 'gc')
        self.deff.prep_sync_lists('gc', sl)
示例#5
0
class TestOLContact:
    def __init__ (self):
        logging.debug('Getting started... Reading Config File...')

        self.config = Config('../config.json', '../state.json')
        self.ol     = OLPIMDB(self.config)
        self.deff   = self.ol.get_def_folder()

        print "\nHurrah: Name is: ", self.deff.get_name()

    def print_contact (self, itemid):
        eid = base64.b64decode(itemid)
        c = OLContact(self.deff, eid=eid)
        logging.debug('Contact: \n%s', str(c))        

    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_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)

    def test_read_custom_props (self, itemid):
        eid = base64.b64decode(itemid)
        olcf = self.deff
        
        prop_tag = olcf.get_proptags().get_custom_prop_tag()
        store    = olcf.get_msgstore()
        item     = store.get_obj().OpenEntry(eid, None, mapi.MAPI_BEST_ACCESS)

        hr, props = item.GetProps([prop_tag], mapi.MAPI_UNICODE)
        (tag, val) = props[0]
        if mt.PROP_TYPE(tag) == mt.PT_ERROR:
            print 'Prop_Tag (0x%16x) not found. Tag: 0x%16x' % (prop_tag,
                                                                (tag % (2**64)))
        else:
            print 'Hurrah! Custom found: ', val

    def test_read_emails (self, itemid):
        eid = base64.b64decode(itemid)
        olcf = self.deff
        
        prop_tag = olcf.get_proptags().valu('ASYNK_PR_EMAIL_1')
        store    = olcf.get_msgstore()
        item     = store.get_obj().OpenEntry(eid, None, mapi.MAPI_BEST_ACCESS)

        hr, props = item.GetProps([prop_tag], mapi.MAPI_UNICODE)
        (tag, val) = props[0]
        if mt.PROP_TYPE(tag) == mt.PT_ERROR:
            print 'Prop_Tag (0x%16x) not found. Tag: 0x%16x' % (prop_tag,
                                                                (tag % (2**64)))
        else:
            print 'Email address found: ', val

    def test_sync_status (self):
        sl = SyncLists(self.deff, 'gc')
        self.deff.prep_sync_lists('gc', sl)