geier / pycarddav

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

Error reporting error! 'Response' object has no attribute 'reason' #38

Closed chrisisbd closed 11 years ago

chrisisbd commented 11 years ago

I'm trying out the write ability of pycardsyncer.

I've added a couple of E-Mail addresses from mutt and then ran pycardsyncer, I got the following:-

chris$ pycardsyncer INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (2): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost Traceback (most recent call last): File "/usr/local/bin/pycardsyncer", line 5, in pkg_resources.run_script('pyCardDAV==0.4', 'pycardsyncer') File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 499, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1239, in run_script execfile(script_filename, namespace, namespace) File "/usr/local/lib/python2.7/dist-packages/pyCardDAV-0.4-py2.7.egg/EGG-INFO/scripts/pycardsyncer", line 83, in controllers.sync(conf) File "/usr/local/lib/python2.7/dist-packages/pyCardDAV-0.4-py2.7.egg/pycarddav/controllers.py", line 154, in sync (href_new, etag_new) = syncer.upload_new_card(card.vcf) File "/usr/local/lib/python2.7/dist-packages/pyCardDAV-0.4-py2.7.egg/pycarddav/carddav.py", line 230, in upload_new_card raise UploadFailed(response.reason) AttributeError: 'Response' object has no attribute 'reason'

I've had a hard look through the python requests module documentation and, along with some googling, I think this may be a difficulty with different versions. I'm running 0.1.12.1

geier commented 11 years ago

I'll have a look at this later tonight, sorry for what looks like at least unspecific documentation or another bug.

chrisisbd commented 11 years ago

I have changed the line:- /usr/local/lib/python2.7/dist-packages/pyCardDAV-0.4-py2.7.egg/pycarddav/carddav.py", line 230, in upload_new_card

To "raise UploadFailed(response.status_code)" and it now reports:- pycarddav.carddav.UploadFailed: 405

So it's a "method not allowed" error.

geier commented 11 years ago

Try replacing it with: response.raise_for_status() Or check out the develop branch

chrisisbd commented 11 years ago

OK, i've changed to the develop branch.

Now I get:- chris$ pycardsyncer INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost CRITICAL:root:While syncing account "work" an error occured: 'SQLiteDb' object has no attribute 'db_path'

geier commented 11 years ago

hmm... I will need to debug that later, for now I've just created a new branch called 4.1-dev which should fix your issues. Keep me posted.

chrisisbd commented 11 years ago

OK, I'm now running the version in branch 4.1-dev

That takes me back to the original error:- chris$ pycardsyncer INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (2): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost Traceback (most recent call last): File "/usr/local/bin/pycardsyncer", line 5, in pkg_resources.run_script('pyCardDAV==0.4', 'pycardsyncer') File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 499, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1239, in run_script execfile(script_filename, namespace, namespace) File "/usr/local/lib/python2.7/dist-packages/pyCardDAV-0.4-py2.7.egg/EGG-INFO/scripts/pycardsyncer", line 83, in controllers.sync(conf) File "/usr/local/lib/python2.7/dist-packages/pyCardDAV-0.4-py2.7.egg/pycarddav/controllers.py", line 154, in sync (href_new, etag_new) = syncer.upload_new_card(card.vcf) File "/usr/local/lib/python2.7/dist-packages/pyCardDAV-0.4-py2.7.egg/pycarddav/carddav.py", line 230, in upload_new_card raise UploadFailed(response.reason) AttributeError: 'Response' object has no attribute 'reason'

... and if I fix line 230, I get:- chris$ pycardsyncer INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (2): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost Traceback (most recent call last): File "/usr/local/bin/pycardsyncer", line 5, in pkg_resources.run_script('pyCardDAV==0.4', 'pycardsyncer') File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 499, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1239, in run_script execfile(script_filename, namespace, namespace) File "/usr/local/lib/python2.7/dist-packages/pyCardDAV-0.4-py2.7.egg/EGG-INFO/scripts/pycardsyncer", line 83, in controllers.sync(conf) File "/usr/local/lib/python2.7/dist-packages/pyCardDAV-0.4-py2.7.egg/pycarddav/controllers.py", line 154, in sync (href_new, etag_new) = syncer.upload_new_card(card.vcf) File "/usr/local/lib/python2.7/dist-packages/pyCardDAV-0.4-py2.7.egg/pycarddav/carddav.py", line 230, in upload_new_card raise UploadFailed(response.status_code) pycarddav.carddav.UploadFailed: 405

