geier / pycarddav

DEPRECATED - use vdirsyncer & khard -- easy to use CLI CardDAV client
http://lostpackets.de/pycarddav
MIT License
99 stars 35 forks source link

A few improvements when integrating with DavMail #105

Open mistotebe opened 9 years ago

mistotebe commented 9 years ago

First commit allows using proxies natively. Second actually sends a valid request when PROPFINDing the addressbook data.

untitaker commented 9 years ago

The issue with PROPFIND is likely fixed with #92.

untitaker commented 9 years ago

You can achieve proxy support by setting environment variables: http://docs.python-requests.org/en/latest/user/advanced/?highlight=proxy#proxies

But i am not sure why you'd need proxy support for DavMail. I ran it locally and just had to point the client against a local URL.

mistotebe commented 9 years ago

The proxy support was helpful when trying to find out what was going wrong, going through an intercepting proxy like mitmproxy, but I believe it is useful nevertheless, which is why I included it here.

By issue #92, do you mean pycarddav being replaced by vdirsyncer? At the moment, I also use pycarddav as a library, is there a way to do that with vdirsyncer?

untitaker commented 9 years ago

By issue #92, do you mean pycarddav being replaced by vdirsyncer?

Not really. Vdirsyncer is just the synchronization part. It stores contacts e.g. in a directory of .vcf files. There are already a few apps with functionality equivalent to pycarddav: https://vdirsyncer.readthedocs.org/en/latest/supported.html#client-applications

At the moment, I also use pycarddav as a library, is there a way to do that with vdirsyncer?

You can use vdirsyncer as a library, but as it's not an exact replacement, you'll have to see if the particular feature implementation you want to use is actually within its scope. I suppose you want to take a look at the CarddavStorage class in https://github.com/untitaker/vdirsyncer/blob/master/vdirsyncer/storage/dav.py

geier commented 9 years ago

Hi, sorry for not getting back to you on this sooner.

First let me thank you for this pull request: thanks!

Second, it does not currently work for me, I get this error:

Traceback (most recent call last):
  File "/home/cg/.virtualenvs/khal/bin/pycardsyncer", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/home/cg/workspace/pycarddav/bin/pycardsyncer", line 55, in <module>
    sync(conf)
  File "/home/cg/workspace/pycarddav/pycarddav/controllers/sync.py", line 50, in sync
    abook = syncer.get_abook()  # type(abook): dict
  File "/home/cg/workspace/pycarddav/pycarddav/carddav.py", line 134, in get_abook
    abook = self._process_xml_props(xml)
  File "/home/cg/workspace/pycarddav/pycarddav/carddav.py", line 278, in _process_xml_props
    props.text.split(';')[0].strip() in ['text/vcard', 'text/x-vcard']):
AttributeError: 'NoneType' object has no attribute 'split'

If you fix this, I'll merge this PR.