Thanks for all the help so far. I'm very happy to continue this debugging if you're OK with it.

chrisisbd commented 11 years ago

OK, I have found the reason for the error I was getting with the 'develop' branch. I still had the database I had created with the 0.4 release version and that's incompatible. Turning debug on in the configuration file allowed me to find that.

How do I enable write support in the develop version?

chrisisbd commented 11 years ago

I have enabled write support by making it the default in the code. I can't get it to work from the pycard.conf file. I have moved write_support to the Account section but with the value YesPleaseIDoHaveABackupOfMyData it tells me it's not a boolean and with the value True it doesn't set write_support to True.

Anyway, it has taken me back to the same old error when I add a new E-Mail address from mutt:-

INFO:urllib3.connectionpool:Starting new HTTP connection (2): localhost DEBUG:urllib3.connectionpool:"PROPFIND /owncloud/remote.php/carddav/addressbooks/chris/contacts ('HTTP/1.1',)" 207 None DEBUG:root:looking for locally changed vcards... DEBUG:root:trying to upload new card 10D92889-B67A48DF-9563F976 INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost DEBUG:urllib3.connectionpool:"PUT /owncloud/remote.php/carddav/addressbooks/chris/contacts2586AC9F-E3AA868E-D71D25A8.vcf ('HTTP/1.1',)" 405 303 INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost DEBUG:urllib3.connectionpool:"PUT /owncloud/remote.php/carddav/addressbooks/chris/contactsB9603EEA-D1E382AE-6A4DC7A3.vcf ('HTTP/1.1',)" 405 303 INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost DEBUG:urllib3.connectionpool:"PUT /owncloud/remote.php/carddav/addressbooks/chris/contactsDC32E57F-34B3E492-E5BCBFB0.vcf ('HTTP/1.1',)" 405 303 INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost DEBUG:urllib3.connectionpool:"PUT /owncloud/remote.php/carddav/addressbooks/chris/contactsE20B5F3D-F78906FA-CAE000A0.vcf ('HTTP/1.1',)" 405 303 INFO:urllib3.connectionpool:Starting new HTTP connection (1): localhost DEBUG:urllib3.connectionpool:"PUT /owncloud/remote.php/carddav/addressbooks/chris/contactsC1CE629B-A250F036-168A82A6.vcf ('HTTP/1.1',)" 405 303 Traceback (most recent call last): File "/usr/local/bin/pycardsyncer", line 5, in pkg_resources.run_script('pyCardDAV==0.4', 'pycardsyncer') File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 499, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1239, in run_script execfile(script_filename, namespace, namespace) File "/usr/local/lib/python2.7/dist-packages/pyCardDAV-0.4-py2.7.egg/EGG-INFO/scripts/pycardsyncer", line 82, in controllers.sync(conf) File "/usr/local/lib/python2.7/dist-packages/pyCardDAV-0.4-py2.7.egg/pycarddav/controllers.py", line 165, in sync (href_new, etag_new) = syncer.upload_new_card(card.vcf) File "/usr/local/lib/python2.7/dist-packages/pyCardDAV-0.4-py2.7.egg/pycarddav/carddav.py", line 208, in upload_new_card response.raise_for_status() File "/usr/lib/python2.7/dist-packages/requests/models.py", line 841, in raise_for_status raise http_error requests.exceptions.HTTPError: 405 Client Error

chrisisbd commented 11 years ago

I believe I have found the bug, at least I'm getting things to upload to the server now.

It's line 193 of carddav.py, a delimeter needs to be added between the URL and the random file name:-

remotepath = str(self.url.resource + '/' + rand_string + ".vcf")

Actually that should really be:- os.path.join(self.url.resource, rand_string + ".vcf") shouldn't it?

geier commented 11 years ago

do you have a jabber/google talk? probably better for debugging this. my address is listed here http://lostpackets.de/pycarddav/ under Feedback

geier commented 11 years ago

does your configured resource in the config file end on a slash? but I guess it should be added if there isn't one

chrisisbd commented 11 years ago

No, it doesn't have a trailing space, it's exactly as it's given by "Show CardDav link" in the owncloud server, i cut and pasted it into the configuration file.

I'll set up a jabber account so we can talk that way. I'm sure I'll have more questions and problems but it's getting a bit late now and my eyes are getting tired! :-)

Thanks for all the help so far.